Sha256: 9acbdadf1398c19f4779f8b3cc1979095d0817857851ea60ed50b21e7c584e77
Contents?: true
Size: 944 Bytes
Versions: 22
Compression:
Stored size: 944 Bytes
Contents
module Unit class Statement < APIResource path '/statements' attribute :period, Types::String def self.pdf_for(statement_id:, customer_id:) url = base_url(statement_id, :pdf, customer_id) statement_connection(url).get.body end def self.html_for(statement_id:, customer_id:) url = base_url(statement_id, :html, customer_id) statement_connection(url).get.body end def self.base_url(statement_id, response_type, customer_id) "#{Unit::Connection.base_url}statements/#{statement_id}/#{response_type}" \ "?filter[customerId]=#{customer_id}" end def self.statement_connection(url) # Establishing a new connection to avoid having to alter the existing connection to support pdf / html responses Faraday.new(url) do |f| f.headers['Authorization'] = "Bearer #{Unit::Connection.api_key}" end end include ResourceOperations::List end end
Version data entries
22 entries across 22 versions & 1 rubygems