Class: Vng::ServiceType
Overview
Provides methods to interact with Vonigo service types.
Constant Summary collapse
- PATH =
'/api/v1/resources/serviceTypes/'
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, type:, duration:) ⇒ ServiceType
constructor
A new instance of ServiceType.
Constructor Details
#initialize(id:, type:, duration:) ⇒ ServiceType
Returns a new instance of ServiceType.
10 11 12 13 14 |
# File 'lib/vng/service_type.rb', line 10 def initialize(id:, type:, duration:) @id = id @type = type @duration = duration end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
8 9 10 |
# File 'lib/vng/service_type.rb', line 8 def duration @duration end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/vng/service_type.rb', line 8 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/vng/service_type.rb', line 8 def type @type end |
Class Method Details
.all ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vng/service_type.rb', line 16 def self.all data = request path: PATH data['ServiceTypes'].map do |body| id = body['serviceTypeID'] type = body['serviceType'] duration = body['duration'] new id: id, type: type, duration: duration end end |
.where(zip:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vng/service_type.rb', line 28 def self.where(zip:) body = { zip: zip, } data = request path: PATH, body: body data.fetch('ServiceTypes', []).filter do |body| body['isActive'] end.map do |body| id = body['serviceTypeID'] type = body['serviceType'] duration = body['duration'] new id: id, type: type, duration: duration end end |