Class: Recharge::Customer

Inherits:
Object
  • Object
show all
Extended by:
HTTPRequest::Count, HTTPRequest::Create, HTTPRequest::Get, HTTPRequest::List, HTTPRequest::Update
Includes:
Persistable
Defined in:
lib/recharge/classes.rb

Constant Summary collapse

PATH =
"/customers".freeze
SINGLE =
"customer".freeze
COLLECTION =
"customers".freeze

Class Method Summary collapse

Methods included from HTTPRequest::Create

create

Methods included from HTTPRequest::Get

get

Methods included from HTTPRequest::Update

update

Methods included from HTTPRequest::List

list

Methods included from HTTPRequest::Count

count

Methods included from Persistable

#save

Class Method Details

.addresses(id) ⇒ Object

Retrieve all of a customer’s addresses

Arguments

id (Fixnum)

Customer ID

Errors

ConnectionError, RequestError

Returns

Array

The customer’s addresses



385
386
387
388
389
390
391
392
393
# File 'lib/recharge/classes.rb', line 385

def self.addresses(id)
  id_required!(id)
  data = GET(join(id, Address::COLLECTION))
  (data[Address::COLLECTION] || []).map do |d|
    address = Address.new(d)
    address.meta = data["meta"]
    address
  end
end

.create_address(id, address) ⇒ Object

Create a new address

Arguments

id (Fixnum)

Customer ID

address (Hash)

Address attributes, see: developer.rechargepayments.com/?shell#create-address

Returns

Recharge::Address

The created address

Errors

Recharge::ConnectionError, Recharge::RequestError



410
411
412
413
414
415
416
# File 'lib/recharge/classes.rb', line 410

def self.create_address(id, address)
  id_required!(id)
  data = POST(join(id, Address::COLLECTION), address)
  address = Address.new(data[Address::SINGLE])
  address.meta = data["meta"]
  address
end