Class: Bambora::V1::ProfileResource

Inherits:
Object
  • Object
show all
Defined in:
lib/bambora/v1/profile_resource.rb

Overview

For making requests to the /profiles endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, api_key:) ⇒ ProfileResource

Instantiate an interface to make requests against Bambora’s Profiles API.

Examples:


client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
profiles = Bambora::V1::ProfileResource(client: client)

# Start making requests ...

Parameters:



21
22
23
24
25
# File 'lib/bambora/v1/profile_resource.rb', line 21

def initialize(client:, api_key:)
  @client = client
  @api_key = api_key
  @sub_path = '/v1/profiles'
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/bambora/v1/profile_resource.rb', line 8

def api_key
  @api_key
end

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/bambora/v1/profile_resource.rb', line 8

def client
  @client
end

#sub_pathObject (readonly)

Returns the value of attribute sub_path.



8
9
10
# File 'lib/bambora/v1/profile_resource.rb', line 8

def sub_path
  @sub_path
end

Instance Method Details

#create(payment_profile_data) ⇒ Hash

Create a Bambora payment profile.

Examples:


client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
profiles = Bambora::V1::ProfileResource(client: client)
data = {
 language: 'en',
  card: {
    name: 'Hup Podling',
    number: '4030000010001234',
    expiry_month: '12',
    expiry_year: '23',
    cvd: '123',
  },
}

profiles.create(data)
# => {
#      :code => 1,
#      :message => "Operation Successful",
#      :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
#    }

Parameters:

  • card_data (Hash)

    All information relevant to making a payment.

Returns:

  • (Hash)

    Indicating success or failure of the operation.

See Also:



57
58
59
# File 'lib/bambora/v1/profile_resource.rb', line 57

def create(payment_profile_data)
  client.post(path: sub_path, body: payment_profile_data, api_key: api_key)
end

#delete(customer_code:) ⇒ Hash

Delete a Bambora payment profile given a customer code.

Examples:


client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
profiles = Bambora::V1::ProfileResource(client: client)
customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'

profiles.delete(customer_code: customer_code)
# => {
#      :code => 1,
#      :message => "Operation Successful",
#      :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
#    }

Parameters:

  • customer_code (String)

    A unique identifier for the associated payment profile.

Returns:

  • (Hash)

    Indicating success or failure of the operation.



166
167
168
# File 'lib/bambora/v1/profile_resource.rb', line 166

def delete(customer_code:)
  client.delete(path: "#{@sub_path}/#{customer_code}", api_key: api_key)
end

#get(customer_code:) ⇒ Hash

Get a Bambora payment profile given a customer code.

Examples:


client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
profiles = Bambora::V1::ProfileResource(client: client)
customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'

profiles.get(customer_code: customer_code)
# => {
#      :code => 1,
#      :message => "Operation Successful",
#      :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
#      :status => "A",
#      :last_transaction => "1900-01-01T00:00:00",
#      :modified_date => "1900-01-01T00:00:00",
#      :card => { :name => "", :number => "", :card_type => "" },
#      :language => "en",
#      :velocity_group => "",
#      :profile_group => "",
#      :account_ref => "",
#      :billing =>
#        {
#          :name => "Harry Lewis",
#          :address_line1 => "",
#          :address_line2 => "",
#          :city => "",
#          :province => "",
#          :country => "",
#          :postal_code => "",
#          :phone_number => "",
#          :email_address => ""},
#      :custom => { :ref1 => "", :ref2 => "", :ref3 => "", :ref4 => "", :ref5 => "" }}

Parameters:

  • customer_code (String)

    A unique identifier for the associated payment profile.

Returns:

  • (Hash)

    Payment profile details.



99
100
101
# File 'lib/bambora/v1/profile_resource.rb', line 99

def get(customer_code:)
  client.get(path: "#{sub_path}/#{customer_code}", api_key: api_key)
end

#update(customer_code:, payment_profile_data:) ⇒ Hash

Make a PUT Request.

Examples:


client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
profiles = Bambora::V1::ProfileResource(client: client)
customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'

data = {
  billing: {
     name: "joh doe",
     address_line1: "123 main st",
     address_line2: "111",
     city: "victoria",
     province: "bc",
     country: "ca",
     postal_code: "V8T4M3",
     phone_number: "25012312345",
     email_address: "[email protected]"
  },
  card: {
    name: 'Hup Podling',
    number: '4030000010001234',
    expiry_month: '12',
    expiry_year: '23',
    cvd: '123',
  },
}

profiles.update(customer_code: customer_code, payment_profile_data: data)
# => {
#      :code => 1,
#      :message => "Operation Successful",
#      :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
#    }

Parameters:

  • customer_code (String)

    A unique identifier for the associated payment profile.

  • data (Hash)

    Payment profile data to be sent in the body of the request.

Returns:

  • (Hash)

    Indicating success or failure of the operation.



143
144
145
# File 'lib/bambora/v1/profile_resource.rb', line 143

def update(customer_code:, payment_profile_data:)
  client.put(path: "#{@sub_path}/#{customer_code}", body: payment_profile_data, api_key: api_key)
end