Class: Bambora::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bambora/client.rb,
lib/bambora/client/version.rb

Overview

The Client class is used to initialize Resource objects that can make requests to the Bambora API.

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
'0.7.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Client

Initialze a new Bambora::Client.

Examples:


client = Bambora::Client.new do |c|
  c.base_url = ENV.fetch('BAMBORA_BASE_URL')
  c.scripts_api_base_url = ENV.fetch('BAMBORA_SCRIPTS_BASE_URL')
  c.merchant_id = ENV.fetch('BAMBORA_MERCHANT_ID')
  c.sub_merchant_id = ENV.fetch('BAMBORA_SUB_MERCHANT_ID')
end

Parameters:

  • options (base_url) (defaults to: {})
    String

    Bambora Base URL

  • options (merchant_id) (defaults to: {})
    String

    The Merchant ID for this request.

  • options (sub_merchant_id) (defaults to: {})
    String

    The Sub-Merchant ID for this request.

Yields:

  • (_self)

Yield Parameters:



71
72
73
74
75
76
77
# File 'lib/bambora/client.rb', line 71

def initialize(options = {})
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end

  yield(self) if block_given?
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



55
56
57
# File 'lib/bambora/client.rb', line 55

def base_url
  @base_url
end

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



55
56
57
# File 'lib/bambora/client.rb', line 55

def merchant_id
  @merchant_id
end

#scripts_api_base_urlObject (readonly)

Returns the value of attribute scripts_api_base_url.



55
56
57
# File 'lib/bambora/client.rb', line 55

def scripts_api_base_url
  @scripts_api_base_url
end

#sub_merchant_idObject (readonly)

Returns the value of attribute sub_merchant_id.



55
56
57
# File 'lib/bambora/client.rb', line 55

def sub_merchant_id
  @sub_merchant_id
end

Instance Method Details

#bank_profiles(api_key:) ⇒ Bambora::Bank::PaymentProfileResource

Retrieve a client to make requests to the Bank Payment Profiles endpoints.

Examples:

profiles = client.bank_profiles(api_key: <yourapikey>)

data = {
  customer_code: '1234',
  bank_account_type: 'CA',
  bank_account_holder: 'All-Maudra Mayrin',
  institution_number: '123',
  branch_number: '12345',
  account_number: '123456789',
  name: 'Brea Princess of Vapra',
  email_address: '[email protected]',
  phone_number: '1231231234',
  address_1: 'The Castle',
  city: "Ha'rar",
  postal_code: 'H0H 0H0',
  province: 'Vapra',
  country: 'Thra',
  sub_merchant_id: 1,
}

profiles.create(data)

Parameters:

  • api_key (String)

    API key for the bank profiles endpoint.

Returns:



145
146
147
# File 'lib/bambora/client.rb', line 145

def bank_profiles(api_key:)
  @bank_profiles ||= Bambora::Bank::PaymentProfileResource.new(client: www_form_client, api_key: api_key)
end

#batch_payments(api_key:) ⇒ Object



175
176
177
178
179
180
# File 'lib/bambora/client.rb', line 175

def batch_payments(api_key:)
  @batch_payments ||= Bambora::V1::BatchPaymentResource.new(
    client: batch_payment_file_upload_client,
    api_key: api_key,
  )
end

#batch_reports(api_key:) ⇒ Bambora::Bank::BatchReportResource

Retrieve a client to make requests to the batch report endpoint.

Examples:

batch_reports = client.batch_reports(api_key: <yourapikey>)

data = {
  rpt_filter_by_1: 'batch_id',
  rpt_filter_value_1: 1,
  rpt_operation_type_1: 'EQ',
  rpt_from_date_time: '2019-12-18 00:00:00',
  rpt_to_date_time: '2019-12-18 23:59:59',
  service_name: 'BatchPaymentsEFT',
}

batch_reports.show(data)

Parameters:

  • api_key (String)

    API key for the bank profiles endpoint.

Returns:



168
169
170
171
172
173
# File 'lib/bambora/client.rb', line 168

def batch_reports(api_key:)
  @batch_reports = Bambora::Bank::BatchReportResource.new(
    client: xml_client,
    api_key: api_key,
  )
end

#payments(api_key:) ⇒ Bambora::V1::PaymentResource

Retrieve a client to make requests to the Payments endpoints.

Examples:

payments = client.profiles(api_key: <yourapikey>)
payments.create(
  {
    amount: 50,
    payment_method: 'card',
    card: {
      name: 'Hup Podling',
      number: '4504481742333',
      expiry_month: '12',
      expiry_year: '20',
      cvd: '123',
    },
  },
)

Parameters:

  • api_key (String)

    API key for the payments endpoint.

Returns:



113
114
115
# File 'lib/bambora/client.rb', line 113

def payments(api_key:)
  @payments ||= Bambora::V1::PaymentResource.new(client: json_client, api_key: api_key)
end

#profiles(api_key:) ⇒ Bambora::V1::ProfileResource

Retrieve a client to make requests to the Profiles endpoints.

Examples:

profiles = client.profiles
profiles.delete(customer_code: '02355E2e58Bf488EAB4EaFAD7083dB6A')

Parameters:

  • api_key (String)

    API key for the profiles endpoint.

Returns:



88
89
90
# File 'lib/bambora/client.rb', line 88

def profiles(api_key:)
  @profiles ||= Bambora::V1::ProfileResource.new(client: json_client, api_key: api_key)
end