Class: Tazworks::Order
Overview
Instance Attribute Summary
Attributes inherited from Model
#attributes, #attributes_loaded, #ids
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
#attributes_loaded?, #clientGuid, find, #initialize, initialize_from_response, #load_attributes, #loaded_attributes, #reload
Class Method Details
.all(clientGuid, params = {}) ⇒ Object
14
15
16
17
|
# File 'lib/tazworks/order.rb', line 14
def self.all(clientGuid, params = {})
raw_response = RestClient.get("/v1/clients/#{clientGuid}/orders", { params: })
OrderPagedResponse.new(raw_response, { clientGuid: })
end
|
.create(clientGuid, params) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/tazworks/order.rb', line 20
def self.create(clientGuid, params)
required_params = %w[applicantGuid clientProductGuid]
required_params.each do |rp|
raise ArgumentError, "#{rp} is missing in params hash." unless params.key?(rp.to_sym)
end
response = RestClient.post("/v1/clients/#{clientGuid}/orders", params)
order = Order.initialize_from_response({ clientGuid: }, response)
order.ids[:orderGuid] = order.attributes[:orderGuid]
order
end
|
.get(ids) ⇒ Object
9
10
11
|
# File 'lib/tazworks/order.rb', line 9
def self.get(ids)
RestClient.get("/v1/clients/#{ids[:clientGuid]}/orders/#{ids[:orderGuid]}")
end
|
Instance Method Details
#order_status ⇒ Object
34
35
36
37
|
# File 'lib/tazworks/order.rb', line 34
def order_status
response = RestClient.get("/v1/clients/#{clientGuid}/orders/#{orderGuid}/status")
JSON.parse(response.body)
end
|
#orderGuid ⇒ Object
50
51
52
|
# File 'lib/tazworks/order.rb', line 50
def orderGuid
@ids[:orderGuid]
end
|
#quickappApplicantLink ⇒ Object
54
55
56
|
# File 'lib/tazworks/order.rb', line 54
def quickappApplicantLink
loaded_attributes[:quickappApplicantLink]
end
|
#results_as_pdf ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/tazworks/order.rb', line 40
def results_as_pdf
begin
response = RestClient.get("/v1/clients/#{clientGuid}/orders/#{orderGuid}/resultsAsPdf")
rescue ::RestClient::BadRequest => e
raise Error, e.response.body
end
json_parsed = JSON.parse(response.body, { symbolize_names: true })
json_parsed[:resultsUrl]
end
|