Class: MaliPoPay::Client
- Inherits:
-
Object
- Object
- MaliPoPay::Client
- Defined in:
- lib/malipopay/client.rb
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#webhook_secret ⇒ Object
readonly
Returns the value of attribute webhook_secret.
Instance Method Summary collapse
- #account ⇒ MaliPoPay::Resources::Account
- #customers ⇒ MaliPoPay::Resources::Customers
-
#initialize(api_key:, environment: :production, base_url: nil, timeout: 30, retries: 2, webhook_secret: nil) ⇒ Client
constructor
Initialize a new MaliPoPay client.
- #invoices ⇒ MaliPoPay::Resources::Invoices
- #payments ⇒ MaliPoPay::Resources::Payments
- #products ⇒ MaliPoPay::Resources::Products
- #references ⇒ MaliPoPay::Resources::References
- #sms ⇒ MaliPoPay::Resources::Sms
- #transactions ⇒ MaliPoPay::Resources::Transactions
- #webhooks ⇒ MaliPoPay::Webhooks::Verifier
Constructor Details
#initialize(api_key:, environment: :production, base_url: nil, timeout: 30, retries: 2, webhook_secret: nil) ⇒ Client
Initialize a new MaliPoPay client
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/malipopay/client.rb', line 15 def initialize(api_key:, environment: :production, base_url: nil, timeout: 30, retries: 2, webhook_secret: nil) raise ArgumentError, "api_key is required" if api_key.nil? || api_key.empty? @http_client = HttpClient.new( api_key: api_key, environment: environment, base_url: base_url, timeout: timeout, retries: retries ) @webhook_secret = webhook_secret end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
5 6 7 |
# File 'lib/malipopay/client.rb', line 5 def http_client @http_client end |
#webhook_secret ⇒ Object (readonly)
Returns the value of attribute webhook_secret.
5 6 7 |
# File 'lib/malipopay/client.rb', line 5 def webhook_secret @webhook_secret end |
Instance Method Details
#account ⇒ MaliPoPay::Resources::Account
54 55 56 |
# File 'lib/malipopay/client.rb', line 54 def account @account ||= Resources::Account.new(@http_client) end |
#customers ⇒ MaliPoPay::Resources::Customers
34 35 36 |
# File 'lib/malipopay/client.rb', line 34 def customers @customers ||= Resources::Customers.new(@http_client) end |
#invoices ⇒ MaliPoPay::Resources::Invoices
39 40 41 |
# File 'lib/malipopay/client.rb', line 39 def invoices @invoices ||= Resources::Invoices.new(@http_client) end |
#payments ⇒ MaliPoPay::Resources::Payments
29 30 31 |
# File 'lib/malipopay/client.rb', line 29 def payments @payments ||= Resources::Payments.new(@http_client) end |
#products ⇒ MaliPoPay::Resources::Products
44 45 46 |
# File 'lib/malipopay/client.rb', line 44 def products @products ||= Resources::Products.new(@http_client) end |
#references ⇒ MaliPoPay::Resources::References
64 65 66 |
# File 'lib/malipopay/client.rb', line 64 def references @references ||= Resources::References.new(@http_client) end |
#sms ⇒ MaliPoPay::Resources::Sms
59 60 61 |
# File 'lib/malipopay/client.rb', line 59 def sms @sms ||= Resources::Sms.new(@http_client) end |
#transactions ⇒ MaliPoPay::Resources::Transactions
49 50 51 |
# File 'lib/malipopay/client.rb', line 49 def transactions @transactions ||= Resources::Transactions.new(@http_client) end |
#webhooks ⇒ MaliPoPay::Webhooks::Verifier
70 71 72 73 74 |
# File 'lib/malipopay/client.rb', line 70 def webhooks raise ArgumentError, "webhook_secret is required for webhook verification" unless @webhook_secret @webhooks ||= Webhooks::Verifier.new(@webhook_secret) end |