Class: Vng::Franchise
Overview
Provides methods to interact with Vonigo franchises.
Constant Summary collapse
- PATH =
'/api/v1/resources/franchises/'
Instance Attribute Summary collapse
-
#cell ⇒ Object
readonly
Returns the value of attribute cell.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#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.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, name: nil, gmt_offset: nil, email: nil, phone: nil, cell: nil) ⇒ Franchise
constructor
A new instance of Franchise.
Constructor Details
#initialize(id:, name: nil, gmt_offset: nil, email: nil, phone: nil, cell: nil) ⇒ Franchise
Returns a new instance of Franchise.
10 11 12 13 14 15 16 17 |
# File 'lib/vng/franchise.rb', line 10 def initialize(id:, name: nil, gmt_offset: nil, email: nil, phone: nil, cell: nil) @id = id @name = name @gmt_offset = gmt_offset @email = email @phone = phone @cell = cell end |
Instance Attribute Details
#cell ⇒ Object (readonly)
Returns the value of attribute cell.
8 9 10 |
# File 'lib/vng/franchise.rb', line 8 def cell @cell end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
8 9 10 |
# File 'lib/vng/franchise.rb', line 8 def email @email end |
#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 |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
8 9 10 |
# File 'lib/vng/franchise.rb', line 8 def phone @phone end |
Class Method Details
.all ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vng/franchise.rb', line 46 def self.all data = request path: PATH data.fetch('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(franchise_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vng/franchise.rb', line 32 def self.find(franchise_id) body = { method: '1', objectID: franchise_id, } data = request path: PATH, body: body email = value_for_field data, 9 phone = value_for_field data, 18 cell = value_for_field data, 1001 new id: franchise_id, email: email, phone: phone, cell: cell end |
.find_by(zip:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vng/franchise.rb', line 20 def self.find_by(zip:) body = { method: '1', zip: zip, } data = request path: Availability::PATH, body: body franchise_id = data['Ids']['franchiseID'] new(id: franchise_id) unless franchise_id == '0' end |