vng 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b56225609421c36f0a90349ca36f0a3114544de059071e4de37fa6207c687586
4
- data.tar.gz: ca68eda1f4cae20d65bd2cc2012f33267faadfde01a5cd5d3738106d894dde3e
3
+ metadata.gz: 3214bdc1e7dd215763c9fd4eeef8910bd50060ff157b76240b288c75a9bd08a2
4
+ data.tar.gz: 5d85d042325d3d3bbeaa7b711d35df94ca505e92775b4d87eec1080b66d5af7e
5
5
  SHA512:
6
- metadata.gz: 641068d4d6ec024423ba52f5b931606e59eddb630c4501c90fb4b7bc13b3d8264ecc26dd6f1b8cfc22a0b787c9f2e4fd0bc21e854f14a5162c07ad70171fd3a7
7
- data.tar.gz: d3454b81e4c349a61de659ab6878c5bd40f37d3facabef16ccff7083d14b1d3c9c086f9170e8bbaf8cea2392cccd17d2e07dfa5dfa5da305a1e58a9ac9c4d550
6
+ metadata.gz: fb9492419c06a439732ca9bce3f79ef4f40a60a8c5875215b7ded6a912b5d04b37493842c02c8264f9a97aab6801bd73ca00e47b6963a0bd1cb072e5e9c2f197
7
+ data.tar.gz: c85669b1c567e1500833cc2aa4fd0ce5807f28a83cb1c0d4b6141762fbd93e3888de8758ef5846a5c0672629c19b4f813c3202b01853f5394d527f322ebed60b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [2.3.0] - 2025-01-09
2
+
3
+ - Add WorkOrder.for_client_id(client_id)
4
+
1
5
  ## [2.2.3] - 2025-01-06
2
6
 
3
7
  - Change mock for invalid phone to 0000000000
@@ -224,7 +224,21 @@ module Vng
224
224
  {"routeID" => 3, "routeName" => "Route 3 (Inactive)", "isActive" => false},
225
225
  ]}
226
226
  when '/api/v1/data/WorkOrders/'
227
- { "WorkOrder"=>{ "objectID"=>"4138030" } }
227
+ if @body[:isCompleteObject].eql? 'true'
228
+ {"WorkOrders" => [
229
+ {"objectID" => "4139754", "isActive" => "true", "Fields" => [
230
+ {"fieldID" => 185, "fieldValue" => "1736445600"},
231
+ {"fieldID" => 813, "fieldValue" => "135.00"},
232
+ {"fieldID" => 809, "fieldValue" => "0.00"},
233
+ {"fieldID" => 811, "fieldValue" => "0.00"},
234
+ {"fieldID" => 810, "fieldValue" => "0.00"},
235
+ {"fieldID" => 186, "fieldValue" => "30"},
236
+ {"fieldID" => 9835, "fieldValue" => "135.00"},
237
+ ]}
238
+ ]}
239
+ else
240
+ { "WorkOrder"=>{ "objectID"=>"4138030" } }
241
+ end
228
242
  when '/api/v1/data/Cases/'
229
243
  if @body[:method].eql? '3'
230
244
  {"Case" => {"objectID" => "28503"}}
data/lib/vng/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vng
2
- VERSION = '2.2.3'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -5,10 +5,17 @@ module Vng
5
5
  class WorkOrder < Resource
6
6
  PATH = '/api/v1/data/WorkOrders/'
7
7
 
8
- attr_reader :id
8
+ attr_reader :id, :scheduled_on, :price, :discount, :tax, :tip, :duration, :total
9
9
 
10
- def initialize(id:)
10
+ def initialize(id:, scheduled_on: nil, price: nil, discount: nil, tax: nil, tip: nil, duration: nil, total: nil)
11
11
  @id = id
12
+ @scheduled_on = scheduled_on
13
+ @price = price
14
+ @discount = discount
15
+ @tax = tax
16
+ @tip = tip
17
+ @duration = duration
18
+ @total = total
12
19
  end
13
20
 
14
21
  def self.create(lock_id:, client_id:, contact_id:, location_id:, duration:, summary:, line_items:)
@@ -32,6 +39,28 @@ module Vng
32
39
  new id: data['WorkOrder']['objectID']
33
40
  end
34
41
 
42
+ def self.for_client_id(client_id)
43
+ body = { clientID: client_id, isCompleteObject: 'true' }
44
+
45
+ data = request path: PATH, body: body, returning: 'WorkOrders'
46
+
47
+ data.filter_map do |body|
48
+ next unless body['isActive']
49
+
50
+ id = body['objectID']
51
+ # scheduled_on is in the time zone of the franchise, not UTC
52
+ scheduled_on = Time.at Integer(value_for_field body, 185), in: 'UTC'
53
+ price = BigDecimal(value_for_field body, 813)
54
+ discount = BigDecimal(value_for_field body, 809)
55
+ tax = BigDecimal(value_for_field body, 811)
56
+ tip = BigDecimal(value_for_field body, 810)
57
+ duration = Integer(value_for_field body, 186)
58
+ total = BigDecimal(value_for_field body, 9835)
59
+
60
+ new id:, scheduled_on:, price:, discount:, tax:, tip:, duration:, total:
61
+ end
62
+ end
63
+
35
64
  # Returns the URL to manage the work order in the Vonigo UI.
36
65
  def url
37
66
  "https://#{self.class.host}/Schedule/Job/Job_Main.aspx?woID=#{id}"
data/lib/vng.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # Used by multiple resources
2
+ require 'bigdecimal'
2
3
  require 'uri'
3
4
  require_relative 'vng/error'
4
5
  require_relative 'vng/config'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vng
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
10
+ date: 2025-01-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: simplecov
@@ -98,7 +97,6 @@ metadata:
98
97
  homepage_uri: https://rubygems.org/gems/vng
99
98
  source_code_uri: https://github.com/claudiob/vng
100
99
  changelog_uri: https://github.com/claudiob/vng/blob/main/CHANGELOG.md
101
- post_install_message:
102
100
  rdoc_options: []
103
101
  require_paths:
104
102
  - lib
@@ -113,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  - !ruby/object:Gem::Version
114
112
  version: '0'
115
113
  requirements: []
116
- rubygems_version: 3.5.23
117
- signing_key:
114
+ rubygems_version: 3.6.2
118
115
  specification_version: 4
119
116
  summary: A Ruby client for the Vonigo API.
120
117
  test_files: []