Class: Recharge::Customer
- Inherits:
-
Object
- Object
- Recharge::Customer
- 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
-
.addresses(id) ⇒ Object
Retrieve all of a customer’s addresses.
-
.create_address(id, address) ⇒ Object
Create a new address.
Methods included from HTTPRequest::Create
Methods included from HTTPRequest::Get
Methods included from HTTPRequest::Update
Methods included from HTTPRequest::List
Methods included from HTTPRequest::Count
Methods included from Persistable
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. = 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. = data["meta"] address end |