Class: Simplify::Customer

Inherits:
Hash
  • Object
show all
Defined in:
lib/simplify/customer.rb

Overview

A Customer object.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#private_keyObject

Private key used to access the API.



40
41
42
# File 'lib/simplify/customer.rb', line 40

def private_key
  @private_key
end

#public_keyObject

Public key used to access the API.



37
38
39
# File 'lib/simplify/customer.rb', line 37

def public_key
  @public_key
end

Class Method Details

.create(parms, public_key = nil, private_key = nil) ⇒ Object

Creates an Customer object

parms

a hash of parameters; valid keys are:

  • card => addressCity City of the cardholder.

  • card => addressCountry Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder.

  • card => addressLine1 Address of the cardholder

  • card => addressLine2 Address of the cardholder if needed.

  • card => addressState State code (USPS code) of residence of the cardholder.

  • card => addressZip Postal code of the cardholder.

  • card => cvc CVC security code of the card. This is the code on the back of the card. Example: 123

  • card => expMonth Expiration month of the card. Format is MM. Example: January = 01 required

  • card => expYear Expiration year of the card. Format is YY. Example: 2013 = 13 required

  • card => name Name as appears on the card.

  • card => number Card number as it appears on the card. required

  • email Email address of the customer required

  • name Customer name required

  • reference Reference field for external applications use.

  • subscriptions => amount Amount of payment in minor units. Example: 1000 = 10.00

  • subscriptions => coupon Coupon associated with the subscription for the customer.

  • subscriptions => currency Currency code (ISO-4217). Must match the currency associated with your account. default:USD

  • subscriptions => customer The customer ID to create the subscription for. Do not supply this when creating a customer.

  • subscriptions => frequency Frequency of payment for the plan. Example: Monthly

  • subscriptions => name Name describing subscription

  • subscriptions => plan The plan ID that the subscription should be created from.

  • subscriptions => quantity Quantity of the plan for the subscription.

public_key

Public to use for the API call. If nil, the value of Simplify::public_key will be used.

private_key

Private key to use for the API call. If nil, the value of Simplify::private_key will be used.

Returns a Customer object.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/simplify/customer.rb', line 72

def self.create(parms, public_key = nil, private_key = nil)
    if public_key == nil then
        public_key = Simplify::public_key
    end
    if private_key == nil then
        private_key = Simplify::private_key
    end

    h = Simplify::PaymentsApi.execute("customer", 'create', parms, public_key, private_key)
    obj = Customer.new()
    obj.public_key = public_key
    obj.private_key = private_key
    obj = obj.merge(h)
    obj
end

.find(id, public_key = nil, private_key = nil) ⇒ Object

Retrieve a Customer object from the API

id

ID of object to retrieve

public_key

Public to use for the API call. If nil, the value of Simplify::public_key will be used.

private_key

Private key to use for the API call. If nil, the value of Simplify::private_key will be used.

Returns a Customer object.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/simplify/customer.rb', line 129

def self.find(id, public_key = nil, private_key = nil)
    if public_key == nil then
         public_key = Simplify::public_key
    end
    if private_key == nil then
        private_key = Simplify::private_key
    end

    h = Simplify::PaymentsApi.execute("customer", 'show', {"id" => id}, public_key, private_key)
    obj = Customer.new()
    obj.public_key = public_key
    obj.private_key = private_key
    obj = obj.merge(h)
    obj
end

.list(criteria = nil, public_key = nil, private_key = nil) ⇒ Object

Retrieve Customer objects.

criteria

a hash of parameters; valid keys are:

  • filter Filters to apply to the list.

  • max Allows up to a max of 50 list items to return. default:20

  • offset Used in paging of the list. This is the start offset of the page. default:0

  • sorting Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated id name email reference.

public_key

Public to use for the API call. If nil, the value of Simplify::public_key will be used.

private_key

Private key to use for the API call. If nil, the value of Simplify::private_key will be used.

Returns an object where the list property contains the list of Customer objects and the total property contains the total number of Customer objects available for the given criteria.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/simplify/customer.rb', line 105

def self.list(criteria = nil, public_key = nil, private_key = nil)

    if public_key == nil then
        public_key = Simplify::public_key
    end
    if private_key == nil then
       private_key = Simplify::private_key
    end

    h = Simplify::PaymentsApi.execute("customer", 'list', criteria, public_key, private_key)
    obj = Customer.new()
    obj.public_key = public_key
    obj.private_key = private_key
    obj = obj.merge(h)
    obj

end

Instance Method Details

#deleteObject

Delete this object



89
90
91
92
93
# File 'lib/simplify/customer.rb', line 89

def delete()
    h = Simplify::PaymentsApi.execute("customer", 'delete', self, self.public_key, self.private_key)
    self.merge!(h)
    self
end

#updateObject

  • card => addressCountry Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder.

  • card => addressLine1 Address of the cardholder.

  • card => addressLine2 Address of the cardholder if needed.

  • card => addressState State code (USPS code) of residence of the cardholder.

  • card => addressZip Postal code of the cardholder.

  • card => cvc CVC security code of the card. This is the code on the back of the card. Example: 123

  • card => expMonth Expiration month of the card. Format is MM. Example: January = 01 (required)

  • card => expYear Expiration year of the card. Format is YY. Example: 2013 = 13 (required)

  • card => name Name as appears on the card.

  • card => number Card number as it appears on the card. (required)

  • email Email address of the customer (required)

  • name Customer name (required)

  • reference Reference field for external applications use.



162
163
164
165
166
# File 'lib/simplify/customer.rb', line 162

def update()
      h = Simplify::PaymentsApi.execute("customer", 'update', self, self.public_key, self.private_key)
      self.merge!(h)
      self
end