Class: Rotessa::Client
- Inherits:
-
Object
- Object
- Rotessa::Client
- Includes:
- HTTParty
- Defined in:
- lib/rotessa/client.rb
Constant Summary collapse
- PAGE_SIZE =
Rotessa’s default page size
1000
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #customer(id:, **query) ⇒ Object
- #customers(**query) ⇒ Object
-
#initialize(api_key: nil, environment: nil) ⇒ Client
constructor
A new instance of Client.
- #transactions(**query) ⇒ Object
Constructor Details
#initialize(api_key: nil, environment: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rotessa/client.rb', line 10 def initialize(api_key: nil, environment: nil) api_key ||= ENV["ROTESSA_API_KEY"] environment ||= ENV["ROTESSA_ENVIRONMENT"]&.to_sym || :production raise "Invalid environment: #{environment}. Only :production and :sandbox are accepted." unless [:production, :sandbox].include?(environment) raise "Invalid API key: #{api_key}. API key must be a string." unless api_key.to_s != "" @api_key = api_key @environment = environment set_base_uri end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/rotessa/client.rb', line 6 def api_key @api_key end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
6 7 8 |
# File 'lib/rotessa/client.rb', line 6 def environment @environment end |
Instance Method Details
#customer(id:, **query) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rotessa/client.rb', line 30 def customer(id:, **query) = .clone [:query].merge!(query) unless id.is_a?(Integer) || id.to_i.to_s == id.to_s [:query][:custom_identifier] = id id = "show_with_custom_identifier" end path = build_path("/customers", id) self.class.get(path, ) end |
#customers(**query) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/rotessa/client.rb', line 23 def customers(**query) = .clone [:query].merge!(query) get_all_pages("/customers", ) end |
#transactions(**query) ⇒ Object
44 45 46 47 48 |
# File 'lib/rotessa/client.rb', line 44 def transactions(**query) = .clone [:query].merge!(query) get_all_pages("/transaction_report", ) end |