Class: MoneyMover::Dwolla::Customer

Inherits:
ApiResource show all
Defined in:
lib/money_mover/dwolla/models/customer.rb

Constant Summary collapse

COMPANY_TYPES =
%w( soleproprietorship llc partnership corporation )

Instance Attribute Summary collapse

Attributes inherited from ApiResource

#_embedded, #_links, #attrs, #id, #resource_location

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiResource

#destroy, fetch, #initialize

Constructor Details

This class inherits a constructor from MoneyMover::Dwolla::ApiResource

Instance Attribute Details

#address1Object

Returns the value of attribute address1.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def address1
  @address1
end

#address2Object

Returns the value of attribute address2.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def address2
  @address2
end

#businessClassificationObject

Returns the value of attribute businessClassification.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def businessClassification
  @businessClassification
end

#businessNameObject

Returns the value of attribute businessName.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def businessName
  @businessName
end

#businessTypeObject

Returns the value of attribute businessType.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def businessType
  @businessType
end

#cityObject

Returns the value of attribute city.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def city
  @city
end

#createdObject

Returns the value of attribute created.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def created
  @created
end

#dateOfBirthObject

Returns the value of attribute dateOfBirth.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def dateOfBirth
  @dateOfBirth
end

#doingBusinessAsObject

Returns the value of attribute doingBusinessAs.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def doingBusinessAs
  @doingBusinessAs
end

#einObject

Returns the value of attribute ein.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def ein
  @ein
end

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def email
  @email
end

#firstNameObject

Returns the value of attribute firstName.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def firstName
  @firstName
end

#ipAddressObject

Returns the value of attribute ipAddress.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def ipAddress
  @ipAddress
end

#lastNameObject

Returns the value of attribute lastName.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def lastName
  @lastName
end

#phoneObject

Returns the value of attribute phone.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def phone
  @phone
end

#postalCodeObject

Returns the value of attribute postalCode.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def postalCode
  @postalCode
end

#ssnObject

Returns the value of attribute ssn.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def ssn
  @ssn
end

#stateObject

Returns the value of attribute state.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def state
  @state
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def status
  @status
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def type
  @type
end

#websiteObject

Returns the value of attribute website.



6
7
8
# File 'lib/money_mover/dwolla/models/customer.rb', line 6

def website
  @website
end

Class Method Details

.find(id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/money_mover/dwolla/models/customer.rb', line 28

def self.find(id)
  client = ApplicationClient.new

  response = client.get fetch_endpoint(id)

  if response.success?
    new response.body
  else
    raise 'Customer Not Found'
    #puts "error: #{response.body}"
  end
end

Instance Method Details

#saveObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/money_mover/dwolla/models/customer.rb', line 41

def save
  return false unless valid?

  if @id
    response = @client.post self.class.fetch_endpoint(@id), create_params
    add_errors_from response unless response.success?
  else
    response = @client.post create_endpoint, create_params

    if response.success?
      @resource_location = response.resource_location
      @id = response.resource_id
    else
      add_errors_from response
    end
  end

  errors.empty?
end