Class: CloudpaymentsRuby::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- CloudpaymentsRuby::Client
- Defined in:
- lib/cloudpayments_ruby/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
- #api_secret ⇒ String readonly
- #orders ⇒ CloudpaymentsRuby::Resources::Orders readonly
- #payments ⇒ CloudpaymentsRuby::Resources::Payments readonly
- #public_id ⇒ String readonly
- #subscriptions ⇒ CloudpaymentsRuby::Resources::Subscriptions readonly
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(public_id: , api_secret: , base_url: , max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(public_id: , api_secret: , base_url: , max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/cloudpayments_ruby/client.rb', line 59 def initialize( public_id: ENV["CLOUDPAYMENTS_PUBLIC_ID"], api_secret: ENV["CLOUDPAYMENTS_API_SECRET"], base_url: ENV["CLOUDPAYMENTS_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://api.cloudpayments.ru" if public_id.nil? raise ArgumentError.new("public_id is required, and can be set via environ: \"CLOUDPAYMENTS_PUBLIC_ID\"") end if api_secret.nil? raise ArgumentError.new("api_secret is required, and can be set via environ: \"CLOUDPAYMENTS_API_SECRET\"") end @public_id = public_id.to_s @api_secret = api_secret.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay ) @payments = CloudpaymentsRuby::Resources::Payments.new(client: self) @subscriptions = CloudpaymentsRuby::Resources::Subscriptions.new(client: self) @orders = CloudpaymentsRuby::Resources::Orders.new(client: self) end |
Instance Attribute Details
#api_secret ⇒ String (readonly)
22 23 24 |
# File 'lib/cloudpayments_ruby/client.rb', line 22 def api_secret @api_secret end |
#orders ⇒ CloudpaymentsRuby::Resources::Orders (readonly)
31 32 33 |
# File 'lib/cloudpayments_ruby/client.rb', line 31 def orders @orders end |
#payments ⇒ CloudpaymentsRuby::Resources::Payments (readonly)
25 26 27 |
# File 'lib/cloudpayments_ruby/client.rb', line 25 def payments @payments end |
#public_id ⇒ String (readonly)
19 20 21 |
# File 'lib/cloudpayments_ruby/client.rb', line 19 def public_id @public_id end |
#subscriptions ⇒ CloudpaymentsRuby::Resources::Subscriptions (readonly)
28 29 30 |
# File 'lib/cloudpayments_ruby/client.rb', line 28 def subscriptions @subscriptions end |