Class: Vng::PriceItem
- Inherits:
-
Object
- Object
- Vng::PriceItem
- Defined in:
- lib/vng/price_item.rb
Overview
Provides methods to interact with Vonigo price items.
Instance Attribute Summary collapse
-
#duration_per_unit ⇒ Object
readonly
Returns the value of attribute duration_per_unit.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#price_item ⇒ Object
readonly
Returns the value of attribute price_item.
-
#service_badge ⇒ Object
readonly
Returns the value of attribute service_badge.
-
#service_category ⇒ Object
readonly
Returns the value of attribute service_category.
-
#tax_id ⇒ Object
readonly
Returns the value of attribute tax_id.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, price_item:, value:, tax_id:, duration_per_unit:, service_badge:, service_category:) ⇒ PriceItem
constructor
A new instance of PriceItem.
Constructor Details
#initialize(id:, price_item:, value:, tax_id:, duration_per_unit:, service_badge:, service_category:) ⇒ PriceItem
Returns a new instance of PriceItem.
6 7 8 9 10 11 12 13 14 |
# File 'lib/vng/price_item.rb', line 6 def initialize(id:, price_item:, value:, tax_id:, duration_per_unit:, service_badge:, service_category:) @id = id @price_item = price_item @value = value @tax_id = tax_id @duration_per_unit = duration_per_unit @service_badge = service_badge @service_category = service_category end |
Instance Attribute Details
#duration_per_unit ⇒ Object (readonly)
Returns the value of attribute duration_per_unit.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def duration_per_unit @duration_per_unit end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def id @id end |
#price_item ⇒ Object (readonly)
Returns the value of attribute price_item.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def price_item @price_item end |
#service_badge ⇒ Object (readonly)
Returns the value of attribute service_badge.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def service_badge @service_badge end |
#service_category ⇒ Object (readonly)
Returns the value of attribute service_category.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def service_category @service_category end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def tax_id @tax_id end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/vng/price_item.rb', line 4 def value @value end |
Class Method Details
.where(location_id:, asset_id:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vng/price_item.rb', line 16 def self.where(location_id:, asset_id:) body = { securityToken: Vng.configuration.security_token, method: '2', serviceTypeID: '14', # only return items of serviceType 'Pet Grooming' locationID: location_id, assetID: asset_id, } uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/priceLists/' request = Net::HTTP::Post.new(uri.request_uri) request.initialize_http_header 'Content-Type' => 'application/json' request.body = body.to_json response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request request end JSON(response.body)['PriceItems'].filter do |body| # TODO: body['serviceBadge'] != 'Not Offered' body['isOnline'] && body['isActive'] end.map do |body| id = body['priceItemID'] price_item = body['priceItem'] value = body['value'] tax_id = body['taxID'] duration_per_unit = body['durationPerUnit'] service_badge = body['serviceBadge'] service_category = body['serviceCategory'] new id: id, price_item: price_item, value: value, tax_id: tax_id, duration_per_unit: duration_per_unit, service_badge: service_badge, service_category: service_category end end |