Class: Clearbooks::Entity

Inherits:
Base
  • Object
show all
Defined in:
lib/clearbooks/model/entity.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

build, create

Constructor Details

#initialize(data) ⇒ Entity

Returns a new instance of Entity.

Parameters:



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/clearbooks/model/entity.rb', line 151

def initialize data
  @id               = Integer data.savon(:id) rescue nil
  @company_name     = data.savon :company_name
  @contact_name     = data.savon :contact_name

  @building         = data.savon :building
  @address1         = data.savon :address1
  @address2         = data.savon :address2
  @town             = data.savon :town
  @county           = data.savon :county
  @country          = data.savon :country
  @postcode         = data.savon :postcode

  @email            = data.savon :email
  @phone1           = data.savon :phone1
  @phone2           = data.savon :phone2
  @fax              = data.savon :fax
  @website          = data.savon :website

  @company_number   = data.savon :company_number
  @vat_number       = data.savon :vat_number
  @statement_url    = data.savon :statement_url
  @external_id      = data.savon :external_id

  @supplier = entity_extra data.savon :supplier
  @supplier = @supplier.from_savon if @supplier

  @customer = entity_extra data.savon :customer
  @customer = @customer.from_savon if @customer

end

Instance Attribute Details

#address1String (readonly)

Optional.



65
66
67
# File 'lib/clearbooks/model/entity.rb', line 65

def address1
  @address1
end

#address2String (readonly)

Optional.



70
71
72
# File 'lib/clearbooks/model/entity.rb', line 70

def address2
  @address2
end

#buildingString (readonly)

Optional.



60
61
62
# File 'lib/clearbooks/model/entity.rb', line 60

def building
  @building
end

#company_nameString (readonly)

Optional.



50
51
52
# File 'lib/clearbooks/model/entity.rb', line 50

def company_name
  @company_name
end

#company_numberFixnum (readonly)

Optional.



130
131
132
# File 'lib/clearbooks/model/entity.rb', line 130

def company_number
  @company_number
end

#contact_nameString (readonly)

Optional.



55
56
57
# File 'lib/clearbooks/model/entity.rb', line 55

def contact_name
  @contact_name
end

#countryString (readonly)

Optional. Country code.



85
86
87
# File 'lib/clearbooks/model/entity.rb', line 85

def country
  @country
end

#countyString (readonly)

Optional.



80
81
82
# File 'lib/clearbooks/model/entity.rb', line 80

def county
  @county
end

#customerHash (readonly)

Optional. [:default_account_code, :default_vat_rate, :default_credit_terms]



140
141
142
# File 'lib/clearbooks/model/entity.rb', line 140

def customer
  @customer
end

#emailString (readonly)

Optional.



95
96
97
# File 'lib/clearbooks/model/entity.rb', line 95

def email
  @email
end

#external_idFixnum (readonly)

Optional.



120
121
122
# File 'lib/clearbooks/model/entity.rb', line 120

def external_id
  @external_id
end

#faxString (readonly)

Optional.



110
111
112
# File 'lib/clearbooks/model/entity.rb', line 110

def fax
  @fax
end

#idFixnum (readonly)

Returns Entity Id.

Returns:

  • (Fixnum)

    Entity Id.

See Also:



42
43
44
# File 'lib/clearbooks/model/entity.rb', line 42

def id
  @id
end

#phone1String (readonly)

Optional.



100
101
102
# File 'lib/clearbooks/model/entity.rb', line 100

def phone1
  @phone1
end

#phone2String (readonly)

Optional.



105
106
107
# File 'lib/clearbooks/model/entity.rb', line 105

def phone2
  @phone2
end

#postcodeString (readonly)

Optional.



90
91
92
# File 'lib/clearbooks/model/entity.rb', line 90

def postcode
  @postcode
end

#statement_urlString (readonly)

Returns The URL the customer/supplier can access to view statements.

Returns:

  • (String)

    The URL the customer/supplier can access to view statements.

See Also:



46
47
48
# File 'lib/clearbooks/model/entity.rb', line 46

def statement_url
  @statement_url
end

#supplierHash (readonly)

Optional. [:default_account_code, :default_vat_rate, :default_credit_terms]



135
136
137
# File 'lib/clearbooks/model/entity.rb', line 135

def supplier
  @supplier
end

#townString (readonly)

Optional.



75
76
77
# File 'lib/clearbooks/model/entity.rb', line 75

def town
  @town
end

#vat_numberFixnum (readonly)

Optional.



125
126
127
# File 'lib/clearbooks/model/entity.rb', line 125

def vat_number
  @vat_number
end

#websiteString (readonly)

Optional.



115
116
117
# File 'lib/clearbooks/model/entity.rb', line 115

def website
  @website
end

Instance Method Details

#to_savonHash

Returns self as Savon readable Hash

Returns:

  • (Hash)

    Returns self as Savon readable Hash



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/clearbooks/model/entity.rb', line 187

def to_savon
  {
    entity: {
      :@company_name    => @company_name,
      :@contact_name    => @contact_name,

      :@building        => @building,
      :@address1        => @address1,
      :@address2        => @address2,
      :@town            => @town,
      :@county          => @county,
      :@country         => @country,
      :@postcode        => @postcode,

      :@email           => @email,
      :@phone1          => @phone1,
      :@phone2          => @phone2,
      :@fax             => @fax,
      :@website         => @website,

      :@company_number  => @company_number,
      :@vat_number      => @vat_number,
      :@external_id     => @external_id,
      :supplier         => entity_extra(@supplier),
      :customer         => entity_extra(@customer)
    }.compact
  }
end