Class: Stn::Zip
Overview
Provides methods to interact with ServiceTitan ZIP codes.
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
-
#zone_name ⇒ Object
readonly
Returns the value of attribute zone_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(zip:, state:, zone_name:) ⇒ Zip
constructor
A new instance of Zip.
Constructor Details
#initialize(zip:, state:, zone_name:) ⇒ Zip
Returns a new instance of Zip.
8 9 10 11 12 |
# File 'lib/stn/zip.rb', line 8 def initialize(zip:, state:, zone_name:) @zip = zip @state = state # I just need a look up table in this repo @zone_name = zone_name end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
6 7 8 |
# File 'lib/stn/zip.rb', line 6 def state @state end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
6 7 8 |
# File 'lib/stn/zip.rb', line 6 def zip @zip end |
#zone_name ⇒ Object (readonly)
Returns the value of attribute zone_name.
6 7 8 |
# File 'lib/stn/zip.rb', line 6 def zone_name @zone_name end |
Class Method Details
.all ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/stn/zip.rb', line 14 def self.all data = request path: "/dispatch/v2/tenant/#{Stn.configuration.tenant_id}/zones" data['data'].filter do |zone| zone['active'] end.flat_map do |zone| zone['zips'].map do |zip| new zip: zip, zone_name: zone['name'], state: 'XX' # need look up end end end |