Showing
19 changed files
with
1 additions
and
424 deletions
lib/appdocks/.DS_Store
deleted
100644 → 0
No preview for this file type
lib/appdocks/api/base.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -module Appdocks | |
| 4 | - module Api | |
| 5 | - class Base | |
| 6 | - def success? | |
| 7 | - response && response[:status].to_i == 1 | |
| 8 | - end | |
| 9 | - | |
| 10 | - def error_code | |
| 11 | - response && response[:error] | |
| 12 | - end | |
| 13 | - | |
| 14 | - def error_message | |
| 15 | - response && response[:message] | |
| 16 | - end | |
| 17 | - | |
| 18 | - def errors | |
| 19 | - response && response[:errors] | |
| 20 | - end | |
| 21 | - | |
| 22 | - private | |
| 23 | - | |
| 24 | - attr_reader :response | |
| 25 | - end | |
| 26 | - end | |
| 27 | -end |
lib/appdocks/api/container/batch.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request_batch' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class Batch < Appdocks::Api::Base | |
| 10 | - def call(container_id:, data:) | |
| 11 | - @response = Appdocks::Api::RequestBatch.new.send_request('pushToDataContainerTable', data, | |
| 12 | - [container_id]) | |
| 13 | - end | |
| 14 | - | |
| 15 | - def operation_id | |
| 16 | - response[:processId] | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | - end | |
| 21 | -end |
lib/appdocks/api/container/batch_status.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request_batch' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class BatchStatus < Appdocks::Api::Base | |
| 10 | - def call(operation_ids:) | |
| 11 | - @response = Appdocks::Api::RequestBatch.new.send_request('getProgressOperationID', data, | |
| 12 | - [operation_ids]) | |
| 13 | - end | |
| 14 | - | |
| 15 | - def data | |
| 16 | - response | |
| 17 | - end | |
| 18 | - | |
| 19 | - def statuses | |
| 20 | - response[:operationStatus] | |
| 21 | - end | |
| 22 | - end | |
| 23 | - end | |
| 24 | - end | |
| 25 | -end |
lib/appdocks/api/container/delete.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class Delete < Appdocks::Api::Base | |
| 10 | - def call(id:, container_id:) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('deleteDataContainerRecordId', nil, | |
| 12 | - {id: container_id, record_id: id}) | |
| 13 | - end | |
| 14 | - | |
| 15 | - def data | |
| 16 | - response[:data] | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | - end | |
| 21 | -end |
lib/appdocks/api/container/insert.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class Insert < Appdocks::Api::Base | |
| 10 | - def call(container_id:, language:, data:) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('insertIntoDataContainerId', data, | |
| 12 | - {id: container_id, language: language}) | |
| 13 | - end | |
| 14 | - | |
| 15 | - def record_id | |
| 16 | - response[:contentdockRecordUid] | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | - end | |
| 21 | -end |
lib/appdocks/api/container/records.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class Records < Appdocks::Api::Base | |
| 10 | - def call(container_id) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('getDataContainerRecordsForContainerId', nil, | |
| 12 | - {id: container_id, scope: 'all'}) | |
| 13 | - end | |
| 14 | - | |
| 15 | - def data | |
| 16 | - response[:data] | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | - end | |
| 21 | -end |
lib/appdocks/api/container/system_tables.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class SystemTables < Appdocks::Api::Base | |
| 10 | - def call | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('getDataContainerTableListSDK', nil, {scope: 'system'}) | |
| 12 | - end | |
| 13 | - | |
| 14 | - def data | |
| 15 | - response[:data] | |
| 16 | - end | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | -end |
lib/appdocks/api/container/update.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class Update < Appdocks::Api::Base | |
| 10 | - def call(id:, container_id:, data:) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('updateDataContainerRecordId', data, | |
| 12 | - {id: container_id, record_id: id}) | |
| 13 | - end | |
| 14 | - | |
| 15 | - def data | |
| 16 | - response[:data] | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | - end | |
| 21 | -end |
lib/appdocks/api/container/user_tables.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module Container | |
| 9 | - class UserTables < Appdocks::Api::Base | |
| 10 | - def call | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('getDataContainerTableListSDK', nil, {scope: 'user'}) | |
| 12 | - end | |
| 13 | - | |
| 14 | - def data | |
| 15 | - response[:data] | |
| 16 | - end | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | -end |
lib/appdocks/api/mobile_user/delete.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module MobileUser | |
| 9 | - class Delete < Appdocks::Api::Base | |
| 10 | - def call(arguments) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('deleteMobileUser', nil, arguments) | |
| 12 | - end | |
| 13 | - end | |
| 14 | - end | |
| 15 | - end | |
| 16 | -end |
lib/appdocks/api/mobile_user/fields.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module MobileUser | |
| 9 | - class Fields < Appdocks::Api::Base | |
| 10 | - def call | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('mobileUserFields', nil) | |
| 12 | - end | |
| 13 | - | |
| 14 | - def fields | |
| 15 | - response[:fields] | |
| 16 | - end | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | -end |
lib/appdocks/api/mobile_user/register.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module MobileUser | |
| 9 | - class Register < Appdocks::Api::Base | |
| 10 | - def call(data) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('registerMobileUser', data) | |
| 12 | - end | |
| 13 | - end | |
| 14 | - end | |
| 15 | - end | |
| 16 | -end |
lib/appdocks/api/mobile_user/tags.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module MobileUser | |
| 9 | - class Tags < Appdocks::Api::Base | |
| 10 | - def call | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('mobileUserTags', nil) | |
| 12 | - end | |
| 13 | - | |
| 14 | - def tags | |
| 15 | - response[:tags] | |
| 16 | - end | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | -end |
lib/appdocks/api/mobile_user/update.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require './appdocks/api/request' | |
| 4 | -require './appdocks/api/base' | |
| 5 | - | |
| 6 | -module Appdocks | |
| 7 | - module Api | |
| 8 | - module MobileUser | |
| 9 | - class Update < Appdocks::Api::Base | |
| 10 | - def call(arguments, data) | |
| 11 | - @response = Appdocks::Api::Request.new.send_request('updateMobileUser', data, arguments) | |
| 12 | - end | |
| 13 | - end | |
| 14 | - end | |
| 15 | - end | |
| 16 | -end |
lib/appdocks/api/request.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require 'uri' | |
| 4 | -require 'net/http' | |
| 5 | -require 'json' | |
| 6 | - | |
| 7 | -module Appdocks | |
| 8 | - module Api | |
| 9 | - class Request | |
| 10 | - BASE_URL = "https://www.development-district.de/api" | |
| 11 | - | |
| 12 | - def send_request(command, data = {}, arguments = {}) | |
| 13 | - @command = command | |
| 14 | - @arguments = arguments | |
| 15 | - @data = data | |
| 16 | - uri = URI(BASE_URL) | |
| 17 | - | |
| 18 | - http = Net::HTTP.new(uri.host, uri.port) | |
| 19 | - http.use_ssl = true | |
| 20 | - request = prepare_request(uri) | |
| 21 | - response = http.request(request) | |
| 22 | - | |
| 23 | - if Integer(response.code, 10) == 200 | |
| 24 | - JSON.parse(response.body, symbolize_names: true) | |
| 25 | - else | |
| 26 | - {error: response.code.to_s, message: response.body} | |
| 27 | - end | |
| 28 | - end | |
| 29 | - | |
| 30 | - private | |
| 31 | - | |
| 32 | - attr_reader :command, :arguments, :data | |
| 33 | - | |
| 34 | - def prepare_request(uri) | |
| 35 | - request = Net::HTTP::Post.new(uri) | |
| 36 | - request.body = params.to_json | |
| 37 | - set_request_options(request) | |
| 38 | - request | |
| 39 | - end | |
| 40 | - | |
| 41 | - def set_request_options(request, type = 'json') | |
| 42 | - request["Content-Type"] = "application/#{type}" | |
| 43 | - request["User-Agent"] = "contentDockAPI/1.0" | |
| 44 | - end | |
| 45 | - | |
| 46 | - def params | |
| 47 | - param = [ | |
| 48 | - api_key, | |
| 49 | - arguments.merge({agent: "contentDockAPI/1.0"}) | |
| 50 | - ] | |
| 51 | - param << data unless data.nil? | |
| 52 | - | |
| 53 | - { | |
| 54 | - data: { | |
| 55 | - query: { | |
| 56 | - command: command, | |
| 57 | - param: param | |
| 58 | - } | |
| 59 | - }.to_json | |
| 60 | - } | |
| 61 | - end | |
| 62 | - | |
| 63 | - def api_key | |
| 64 | - Appdocks::Api::Settings.api_key | |
| 65 | - end | |
| 66 | - end | |
| 67 | - end | |
| 68 | -end |
lib/appdocks/api/request_batch.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -require 'uri' | |
| 4 | -require 'net/http' | |
| 5 | -require 'json' | |
| 6 | - | |
| 7 | -module Appdocks | |
| 8 | - module Api | |
| 9 | - class RequestBatch < Request | |
| 10 | - BASE_URL = "https://www.development-district.de/api" | |
| 11 | - | |
| 12 | - private | |
| 13 | - | |
| 14 | - def params | |
| 15 | - param = [ | |
| 16 | - api_key | |
| 17 | - ] | |
| 18 | - | |
| 19 | - param += [Appdocks::Api::Settings.subdomain, Appdocks::Api::Settings.agent] | |
| 20 | - | |
| 21 | - param += arguments | |
| 22 | - param << data unless data.nil? | |
| 23 | - | |
| 24 | - { | |
| 25 | - data: { | |
| 26 | - query: { | |
| 27 | - command: command, | |
| 28 | - param: param | |
| 29 | - } | |
| 30 | - }.to_json | |
| 31 | - } | |
| 32 | - end | |
| 33 | - end | |
| 34 | - end | |
| 35 | -end |
lib/appdocks/api/settings.rb
deleted
100644 → 0
| 1 | -# frozen_string_literal: true | |
| 2 | - | |
| 3 | -module Appdocks | |
| 4 | - module Api | |
| 5 | - class Settings | |
| 6 | - class << self | |
| 7 | - def api_key | |
| 8 | - options[:api_key] | |
| 9 | - end | |
| 10 | - | |
| 11 | - def subdomain | |
| 12 | - options[:subdomain] | |
| 13 | - end | |
| 14 | - | |
| 15 | - def agent | |
| 16 | - options[:agent] | |
| 17 | - end | |
| 18 | - | |
| 19 | - def update(params = {}) | |
| 20 | - options.merge!(params) | |
| 21 | - end | |
| 22 | - | |
| 23 | - def option(name, value) | |
| 24 | - options[name] = value | |
| 25 | - end | |
| 26 | - | |
| 27 | - def options | |
| 28 | - @options ||= {} | |
| 29 | - end | |
| 30 | - end | |
| 31 | - | |
| 32 | - option(:api_key, '') | |
| 33 | - end | |
| 34 | - end | |
| 35 | -end |