Class: Files::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ Account

Returns a new instance of Account.



7
8
9
10
# File 'lib/files.com/models/account.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/account.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/account.rb', line 5

def options
  @options
end

Class Method Details

.create(params = {}, options = {}) ⇒ Object

Parameters:

name - string - Internal name.
company_name - string - Company name.
address - string - Address line 1.
address_2 - string - Address line 2.
city - string - City.
state - string - State.
zip - string - Zipcode.
country - string - Country.
email - string - Email.
phone_number - string - Primary phone number.
card_number - string - Credit card number.
card_type - string - Credit card type.  Can be visa, master, maestro, solo, switch, american_express, or discover.
expiration_year - string - Expiration year(4 digits).
expiration_month - string - Expiration month(2 digits).
start_year - string - Required for some cards(Switch / Solo).
start_month - string - Required for some cards(Switch / Solo).
cvv - string - 3 digit code on the back of the card.
paypal_token - string - Token for paying with paypal.
paypal_payer_id - string - Paypal payer ID for paying with paypal.
plan_id - int64 - Plan ID to switch to immediately.
billing_frequency - int64 - The billing frequency, in months, for the site.  Must be 1 (monthly) or 12 (annual).
currency - string - Preferred currency for this account.
create_account - boolean - Create account without immediately charging the customer.  (i.e. let the trial complete first.)


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/files.com/models/account.rb', line 273

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: company_name must be an String") if params[:company_name] and !params[:company_name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: address must be an String") if params[:address] and !params[:address].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: address_2 must be an String") if params[:address_2] and !params[:address_2].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: city must be an String") if params[:city] and !params[:city].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: state must be an String") if params[:state] and !params[:state].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: zip must be an String") if params[:zip] and !params[:zip].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: country must be an String") if params[:country] and !params[:country].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: email must be an String") if params[:email] and !params[:email].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: phone_number must be an String") if params[:phone_number] and !params[:phone_number].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: card_number must be an String") if params[:card_number] and !params[:card_number].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: card_type must be an String") if params[:card_type] and !params[:card_type].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expiration_year must be an String") if params[:expiration_year] and !params[:expiration_year].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expiration_month must be an String") if params[:expiration_month] and !params[:expiration_month].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: start_year must be an String") if params[:start_year] and !params[:start_year].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: start_month must be an String") if params[:start_month] and !params[:start_month].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: cvv must be an String") if params[:cvv] and !params[:cvv].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: paypal_token must be an String") if params[:paypal_token] and !params[:paypal_token].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: paypal_payer_id must be an String") if params[:paypal_payer_id] and !params[:paypal_payer_id].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: plan_id must be an Integer") if params[:plan_id] and !params[:plan_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: billing_frequency must be an Integer") if params[:billing_frequency] and !params[:billing_frequency].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: currency must be an String") if params[:currency] and !params[:currency].is_a?(String)

  response, options = Api.send_request("/account", :post, params, options)
  Account.new(response.data, options)
end

.get(params = {}, options = {}) ⇒ Object



244
245
246
247
# File 'lib/files.com/models/account.rb', line 244

def self.get(params = {}, options = {})
  response, options = Api.send_request("/account", :get, params, options)
  Account.new(response.data, options)
end

.update(params = {}, options = {}) ⇒ Object

Parameters:

name - string - Internal name.
company_name - string - Company name.
address - string - Address line 1.
address_2 - string - Address line 2.
city - string - City.
state - string - State.
zip - string - Zipcode.
country - string - Country.
email - string - Email.
phone_number - string - Primary phone number.
card_number - string - Credit card number.
card_type - string - Credit card type.  Can be visa, master, maestro, solo, switch, american_express, or discover.
expiration_year - string - Expiration year(4 digits).
expiration_month - string - Expiration month(2 digits).
start_year - string - Required for some cards(Switch / Solo).
start_month - string - Required for some cards(Switch / Solo).
cvv - string - 3 digit code on the back of the card.
paypal_token - string - Token for paying with paypal.
paypal_payer_id - string - Paypal payer ID for paying with paypal.


321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/files.com/models/account.rb', line 321

def self.update(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: company_name must be an String") if params[:company_name] and !params[:company_name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: address must be an String") if params[:address] and !params[:address].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: address_2 must be an String") if params[:address_2] and !params[:address_2].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: city must be an String") if params[:city] and !params[:city].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: state must be an String") if params[:state] and !params[:state].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: zip must be an String") if params[:zip] and !params[:zip].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: country must be an String") if params[:country] and !params[:country].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: email must be an String") if params[:email] and !params[:email].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: phone_number must be an String") if params[:phone_number] and !params[:phone_number].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: card_number must be an String") if params[:card_number] and !params[:card_number].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: card_type must be an String") if params[:card_type] and !params[:card_type].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expiration_year must be an String") if params[:expiration_year] and !params[:expiration_year].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expiration_month must be an String") if params[:expiration_month] and !params[:expiration_month].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: start_year must be an String") if params[:start_year] and !params[:start_year].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: start_month must be an String") if params[:start_month] and !params[:start_month].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: cvv must be an String") if params[:cvv] and !params[:cvv].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: paypal_token must be an String") if params[:paypal_token] and !params[:paypal_token].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: paypal_payer_id must be an String") if params[:paypal_payer_id] and !params[:paypal_payer_id].is_a?(String)

  response, options = Api.send_request("/account", :patch, params, options)
  Account.new(response.data, options)
end

Instance Method Details

#addressObject

string - Account address



22
23
24
# File 'lib/files.com/models/account.rb', line 22

def address
  @attributes[:address]
end

#address=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/account.rb', line 26

def address=(value)
  @attributes[:address] = value
end

#address_2Object

string - Account address 2



31
32
33
# File 'lib/files.com/models/account.rb', line 31

def address_2
  @attributes[:address_2]
end

#address_2=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/account.rb', line 35

def address_2=(value)
  @attributes[:address_2] = value
end

#billing_frequencyObject

int64 - Number of usage periods billed at once. This value will either be 12 representing an annual account of 12 usage periods or 1 representing a monthly account.



144
145
146
# File 'lib/files.com/models/account.rb', line 144

def billing_frequency
  @attributes[:billing_frequency]
end

#billing_frequency=(value) ⇒ Object



148
149
150
# File 'lib/files.com/models/account.rb', line 148

def billing_frequency=(value)
  @attributes[:billing_frequency] = value
end

#card_numberObject

string - Account payment card number



40
41
42
# File 'lib/files.com/models/account.rb', line 40

def card_number
  @attributes[:card_number]
end

#card_number=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/account.rb', line 44

def card_number=(value)
  @attributes[:card_number] = value
end

#card_typeObject

string - Account payment card type



49
50
51
# File 'lib/files.com/models/account.rb', line 49

def card_type
  @attributes[:card_type]
end

#card_type=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/account.rb', line 53

def card_type=(value)
  @attributes[:card_type] = value
end

#cityObject

string - Account city



58
59
60
# File 'lib/files.com/models/account.rb', line 58

def city
  @attributes[:city]
end

#city=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/account.rb', line 62

def city=(value)
  @attributes[:city] = value
end

#company_nameObject

string - Account company name



67
68
69
# File 'lib/files.com/models/account.rb', line 67

def company_name
  @attributes[:company_name]
end

#company_name=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/account.rb', line 71

def company_name=(value)
  @attributes[:company_name] = value
end

#countryObject

string - Account country



76
77
78
# File 'lib/files.com/models/account.rb', line 76

def country
  @attributes[:country]
end

#country=(value) ⇒ Object



80
81
82
# File 'lib/files.com/models/account.rb', line 80

def country=(value)
  @attributes[:country] = value
end

#create_accountObject

boolean - Create account without immediately charging the customer. (i.e. let the trial complete first.)



225
226
227
# File 'lib/files.com/models/account.rb', line 225

def 
  @attributes[:create_account]
end

#create_account=(value) ⇒ Object



229
230
231
# File 'lib/files.com/models/account.rb', line 229

def create_account=(value)
  @attributes[:create_account] = value
end

#created_atObject

date-time - Account creation date/time



85
86
87
# File 'lib/files.com/models/account.rb', line 85

def created_at
  @attributes[:created_at]
end

#currencyObject

string - Account preferred currency



90
91
92
# File 'lib/files.com/models/account.rb', line 90

def currency
  @attributes[:currency]
end

#currency=(value) ⇒ Object



94
95
96
# File 'lib/files.com/models/account.rb', line 94

def currency=(value)
  @attributes[:currency] = value
end

#cvvObject

string - 3 digit code on the back of the card.



189
190
191
# File 'lib/files.com/models/account.rb', line 189

def cvv
  @attributes[:cvv]
end

#cvv=(value) ⇒ Object



193
194
195
# File 'lib/files.com/models/account.rb', line 193

def cvv=(value)
  @attributes[:cvv] = value
end

#emailObject

email - Account email address



99
100
101
# File 'lib/files.com/models/account.rb', line 99

def email
  @attributes[:email]
end

#email=(value) ⇒ Object



103
104
105
# File 'lib/files.com/models/account.rb', line 103

def email=(value)
  @attributes[:email] = value
end

#expiration_monthObject

string - Expiration month(2 digits).



162
163
164
# File 'lib/files.com/models/account.rb', line 162

def expiration_month
  @attributes[:expiration_month]
end

#expiration_month=(value) ⇒ Object



166
167
168
# File 'lib/files.com/models/account.rb', line 166

def expiration_month=(value)
  @attributes[:expiration_month] = value
end

#expiration_yearObject

string - Expiration year(4 digits).



153
154
155
# File 'lib/files.com/models/account.rb', line 153

def expiration_year
  @attributes[:expiration_year]
end

#expiration_year=(value) ⇒ Object



157
158
159
# File 'lib/files.com/models/account.rb', line 157

def expiration_year=(value)
  @attributes[:expiration_year] = value
end

#nameObject

string - Account name



13
14
15
# File 'lib/files.com/models/account.rb', line 13

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/account.rb', line 17

def name=(value)
  @attributes[:name] = value
end

#paypal_payer_idObject

string - Paypal payer ID for paying with paypal.



207
208
209
# File 'lib/files.com/models/account.rb', line 207

def paypal_payer_id
  @attributes[:paypal_payer_id]
end

#paypal_payer_id=(value) ⇒ Object



211
212
213
# File 'lib/files.com/models/account.rb', line 211

def paypal_payer_id=(value)
  @attributes[:paypal_payer_id] = value
end

#paypal_tokenObject

string - Token for paying with paypal.



198
199
200
# File 'lib/files.com/models/account.rb', line 198

def paypal_token
  @attributes[:paypal_token]
end

#paypal_token=(value) ⇒ Object



202
203
204
# File 'lib/files.com/models/account.rb', line 202

def paypal_token=(value)
  @attributes[:paypal_token] = value
end

#phone_numberObject

string - Account phone number



108
109
110
# File 'lib/files.com/models/account.rb', line 108

def phone_number
  @attributes[:phone_number]
end

#phone_number=(value) ⇒ Object



112
113
114
# File 'lib/files.com/models/account.rb', line 112

def phone_number=(value)
  @attributes[:phone_number] = value
end

#plan_idObject

int64 - Plan ID to switch to immediately.



216
217
218
# File 'lib/files.com/models/account.rb', line 216

def plan_id
  @attributes[:plan_id]
end

#plan_id=(value) ⇒ Object



220
221
222
# File 'lib/files.com/models/account.rb', line 220

def plan_id=(value)
  @attributes[:plan_id] = value
end

#processor_typeObject

string - Type of billing processor. Can be PayPal, Credit Card, or Manual



117
118
119
# File 'lib/files.com/models/account.rb', line 117

def processor_type
  @attributes[:processor_type]
end

#processor_type=(value) ⇒ Object



121
122
123
# File 'lib/files.com/models/account.rb', line 121

def processor_type=(value)
  @attributes[:processor_type] = value
end

#saveObject



233
234
235
236
237
238
239
240
241
242
# File 'lib/files.com/models/account.rb', line 233

def save
  if @attributes[:id]
    raise NotImplementedError.new("The Account object doesn't support updates.")
  else
    new_obj = Account.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#start_monthObject

string - Required for some cards(Switch / Solo).



180
181
182
# File 'lib/files.com/models/account.rb', line 180

def start_month
  @attributes[:start_month]
end

#start_month=(value) ⇒ Object



184
185
186
# File 'lib/files.com/models/account.rb', line 184

def start_month=(value)
  @attributes[:start_month] = value
end

#start_yearObject

string - Required for some cards(Switch / Solo).



171
172
173
# File 'lib/files.com/models/account.rb', line 171

def start_year
  @attributes[:start_year]
end

#start_year=(value) ⇒ Object



175
176
177
# File 'lib/files.com/models/account.rb', line 175

def start_year=(value)
  @attributes[:start_year] = value
end

#stateObject

string - Account state



126
127
128
# File 'lib/files.com/models/account.rb', line 126

def state
  @attributes[:state]
end

#state=(value) ⇒ Object



130
131
132
# File 'lib/files.com/models/account.rb', line 130

def state=(value)
  @attributes[:state] = value
end

#zipObject

string - Account zipcode



135
136
137
# File 'lib/files.com/models/account.rb', line 135

def zip
  @attributes[:zip]
end

#zip=(value) ⇒ Object



139
140
141
# File 'lib/files.com/models/account.rb', line 139

def zip=(value)
  @attributes[:zip] = value
end