Class: GoCardless::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gocardless-pro.rb

Overview

A class for working with and talking to the GoCardless API

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Get a Client configured to use HTTP Basic authentication with the GC Api

Parameters:

  • options (Hash<Symbol,String>)

    configuration for creating the client

Options Hash (options):

  • :environment (Symbol)

    the environment to connect to - one of :live or :sandbox.

  • :api_key (Symbol)

    the ID of the API Key

  • :api_secret (Symbol)

    the key of the API Key

  • :url (Symbol)

    the full URL used to make requests to. If you specify this, it will be used over the environment option.



182
183
184
185
186
187
188
189
# File 'lib/gocardless-pro.rb', line 182

def initialize(options)
  api_key = options.delete(:api_key) || fail('No API key ID given to GoCardless Client')
  api_secret = options.delete(:api_secret) || fail('No API secret given to GoCardless Client')
  environment = options.delete(:environment) || :live
  url = options.delete(:url) || url_for_environment(environment)
  options = custom_options(options)
  @api_service = ApiService.new(url, api_key, api_secret, options)
end

Instance Method Details

#api_keysObject

Access to the service for api_key to make API calls



93
94
95
# File 'lib/gocardless-pro.rb', line 93

def api_keys
  @api_keys ||= Services::ApiKeyService.new(@api_service)
end

#creditor_bank_accountsObject

Access to the service for creditor_bank_account to make API calls



103
104
105
# File 'lib/gocardless-pro.rb', line 103

def creditor_bank_accounts
  @creditor_bank_accounts ||= Services::CreditorBankAccountService.new(@api_service)
end

#creditorsObject

Access to the service for creditor to make API calls



98
99
100
# File 'lib/gocardless-pro.rb', line 98

def creditors
  @creditors ||= Services::CreditorService.new(@api_service)
end

#customer_bank_accountsObject

Access to the service for customer_bank_account to make API calls



113
114
115
# File 'lib/gocardless-pro.rb', line 113

def customer_bank_accounts
  @customer_bank_accounts ||= Services::CustomerBankAccountService.new(@api_service)
end

#customersObject

Access to the service for customer to make API calls



108
109
110
# File 'lib/gocardless-pro.rb', line 108

def customers
  @customers ||= Services::CustomerService.new(@api_service)
end

#eventsObject

Access to the service for event to make API calls



118
119
120
# File 'lib/gocardless-pro.rb', line 118

def events
  @events ||= Services::EventService.new(@api_service)
end

#helpersObject

Access to the service for helper to make API calls



123
124
125
# File 'lib/gocardless-pro.rb', line 123

def helpers
  @helpers ||= Services::HelperService.new(@api_service)
end

#mandatesObject

Access to the service for mandate to make API calls



128
129
130
# File 'lib/gocardless-pro.rb', line 128

def mandates
  @mandates ||= Services::MandateService.new(@api_service)
end

#paymentsObject

Access to the service for payment to make API calls



133
134
135
# File 'lib/gocardless-pro.rb', line 133

def payments
  @payments ||= Services::PaymentService.new(@api_service)
end

#payoutsObject

Access to the service for payout to make API calls



138
139
140
# File 'lib/gocardless-pro.rb', line 138

def payouts
  @payouts ||= Services::PayoutService.new(@api_service)
end

#publishable_api_keysObject

Access to the service for publishable_api_key to make API calls



143
144
145
# File 'lib/gocardless-pro.rb', line 143

def publishable_api_keys
  @publishable_api_keys ||= Services::PublishableApiKeyService.new(@api_service)
end

#redirect_flowsObject

Access to the service for redirect_flow to make API calls



148
149
150
# File 'lib/gocardless-pro.rb', line 148

def redirect_flows
  @redirect_flows ||= Services::RedirectFlowService.new(@api_service)
end

#refundsObject

Access to the service for refund to make API calls



153
154
155
# File 'lib/gocardless-pro.rb', line 153

def refunds
  @refunds ||= Services::RefundService.new(@api_service)
end

#rolesObject

Access to the service for role to make API calls



158
159
160
# File 'lib/gocardless-pro.rb', line 158

def roles
  @roles ||= Services::RoleService.new(@api_service)
end

#subscriptionsObject

Access to the service for subscription to make API calls



163
164
165
# File 'lib/gocardless-pro.rb', line 163

def subscriptions
  @subscriptions ||= Services::SubscriptionService.new(@api_service)
end

#usersObject

Access to the service for user to make API calls



168
169
170
# File 'lib/gocardless-pro.rb', line 168

def users
  @users ||= Services::UserService.new(@api_service)
end