Class: CrunchApi::Supplier
- Inherits:
-
Object
- Object
- CrunchApi::Supplier
- Defined in:
- lib/crunch-api/supplier.rb
Instance Attribute Summary collapse
-
#contact_name ⇒ Object
readonly
Returns the value of attribute contact_name.
-
#default_expense_type ⇒ Object
readonly
Returns the value of attribute default_expense_type.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#fax ⇒ Object
readonly
Returns the value of attribute fax.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#telephone ⇒ Object
readonly
Returns the value of attribute telephone.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml) ⇒ Supplier
constructor
A new instance of Supplier.
- #unknown_supplier? ⇒ Boolean
Constructor Details
#initialize(xml) ⇒ Supplier
Returns a new instance of Supplier.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/crunch-api/supplier.rb', line 9 def initialize(xml) @id = xml[:@supplierId] @uri = xml[:@resourceUrl] @default_expense_type = xml[:@defaultExpenseType] @unknown_supplier_flag = xml[:@unknownSupplier] == "true" @name = xml[:name] @contact_name = xml[:contact_name] @email = xml[:email] @website = xml[:website] @telephone = xml[:telephone] @fax = xml[:fax] end |
Instance Attribute Details
#contact_name ⇒ Object (readonly)
Returns the value of attribute contact_name.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def contact_name @contact_name end |
#default_expense_type ⇒ Object (readonly)
Returns the value of attribute default_expense_type.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def default_expense_type @default_expense_type end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def email @email end |
#fax ⇒ Object (readonly)
Returns the value of attribute fax.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def fax @fax end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def name @name end |
#telephone ⇒ Object (readonly)
Returns the value of attribute telephone.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def telephone @telephone end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def uri @uri end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
7 8 9 |
# File 'lib/crunch-api/supplier.rb', line 7 def website @website end |
Class Method Details
.all ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/crunch-api/supplier.rb', line 26 def self.all consumer = OAuth::Consumer.new(CrunchApi.[:consumer_key], CrunchApi.[:consumer_secret], {}) token = OAuth::AccessToken.new(consumer, CrunchApi.[:oauth_token], CrunchApi.[:oauth_token_secret]) uri = "#{CrunchApi.[:endpoint]}#{path}" response = token.get(uri) parse_xml(response.body).collect{|attributes| new(attributes)} end |
.for_id(id) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/crunch-api/supplier.rb', line 37 def self.for_id(id) consumer = OAuth::Consumer.new(CrunchApi.[:consumer_key], CrunchApi.[:consumer_secret], {}) token = OAuth::AccessToken.new(consumer, CrunchApi.[:oauth_token], CrunchApi.[:oauth_token_secret]) uri = "#{CrunchApi.[:endpoint]}#{path}/#{id}" response = token.get(uri) new(parse_xml(response.body)) unless errors?(response.body) end |
Instance Method Details
#unknown_supplier? ⇒ Boolean
22 23 24 |
# File 'lib/crunch-api/supplier.rb', line 22 def unknown_supplier? @unknown_supplier_flag end |