Class: Assently::Client

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

Defined Under Namespace

Classes: ErrorResult, SuccessResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret, environment = :production) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
# File 'lib/assently/client.rb', line 12

def initialize api_key, api_secret, environment = :production
  @api_key = api_key
  @api_secret = api_secret
  self.environment = environment
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/assently/client.rb', line 8

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



8
9
10
# File 'lib/assently/client.rb', line 8

def api_secret
  @api_secret
end

#environmentObject

Returns the value of attribute environment.



10
11
12
# File 'lib/assently/client.rb', line 10

def environment
  @environment
end

Instance Method Details

#connectionObject



52
53
54
55
56
# File 'lib/assently/client.rb', line 52

def connection
  HTTP.
    headers(accept: "application/json").
    basic_auth(user: api_key, pass: api_secret)
end

#create_case(signature_case, options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/assently/client.rb', line 18

def create_case signature_case, options = {}
  signature_case_json = Assently::Serializers::CaseSerializer.serialize signature_case, options

  post "/api/v2/createcase", signature_case_json
end

#find_cases(options = {}) ⇒ Object



32
33
34
# File 'lib/assently/client.rb', line 32

def find_cases options = {}
  get "/api/v2/findcases", options
end

#get(api_command, parameters = {}) ⇒ Object



44
45
46
# File 'lib/assently/client.rb', line 44

def get api_command, parameters = {}
  make_response make_get(api_command, parameters)
end

#get_case(id) ⇒ Object



28
29
30
# File 'lib/assently/client.rb', line 28

def get_case id
  get "/api/v2/getcase", { id: id }
end

#get_document_data(case_id, document_id) ⇒ Object



36
37
38
# File 'lib/assently/client.rb', line 36

def get_document_data case_id, document_id
  get "/api/v2/getdocumentdata", { "caseId" => case_id, "documentId" => document_id }
end

#headersObject



58
59
60
# File 'lib/assently/client.rb', line 58

def headers
  connection.headers
end

#hostObject



48
49
50
# File 'lib/assently/client.rb', line 48

def host
  hosts.fetch(self.environment, hosts[:production])
end

#post(api_command, body = nil) ⇒ Object



40
41
42
# File 'lib/assently/client.rb', line 40

def post api_command, body = nil
  make_response make_post(api_command, body)
end

#send_case(id) ⇒ Object



24
25
26
# File 'lib/assently/client.rb', line 24

def send_case id
  post "/api/v2/sendcase", JSON.pretty_generate({ id: id })
end