Class: Icasework::Resource
- Inherits:
-
Object
- Object
- Icasework::Resource
show all
- Includes:
- Curl
- Defined in:
- lib/icasework/resource.rb,
lib/icasework/resource/curl.rb,
lib/icasework/resource/data.rb,
lib/icasework/resource/payload.rb
Overview
API Endpoints for configured database
Defined Under Namespace
Modules: Curl, Data, Payload
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Curl
#to_curl
Constructor Details
#initialize(method, path, payload, **options) ⇒ Resource
Returns a new instance of Resource.
41
42
43
44
45
46
|
# File 'lib/icasework/resource.rb', line 41
def initialize(method, path, payload, **options)
@method = method
@path = path
@payload = payload
@options = options
end
|
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
39
40
41
|
# File 'lib/icasework/resource.rb', line 39
def method
@method
end
|
Class Method Details
.create_case(payload = {}) ⇒ Object
31
32
33
|
# File 'lib/icasework/resource.rb', line 31
def create_case(payload = {})
new(:post, 'createcase', payload)
end
|
.get_case_attribute(payload = {}) ⇒ Object
19
20
21
|
# File 'lib/icasework/resource.rb', line 19
def get_case_attribute(payload = {})
new(:get, 'getcaseattribute', payload)
end
|
.get_case_details(payload = {}) ⇒ Object
23
24
25
|
# File 'lib/icasework/resource.rb', line 23
def get_case_details(payload = {})
new(:get, 'getcasedetails', payload)
end
|
.get_case_documents(payload = {}) ⇒ Object
27
28
29
|
# File 'lib/icasework/resource.rb', line 27
def get_case_documents(payload = {})
new(:get, 'getcasedocuments', payload)
end
|
.get_cases(payload = {}) ⇒ Object
15
16
17
|
# File 'lib/icasework/resource.rb', line 15
def get_cases(payload = {})
new(:get, 'getcases', payload, subdomain: 'uatportal')
end
|
.token(payload = {}) ⇒ Object
11
12
13
|
# File 'lib/icasework/resource.rb', line 11
def token(payload = {})
new(:post, 'token', payload, authorised: false, format: nil)
end
|
Instance Method Details
#data ⇒ Object
77
78
79
|
# File 'lib/icasework/resource.rb', line 77
def data
response
end
|
57
58
59
60
61
62
63
|
# File 'lib/icasework/resource.rb', line 57
def
return {} unless authorised?
= {}
[:authorization] = "Bearer #{Icasework::Token::Bearer.generate}"
end
|
#payload ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/icasework/resource.rb', line 65
def payload
return @payload if @payload_parsed
@payload[:format] = format if format
@payload = Payload.process(@payload)
@payload = { params: @payload } if method == :get
@payload_parsed = true
@payload
end
|
#url ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/icasework/resource.rb', line 48
def url
if Icasework.production?
"https://#{Icasework.account}.icasework.com/#{@path}"
else
subdomain = @options.fetch(:subdomain, 'uat')
"https://#{subdomain}.icasework.com/#{@path}?db=#{Icasework.account}"
end
end
|