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

.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.


117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/files.com/models/account.rb', line 117

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



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

def address
  @attributes[:address]
end

#address_2Object

string - Account address 2



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

def address_2
  @attributes[:address_2]
end

#billing_frequencyObject

int64 - Account billing frequency. Either 12(yearly) or 1(monthly)



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

def billing_frequency
  @attributes[:billing_frequency]
end

#card_numberObject

string - Account payment card number



28
29
30
# File 'lib/files.com/models/account.rb', line 28

def card_number
  @attributes[:card_number]
end

#card_typeObject

string - Account payment card type



33
34
35
# File 'lib/files.com/models/account.rb', line 33

def card_type
  @attributes[:card_type]
end

#cityObject

string - Account city



38
39
40
# File 'lib/files.com/models/account.rb', line 38

def city
  @attributes[:city]
end

#company_nameObject

string - Account company name



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

def company_name
  @attributes[:company_name]
end

#countryObject

string - Account country



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

def country
  @attributes[:country]
end

#created_atObject

date-time - Account creation date/time



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

def created_at
  @attributes[:created_at]
end

#currencyObject

string - Account preferred currency



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

def currency
  @attributes[:currency]
end

#emailObject

email - Account email address



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

def email
  @attributes[:email]
end

#nameObject

string - Account name



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

def name
  @attributes[:name]
end

#phone_numberObject

string - Account phone number



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

def phone_number
  @attributes[:phone_number]
end

#processor_typeObject

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



73
74
75
# File 'lib/files.com/models/account.rb', line 73

def processor_type
  @attributes[:processor_type]
end

#stateObject

string - Account state



78
79
80
# File 'lib/files.com/models/account.rb', line 78

def state
  @attributes[:state]
end

#updated_atObject

date-time - Account last updated at



83
84
85
# File 'lib/files.com/models/account.rb', line 83

def updated_at
  @attributes[:updated_at]
end

#zipObject

string - Account zipcode



88
89
90
# File 'lib/files.com/models/account.rb', line 88

def zip
  @attributes[:zip]
end