Class: Vng::Franchise
Overview
Provides methods to interact with Vonigo franchises.
Constant Summary collapse
- PATH =
'/api/v1/resources/franchises/'
Instance Attribute Summary collapse
-
#gmt_offset ⇒ Object
readonly
Returns the value of attribute gmt_offset.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, name: nil, gmt_offset: nil) ⇒ Franchise
constructor
A new instance of Franchise.
Constructor Details
#initialize(id:, name: nil, gmt_offset: nil) ⇒ Franchise
Returns a new instance of Franchise.
10 11 12 13 14 |
# File 'lib/vng/franchise.rb', line 10 def initialize(id:, name: nil, gmt_offset: nil) @id = id @name = name @gmt_offset = gmt_offset end |
Instance Attribute Details
#gmt_offset ⇒ Object (readonly)
Returns the value of attribute gmt_offset.
8 9 10 |
# File 'lib/vng/franchise.rb', line 8 def gmt_offset @gmt_offset end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/vng/franchise.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/vng/franchise.rb', line 8 def name @name end |
Class Method Details
.all ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vng/franchise.rb', line 29 def self.all data = request path: PATH data['Franchises'].filter do |franchise| franchise['isActive'] end.map do |franchise| id = franchise['franchiseID'] name = franchise['franchiseName'] gmt_offset = franchise['gmtOffsetFranchise'] new id: id, name: name, gmt_offset: gmt_offset end end |
.find_by(zip:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vng/franchise.rb', line 17 def self.find_by(zip:) body = { method: '1', zip: zip, } data = request path: Vng::Availability::PATH, body: body franchise_id = data['Ids']['franchiseID'] new(id: franchise_id) unless franchise_id == '0' end |