Class: GenesisRuby::Api::Requests::NonFinancial::BillingApi::Statement

Inherits:
Base::NonFinancial::BillingApi::Base show all
Defined in:
lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb

Overview

Billing Statements API request

Constant Summary collapse

MAX_COUNT_BILLING_STATEMENT =

rubocop:disable Metrics/ClassLength

1_000
MAX_DAYS_DIFFERENCE =
7
STATUSES =

Allowed values for the status filter

%w(open pending paid bounced).freeze
ORDER_BY_FIELDS =

Allowed values for the sort_by_field parameter

%w(billingStatement creationDate startDate endDate valueDate
currency status masterAccountName).freeze

Constants inherited from GenesisRuby::Api::Request

GenesisRuby::Api::Request::AUTH_TYPE_BASIC, GenesisRuby::Api::Request::AUTH_TYPE_TOKEN, GenesisRuby::Api::Request::METHOD_DELETE, GenesisRuby::Api::Request::METHOD_GET, GenesisRuby::Api::Request::METHOD_PATCH, GenesisRuby::Api::Request::METHOD_POST, GenesisRuby::Api::Request::METHOD_PUT, GenesisRuby::Api::Request::PORT_HTTPS, GenesisRuby::Api::Request::PROTOCOL_HTTPS

Instance Attribute Summary collapse

Attributes included from Mixins::Requests::NonFinancial::PagingAttributes

#page, #per_page

Attributes included from Mixins::Requests::NonFinancial::BillingApi::SortAttributes

#sort_by_direction, #sort_by_field

Attributes inherited from Base::Versioned

#allowed_versions, #version

Attributes inherited from GenesisRuby::Api::Request

#api_config

Instance Method Summary collapse

Methods inherited from Base::NonFinancial::BillingApi::Base

#billing_statement, #billing_statement=

Methods included from Mixins::Requests::NonFinancial::DateAttributes

#end_date, #end_date=, #end_date_from, #end_date_from=, #end_date_to, #end_date_to=, #start_date, #start_date=, #start_date_from, #start_date_from=, #start_date_to, #start_date_to=

Methods inherited from GenesisRuby::Api::Request

#build_document

Constructor Details

#initialize(configuration, _builder_interface = nil) ⇒ Statement

Returns a new instance of Statement.



37
38
39
40
41
42
43
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 37

def initialize(configuration, _builder_interface = nil)
  super configuration

  self.root_key     = 'query'
  self.request_name = 'billingStatements'
  self.request_path = 'billing_statements'
end

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



28
29
30
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 28

def currency
  @currency
end

#next=(value) ⇒ Object (writeonly)

Cursor for the next page of results



31
32
33
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 31

def next=(value)
  @next = value
end

#payment_methodObject

Returns the value of attribute payment_method.



27
28
29
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 27

def payment_method
  @payment_method
end

#statusObject

Returns the value of attribute status.



27
28
29
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 27

def status
  @status
end

Instance Method Details

#creation_dateObject

Returns the creation date formatted as YYYY-MM-DD



59
60
61
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 59

def creation_date
  @creation_date&.strftime(Api::Constants::DateTimeFormats::YYYY_MM_DD_ISO_8601)
end

#creation_date=(value) ⇒ Object

Sets the creation date filter



64
65
66
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 64

def creation_date=(value)
  parse_date attribute: __method__, value: value, allow_empty: true
end

#response_fieldsObject

List of requested response fields



46
47
48
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 46

def response_fields
  @response_fields || []
end

#response_fields=(value) ⇒ Object

Sets response fields validated against StatementResponseFields



51
52
53
54
55
56
# File 'lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb', line 51

def response_fields=(value)
  parse_array_of_strings attribute: __method__,
                         value: value,
                         allowed: Api::Constants::Transactions::Parameters::NonFinancial::BillingApi::
                             StatementResponseFields.all
end