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
293 294 295 296 297 298 299 300 301 |
# File 'lib/recharge/classes.rb', line 293 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
318 319 320 321 322 323 324 |
# File 'lib/recharge/classes.rb', line 318 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 |