Class: Unit::Statement
Instance Attribute Summary
Attributes inherited from APIResource
#id, #raw_data, #relationships, #type
Class Method Summary
collapse
included
Methods inherited from APIResource
#as_json_api, attribute, #attributes, belongs_to, build_resource_from_json_api, #clear_attributes!, connection, #dirty?, #dirty_attributes, has_many, #initialize, #mark_as_clean!, #mark_attribute_as_dirty, path, resource_path, #resource_type, resources_path, #schema, schema, #update_attribute, #update_resource_from_json_api
Class Method Details
.base_url(statement_id, response_type, customer_id) ⇒ Object
17
18
19
20
|
# File 'lib/unit-ruby/statement.rb', line 17
def self.base_url(statement_id, response_type, customer_id)
"#{Unit::Connection.base_url}statements/#{statement_id}/#{response_type}" \
"?filter[customerId]=#{customer_id}"
end
|
.html_for(statement_id:, customer_id:) ⇒ Object
12
13
14
15
|
# File 'lib/unit-ruby/statement.rb', line 12
def self.html_for(statement_id:, customer_id:)
url = base_url(statement_id, :html, customer_id)
statement_connection(url).get.body
end
|
.pdf_for(statement_id:, customer_id:) ⇒ Object
7
8
9
10
|
# File 'lib/unit-ruby/statement.rb', line 7
def self.pdf_for(statement_id:, customer_id:)
url = base_url(statement_id, :pdf, customer_id)
statement_connection(url).get.body
end
|
.statement_connection(url) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/unit-ruby/statement.rb', line 22
def self.statement_connection(url)
Faraday.new(url) do |f|
f.['Authorization'] = "Bearer #{Unit::Connection.api_key}"
end
end
|