Class: Aria

Inherits:
Object
  • Object
show all
Defined in:
lib/aria_sdk_unofficial.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_no:, auth_key:, api_type:, env_type:, api_name: nil) ⇒ Aria

Returns a new instance of Aria.



9
10
11
12
13
# File 'lib/aria_sdk_unofficial.rb', line 9

def initialize(client_no:, auth_key:, api_type:, env_type:, api_name: nil)
    self.client_no = client_no
    self.auth_key = auth_key
    self.url = get_url api_type, env_type
end

Instance Attribute Details

#auth_keyObject

Returns the value of attribute auth_key.



7
8
9
# File 'lib/aria_sdk_unofficial.rb', line 7

def auth_key
  @auth_key
end

#client_noObject

Returns the value of attribute client_no.



7
8
9
# File 'lib/aria_sdk_unofficial.rb', line 7

def client_no
  @client_no
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/aria_sdk_unofficial.rb', line 7

def url
  @url
end

Instance Method Details

#call(api_name, options = {}, remove_nil = false) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aria_sdk_unofficial.rb', line 15

def call(api_name, options = {}, remove_nil=false)

    defaults = {
        :output_format => 'json',
        :client_no => self.client_no,
        :auth_key => self.auth_key,
        :rest_call => api_name
    }

    if remove_nil
      options.keys.each { |x| options.delete x if options[x].nil? }
    end

    options.merge!(defaults)
    HTTParty.post(self.url, :body => options)
end

#get_url(api_type, env_type) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/aria_sdk_unofficial.rb', line 32

def get_url(api_type, env_type)
  env_url = ''
  full_url = ''
  if env_type == 0 # SF
    env_url += '.future.stage'
  elsif env_type == 1 # SC
    env_url += '.current.stage'
  elsif env_type == 3 # SF CPH
    env_url += '.future.stage.cph'
  elsif env_type == 4 # Prod CPH
    env_url = '.cph'
  end

  if api_type == 0 # core
    full_url = "https://secure#{env_url}.ariasystems.net/api/ws/api_ws_class_dispatcher.php"
  elsif api_type == 1 # object
    full_url = "https://secure#{env_url}.ariasystems.net/api/AriaQuery/objects.php"
  else # admin
    full_url = "https://admintools#{env_url}.ariasystems.net/AdminTools.php/Dispatcher"
  end
    return full_url
end