vng 0.1.0 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -0
- data/README.md +114 -2
- data/Rakefile +2 -4
- data/lib/vng/asset.rb +62 -0
- data/lib/vng/availability.rb +42 -0
- data/lib/vng/breed.rb +43 -0
- data/lib/vng/case.rb +54 -0
- data/lib/vng/config.rb +45 -0
- data/lib/vng/configuration.rb +51 -0
- data/lib/vng/contact.rb +67 -0
- data/lib/vng/franchise.rb +60 -0
- data/lib/vng/lead.rb +72 -0
- data/lib/vng/location.rb +68 -0
- data/lib/vng/lock.rb +54 -0
- data/lib/vng/price_item.rb +51 -0
- data/lib/vng/security_token.rb +51 -0
- data/lib/vng/service_type.rb +64 -0
- data/lib/vng/version.rb +1 -3
- data/lib/vng/work_order.rb +71 -0
- data/lib/vng/zip.rb +37 -0
- data/lib/vng.rb +21 -2
- metadata +35 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cff4f73336138d9e2386b1273fd4e398c8d3e8e9c52fb60ba4f47fb7b98e3bf
|
4
|
+
data.tar.gz: 6dbfa0fdad71e5fe35b113071e451a27e0150cde5ccffc7bc0676f191d433486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d76586e4271dc06bfe12ab3784f9534373f82e1953084c012ca79522ffbad4744486f55f66076b735bcafe7bddddc1465ef624f2af001aa0c183106a4403f0c4
|
7
|
+
data.tar.gz: 5bb9df92265cf90e2e10a88efc2e5cbd4de6d0b4e80e38dc2faf597780ea9b759e951fe331ae453db38253df4c93a58bd04d8a6c299318f475a5c04f6b5d08c1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,57 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.13] - 2024-11-15
|
4
|
+
|
5
|
+
- Enable Vng.configuration.security_token
|
6
|
+
|
7
|
+
## [0.1.12] - 2024-11-15
|
8
|
+
|
9
|
+
- Adds ServiceType.where(zip:)
|
10
|
+
|
11
|
+
## [0.1.11] - 2024-11-15
|
12
|
+
|
13
|
+
- Adds Zip
|
14
|
+
|
15
|
+
## [0.1.10] - 2024-11-14
|
16
|
+
|
17
|
+
- Adds Service Type
|
18
|
+
|
19
|
+
## [0.1.9] - 2024-11-13
|
20
|
+
|
21
|
+
- Adds Franchise
|
22
|
+
|
23
|
+
## [0.1.8] - 2024-11-13
|
24
|
+
|
25
|
+
- Adds Security Token
|
26
|
+
|
27
|
+
## [0.1.7] - 2024-11-12
|
28
|
+
|
29
|
+
- Adds Case
|
30
|
+
|
31
|
+
## [0.1.6] - 2024-11-12
|
32
|
+
|
33
|
+
- Adds WorkOrder
|
34
|
+
|
35
|
+
## [0.1.5] - 2024-11-11
|
36
|
+
|
37
|
+
- Adds Availability
|
38
|
+
|
39
|
+
## [0.1.4] - 2024-11-11
|
40
|
+
|
41
|
+
- Adds Price Item
|
42
|
+
|
43
|
+
## [0.1.3] - 2024-11-10
|
44
|
+
|
45
|
+
- Adds Location
|
46
|
+
|
47
|
+
## [0.1.2] - 2024-11-10
|
48
|
+
|
49
|
+
- Adds Breed
|
50
|
+
|
51
|
+
## [0.1.1] - 2024-11-10
|
52
|
+
|
53
|
+
- Adds Lead.create, Lead#destroy, Contact.create, Contact#destroy
|
54
|
+
|
3
55
|
## [0.1.0] - 2024-11-10
|
4
56
|
|
5
57
|
- Initial release
|
data/README.md
CHANGED
@@ -1,3 +1,115 @@
|
|
1
|
-
|
1
|
+
Vng - a Ruby client for the Vonigo API
|
2
|
+
======================================================
|
2
3
|
|
3
|
-
|
4
|
+
Vng helps you write apps that need to interact with Vonigo.
|
5
|
+
|
6
|
+
The **source code** is available on [GitHub](https://github.com/HouseAccountEng/vng) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/vng/frames).
|
7
|
+
|
8
|
+
After [registering your app](#configuring-your-app), you can run commands like:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
Vng::Zip.all
|
12
|
+
Vng::Franchise.all
|
13
|
+
Vng::ServiceType.where zip:
|
14
|
+
Vng::SecurityToken.create host:, usename:, password:
|
15
|
+
Vng::Lead.create email:, phone:, name: full_name
|
16
|
+
Vng::Contact.create first_name:, last_name:, email:, phone:, client_id:
|
17
|
+
Vng::Location.create address:, city:, zip:, state: state, client_id:
|
18
|
+
Vng::Breed.all
|
19
|
+
Vng::Asset.create name:, weight:, breed_option_id:, client_id:
|
20
|
+
Vng::PriceItem.where location_id:, asset_id:
|
21
|
+
Vng::Availability.where(location_id:, duration:, from_time:, to_time:
|
22
|
+
Vng::Lock.create date:, duration: location_id:
|
23
|
+
Vng::WorkOrder.create lock_id:, client_id:, contact_id:, location_id:, duration:, summary:, line_items:
|
24
|
+
Vng::Case.create client_id:, summary:, comments:
|
25
|
+
```
|
26
|
+
|
27
|
+
The **full documentation** is available at [rubydoc.info](http://www.rubydoc.info/gems/vng/frames).
|
28
|
+
|
29
|
+
How to install
|
30
|
+
==============
|
31
|
+
|
32
|
+
To install on your system, run
|
33
|
+
|
34
|
+
gem install vng
|
35
|
+
|
36
|
+
To use inside a bundled Ruby project, add this line to the Gemfile:
|
37
|
+
|
38
|
+
gem 'vng', '~> 0.1.13'
|
39
|
+
|
40
|
+
Since the gem follows [Semantic Versioning](http://semver.org),
|
41
|
+
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
42
|
+
guarantees that your project won’t occur in any error when you `bundle update`
|
43
|
+
and a new version of Vng is released.
|
44
|
+
|
45
|
+
Available resources
|
46
|
+
===================
|
47
|
+
|
48
|
+
Vng::Zip
|
49
|
+
-------
|
50
|
+
|
51
|
+
TODO
|
52
|
+
|
53
|
+
|
54
|
+
Configuring your app
|
55
|
+
====================
|
56
|
+
|
57
|
+
In order to use Vng you must have credentials to the [Vonigo](https://www.vonigo.com/) API.
|
58
|
+
|
59
|
+
Add them to your code with the following snippet of code (replacing with your own credentials):
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Vng.configure do |config|
|
63
|
+
config.host = 'subdomain.vonigo.com'
|
64
|
+
config.username = 'VonigoUser'
|
65
|
+
config.password = 'VonigoPassword'
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
Configuring with environment variables
|
70
|
+
--------------------------------------
|
71
|
+
|
72
|
+
As an alternative to the approach above, you can configure your app with
|
73
|
+
variables. Setting the following environment variables:
|
74
|
+
|
75
|
+
```bash
|
76
|
+
export VNG_HOST="subdomain.vonigo.com"
|
77
|
+
export VNG_USERNAME="VonigoUser"
|
78
|
+
export VNG_PASSWORD="VonigoPassword"
|
79
|
+
```
|
80
|
+
|
81
|
+
is equivalent to the previous approach so pick the one you prefer.
|
82
|
+
If a variable is set in both places, then `Vng.configure` takes precedence.
|
83
|
+
|
84
|
+
How to test
|
85
|
+
===========
|
86
|
+
|
87
|
+
To run tests:
|
88
|
+
|
89
|
+
```bash
|
90
|
+
rspec
|
91
|
+
```
|
92
|
+
|
93
|
+
How to release new versions
|
94
|
+
===========================
|
95
|
+
|
96
|
+
If you are a manager of this project, remember to upgrade the [Vng gem](http://rubygems.org/gems/vng)
|
97
|
+
whenever a new feature is added or a bug gets fixed.
|
98
|
+
Make sure all the tests are passing ,
|
99
|
+
document the changes in CHANGELOG.md and README.md, bump the version, then run
|
100
|
+
|
101
|
+
rake release
|
102
|
+
|
103
|
+
Remember that the vng gem follows [Semantic Versioning](http://semver.org).
|
104
|
+
Any new release that is fully backward-compatible should bump the *patch* version (0.0.x).
|
105
|
+
Any new version that breaks compatibility should bump the *minor* version (0.x.0)
|
106
|
+
|
107
|
+
How to contribute
|
108
|
+
=================
|
109
|
+
|
110
|
+
Vng needs your support!
|
111
|
+
The goal of Vng is to provide a Ruby interface for all the methods exposed by the Vonigo API.
|
112
|
+
|
113
|
+
If you find that a method is missing, fork the project, add the missing code,
|
114
|
+
write the appropriate tests, then submit a pull request, and it will gladly
|
115
|
+
be merged!
|
data/Rakefile
CHANGED
data/lib/vng/asset.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo assets.
|
3
|
+
class Asset
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
def initialize(id:)
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create(name:, weight:, breed_option_id:, client_id:)
|
11
|
+
body = {
|
12
|
+
securityToken: Vng.configuration.security_token,
|
13
|
+
method: '3',
|
14
|
+
clientID: client_id,
|
15
|
+
Fields: [
|
16
|
+
{fieldID: 1013, fieldValue: name},
|
17
|
+
{fieldID: 1017, fieldValue: weight},
|
18
|
+
{fieldID: 1014, optionID: breed_option_id},
|
19
|
+
]
|
20
|
+
}
|
21
|
+
|
22
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Assets/'
|
23
|
+
|
24
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
25
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
26
|
+
request.body = body.to_json
|
27
|
+
|
28
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
29
|
+
http.request request
|
30
|
+
end
|
31
|
+
|
32
|
+
# curl = 'curl'.tap do |curl|
|
33
|
+
# curl << ' -X POST'
|
34
|
+
# request.each_header{|k, v| curl << %Q{ -H "#{k}: #{v}"}}
|
35
|
+
# curl << %Q{ -d '#{request.body}'} if request.body
|
36
|
+
# curl << %Q{ "#{uri.to_s}"}
|
37
|
+
# end
|
38
|
+
# puts curl
|
39
|
+
|
40
|
+
new id: JSON(response.body)['Asset']['objectID']
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
body = {
|
45
|
+
securityToken: Vng.configuration.security_token,
|
46
|
+
method: '4',
|
47
|
+
objectID: id,
|
48
|
+
}
|
49
|
+
|
50
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Assets/'
|
51
|
+
|
52
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
53
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
54
|
+
request.body = body.to_json
|
55
|
+
|
56
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
57
|
+
http.request request
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo availabilities.
|
3
|
+
class Availability
|
4
|
+
attr_reader :route_id, :date, :minutes
|
5
|
+
|
6
|
+
def initialize(route_id:, date:, minutes:)
|
7
|
+
@route_id = route_id
|
8
|
+
@date = date
|
9
|
+
@minutes = minutes
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.where(location_id:, duration:, from_time:, to_time:)
|
13
|
+
body = {
|
14
|
+
securityToken: Vng.configuration.security_token,
|
15
|
+
method: '0',
|
16
|
+
serviceTypeID: '14', # only return items of serviceType 'Pet Grooming'
|
17
|
+
locationID: location_id,
|
18
|
+
duration: duration.to_i,
|
19
|
+
dateStart: from_time.to_i,
|
20
|
+
dateEnd: to_time.to_i,
|
21
|
+
}
|
22
|
+
|
23
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/availability/'
|
24
|
+
|
25
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
26
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
27
|
+
request.body = body.to_json
|
28
|
+
|
29
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
30
|
+
http.request request
|
31
|
+
end
|
32
|
+
|
33
|
+
JSON(response.body)['Availability'].map do |body|
|
34
|
+
route_id = body['routeID']
|
35
|
+
date = Date.strptime body['dayID'], '%Y%m%d'
|
36
|
+
minutes = body['startTime'].to_i
|
37
|
+
|
38
|
+
new route_id: route_id, date: date, minutes: minutes
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/vng/breed.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo breeds.
|
3
|
+
class Breed
|
4
|
+
attr_reader :id, :name, :species, :option_id, :low_weight, :high_weight
|
5
|
+
|
6
|
+
def initialize(id:, name:, species:, option_id:, low_weight:, high_weight:)
|
7
|
+
@id = id
|
8
|
+
@name = name
|
9
|
+
@species = species
|
10
|
+
@option_id = option_id
|
11
|
+
@low_weight = low_weight
|
12
|
+
@high_weight = high_weight
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: Needs pagination
|
16
|
+
def self.all
|
17
|
+
body = {
|
18
|
+
securityToken: Vng.configuration.security_token,
|
19
|
+
}
|
20
|
+
|
21
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/breeds/'
|
22
|
+
|
23
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
24
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
25
|
+
request.body = body.to_json
|
26
|
+
|
27
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
28
|
+
http.request request
|
29
|
+
end
|
30
|
+
|
31
|
+
JSON(response.body)['Breeds'].map do |body|
|
32
|
+
id = body['breedID']
|
33
|
+
name = body['breed']
|
34
|
+
species = body['species']
|
35
|
+
option_id = body['optionID']
|
36
|
+
low_weight = body['breedLowWeight']
|
37
|
+
high_weight = body['breedHighWeight']
|
38
|
+
|
39
|
+
new id: id, name: name, species: species, option_id: option_id, low_weight: low_weight, high_weight: high_weight
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/vng/case.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo cases.
|
3
|
+
class Case
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
def initialize(id:)
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create(client_id:, summary:, comments:)
|
11
|
+
body = {
|
12
|
+
securityToken: Vng.configuration.security_token,
|
13
|
+
method: '3',
|
14
|
+
objectID: client_id,
|
15
|
+
Fields: [
|
16
|
+
{fieldID: 219, optionID: 239}, # Status: open
|
17
|
+
{fieldID: 220, fieldValue: summary},
|
18
|
+
{fieldID: 230, fieldValue: comments},
|
19
|
+
]
|
20
|
+
}
|
21
|
+
|
22
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Cases/'
|
23
|
+
|
24
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
25
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
26
|
+
request.body = body.to_json
|
27
|
+
|
28
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
29
|
+
http.request request
|
30
|
+
end
|
31
|
+
|
32
|
+
new id: JSON(response.body)['Case']['objectID']
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
body = {
|
37
|
+
securityToken: Vng.configuration.security_token,
|
38
|
+
method: '4',
|
39
|
+
objectID: id,
|
40
|
+
}
|
41
|
+
|
42
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Cases/'
|
43
|
+
|
44
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
45
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
46
|
+
request.body = body.to_json
|
47
|
+
|
48
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
49
|
+
http.request request
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/lib/vng/config.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'vng/configuration'
|
2
|
+
|
3
|
+
# An object-oriented Ruby client for Voonigo.
|
4
|
+
# @see http://www.rubydoc.info/gems/vng/
|
5
|
+
module Vng
|
6
|
+
# Provides methods to read and write global configuration settings.
|
7
|
+
#
|
8
|
+
# A typical usage is to set the Security Token for the API calls.
|
9
|
+
#
|
10
|
+
# @example Set the Security Token for the API client:
|
11
|
+
# Vng.configure do |config|
|
12
|
+
# config.security_token = 'ABCDEFGHIJ1234567890'
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
module Config
|
16
|
+
# Yields the global configuration to the given block.
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# Vng.configure do |config|
|
20
|
+
# config.security_token = 'ABCDEFGHIJ1234567890'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# @yield [Vng::Models::Configuration] The global configuration.
|
24
|
+
def configure
|
25
|
+
yield configuration if block_given?
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the global {Vng::Models::Configuration} object.
|
29
|
+
#
|
30
|
+
# While this method _can_ be used to read and write configuration settings,
|
31
|
+
# it is easier to use {Vng::Config#configure} Vng.configure}.
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# Vng.configuration.security_token = 'ABCDEFGHIJ1234567890'
|
35
|
+
#
|
36
|
+
# @return [Vng::Models::Configuration] The global configuration.
|
37
|
+
def configuration
|
38
|
+
@configuration ||= Vng::Configuration.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# @note Config is the only module auto-loaded in the Vng module,
|
43
|
+
# in order to have a syntax as easy as Vng.configure
|
44
|
+
extend Config
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides an object to store global configuration settings.
|
3
|
+
#
|
4
|
+
# This class is typically not used directly, but by calling
|
5
|
+
# {Vng::Config#configure Vng.configure}, which creates and updates a single
|
6
|
+
# instance of {Vng::Models::Configuration}.
|
7
|
+
#
|
8
|
+
# @example Set the Security Token for the API client:
|
9
|
+
# Vng.configure do |config|
|
10
|
+
# config.security_token = 'ABCDEFGHIJ1234567890'
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# @see Vng::Config for more examples.
|
14
|
+
#
|
15
|
+
# An alternative way to set global configuration settings is by storing
|
16
|
+
# them in the following environment variables:
|
17
|
+
#
|
18
|
+
# * +VNG_HOST+ to store the host for the Vonigo API
|
19
|
+
# * +VNG_USERNAME+ to store the username for the Vonigo API
|
20
|
+
# * +VNG_PASSWORD+ to store the password for the Vonigo API
|
21
|
+
#
|
22
|
+
# In case both methods are used together,
|
23
|
+
# {Vng::Config#configure Vng.configure} takes precedence.
|
24
|
+
#
|
25
|
+
# @example Set the API credentials
|
26
|
+
# ENV['VNG_HOST'] = 'subdomain.vonigo.com'
|
27
|
+
# ENV['VNG_USERNAME'] = 'VonigoUser'
|
28
|
+
# ENV['VNG_Password'] = 'VonigoPassword'
|
29
|
+
#
|
30
|
+
class Configuration
|
31
|
+
# @return [String] the Security Token for the API calls.
|
32
|
+
attr_accessor :security_token
|
33
|
+
|
34
|
+
# @return [String] the URI host for the API calls.
|
35
|
+
attr_accessor :host
|
36
|
+
|
37
|
+
# @return [String] the username for the API calls.
|
38
|
+
attr_accessor :username
|
39
|
+
|
40
|
+
# @return [String] the password for the API calls.
|
41
|
+
attr_accessor :password
|
42
|
+
|
43
|
+
# Initialize the global configuration settings, using the values of
|
44
|
+
# the specified following environment variables by default.
|
45
|
+
def initialize
|
46
|
+
@host = ENV['VNG_HOST']
|
47
|
+
@username = ENV['VNG_USERNAME']
|
48
|
+
@password = ENV['VNG_PASSWORD']
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/vng/contact.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo contacts.
|
3
|
+
class Contact
|
4
|
+
attr_reader :id, :first_name, :last_name, :email, :phone
|
5
|
+
|
6
|
+
def initialize(id:, first_name:, last_name:, email:, phone:)
|
7
|
+
@id = id
|
8
|
+
@first_name = first_name
|
9
|
+
@last_name = last_name
|
10
|
+
@email = email
|
11
|
+
@phone = phone
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(first_name:, last_name:, email:, phone:, client_id:)
|
15
|
+
body = {
|
16
|
+
securityToken: Vng.configuration.security_token,
|
17
|
+
method: '3',
|
18
|
+
clientID: client_id,
|
19
|
+
Fields: [
|
20
|
+
{fieldID: 127, fieldValue: first_name},
|
21
|
+
{fieldID: 128, fieldValue: last_name},
|
22
|
+
{fieldID: 97, fieldValue: email},
|
23
|
+
{fieldID: 96, fieldValue: phone},
|
24
|
+
]
|
25
|
+
}
|
26
|
+
|
27
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Contacts/'
|
28
|
+
|
29
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
30
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
31
|
+
request.body = body.to_json
|
32
|
+
|
33
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
34
|
+
http.request request
|
35
|
+
end
|
36
|
+
|
37
|
+
body = JSON response.body
|
38
|
+
|
39
|
+
id = body['Contact']['objectID']
|
40
|
+
first_name = body['Fields'].find{|field| field['fieldID'] == 127}['fieldValue']
|
41
|
+
last_name = body['Fields'].find{|field| field['fieldID'] == 128}['fieldValue']
|
42
|
+
email = body['Fields'].find{|field| field['fieldID'] == 97}['fieldValue']
|
43
|
+
phone = body['Fields'].find{|field| field['fieldID'] == 96}['fieldValue']
|
44
|
+
|
45
|
+
new id: id, first_name: first_name, last_name: last_name, email: email, phone: phone
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
body = {
|
50
|
+
securityToken: Vng.configuration.security_token,
|
51
|
+
method: '4',
|
52
|
+
objectID: id,
|
53
|
+
}
|
54
|
+
|
55
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Contacts/'
|
56
|
+
|
57
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
58
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
59
|
+
request.body = body.to_json
|
60
|
+
|
61
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
62
|
+
http.request request
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo franchises.
|
3
|
+
class Franchise
|
4
|
+
attr_reader :id, :name, :gmt_offset
|
5
|
+
|
6
|
+
def initialize(id:, name: nil, gmt_offset: nil)
|
7
|
+
@id = id
|
8
|
+
@name = name
|
9
|
+
@gmt_offset = gmt_offset
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def self.find_by(zip:)
|
14
|
+
body = {
|
15
|
+
securityToken: Vng.configuration.security_token,
|
16
|
+
method: '1',
|
17
|
+
zip: zip,
|
18
|
+
}
|
19
|
+
|
20
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/availability/'
|
21
|
+
|
22
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
23
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
24
|
+
request.body = body.to_json
|
25
|
+
|
26
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
27
|
+
http.request request
|
28
|
+
end
|
29
|
+
|
30
|
+
franchise_id = JSON(response.body)['Ids']['franchiseID']
|
31
|
+
new(id: franchise_id) unless franchise_id == '0'
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.all
|
35
|
+
body = {
|
36
|
+
securityToken: Vng.configuration.security_token,
|
37
|
+
}
|
38
|
+
|
39
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/franchises/'
|
40
|
+
|
41
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
42
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
43
|
+
request.body = body.to_json
|
44
|
+
|
45
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
46
|
+
http.request request
|
47
|
+
end
|
48
|
+
|
49
|
+
JSON(response.body)['Franchises'].filter do |body|
|
50
|
+
body['isActive']
|
51
|
+
end.map do |body|
|
52
|
+
id = body['franchiseID']
|
53
|
+
name = body['franchiseName']
|
54
|
+
gmt_offset = body['gmtOffsetFranchise']
|
55
|
+
|
56
|
+
new id: id, name: name, gmt_offset: gmt_offset
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/vng/lead.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo leads.
|
3
|
+
class Lead
|
4
|
+
attr_reader :id, :name, :email, :phone
|
5
|
+
|
6
|
+
def initialize(id:, name:, email:, phone:)
|
7
|
+
@id = id
|
8
|
+
@name = name
|
9
|
+
@email = email
|
10
|
+
@phone = phone
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.create(name:, email:, phone:)
|
14
|
+
body = {
|
15
|
+
securityToken: Vng.configuration.security_token,
|
16
|
+
method: '3',
|
17
|
+
Fields: [
|
18
|
+
{fieldID: 121, optionID: '59'},
|
19
|
+
{fieldID: 126, fieldValue: name},
|
20
|
+
{fieldID: 238, fieldValue: email},
|
21
|
+
{fieldID: 1024, fieldValue: phone},
|
22
|
+
]
|
23
|
+
}
|
24
|
+
|
25
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Leads/'
|
26
|
+
|
27
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
28
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
29
|
+
request.body = body.to_json
|
30
|
+
|
31
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
32
|
+
http.request request
|
33
|
+
end
|
34
|
+
|
35
|
+
body = JSON response.body
|
36
|
+
|
37
|
+
if body['errNo']
|
38
|
+
# 'errNo'=>-600,
|
39
|
+
# 'errMsg'=>'Data validation failed.',
|
40
|
+
# 'dateNow'=>'1731342482',
|
41
|
+
# 'Errors'=>[{"fieldID"=>1024, "fieldName"=>"Phone # to Reach You", "errNo"=>-602, "errMsg"=>"Field data is in incorrect format."}]}
|
42
|
+
|
43
|
+
# raise Vng::Error
|
44
|
+
end
|
45
|
+
|
46
|
+
id = body['Client']['objectID']
|
47
|
+
name = body['Fields'].find{|field| field['fieldID'] == 126}['fieldValue']
|
48
|
+
email = body['Fields'].find{|field| field['fieldID'] == 238}['fieldValue']
|
49
|
+
phone = body['Fields'].find{|field| field['fieldID'] == 1024}['fieldValue']
|
50
|
+
|
51
|
+
new id: id, name: name, email: email, phone: phone
|
52
|
+
end
|
53
|
+
|
54
|
+
def destroy
|
55
|
+
body = {
|
56
|
+
securityToken: Vng.configuration.security_token,
|
57
|
+
method: '4',
|
58
|
+
objectID: id,
|
59
|
+
}
|
60
|
+
|
61
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Leads/'
|
62
|
+
|
63
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
64
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
65
|
+
request.body = body.to_json
|
66
|
+
|
67
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
68
|
+
http.request request
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/vng/location.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo locations.
|
3
|
+
class Location
|
4
|
+
# TODO: fetch from /system/objects/ method: 1, objectID: 20
|
5
|
+
STATES_OPTION_ID = {
|
6
|
+
AK: 9879, AL: 9878, AR: 9877, AZ: 9880, CA: 9883, CO: 9876, CT: 9875,
|
7
|
+
DC: 9874, DE: 9873, FL: 9872, GA: 9871, HI: 9870, IA: 9869, ID: 9868,
|
8
|
+
IL: 9867, IN: 9866, KS: 9865, KY: 9864, LA: 9863, MA: 9862, MD: 9861,
|
9
|
+
ME: 9860, MI: 9859, MN: 9858, MO: 9857, MS: 9856, MT: 9855, NC: 9854,
|
10
|
+
ND: 9853, NE: 9852, NH: 9851, NJ: 9850, NM: 9849, NV: 9829, NY: 9848,
|
11
|
+
OH: 9847, OK: 9846, OR: 9881, PA: 9845, RI: 9843, SC: 9841, SD: 9842,
|
12
|
+
TN: 9840, TX: 9839, UT: 9838, VA: 9837, VT: 9836, WA: 9882, WI: 9828,
|
13
|
+
WV: 9835, WY: 9834,
|
14
|
+
}
|
15
|
+
|
16
|
+
attr_reader :id
|
17
|
+
|
18
|
+
def initialize(id:)
|
19
|
+
@id = id
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create(address:, city:, zip:, state:, client_id:)
|
23
|
+
body = {
|
24
|
+
securityToken: Vng.configuration.security_token,
|
25
|
+
method: '3',
|
26
|
+
clientID: client_id,
|
27
|
+
Fields: [
|
28
|
+
{fieldID: 779, optionID: 9906}, # 'USA'
|
29
|
+
{fieldID: 778, optionID: STATES_OPTION_ID[state.to_sym]},
|
30
|
+
{fieldID: 776, fieldValue: city},
|
31
|
+
{fieldID: 773, fieldValue: address},
|
32
|
+
{fieldID: 775, fieldValue: zip},
|
33
|
+
]
|
34
|
+
}
|
35
|
+
|
36
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Locations/'
|
37
|
+
|
38
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
39
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
40
|
+
request.body = body.to_json
|
41
|
+
|
42
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
43
|
+
http.request request
|
44
|
+
end
|
45
|
+
|
46
|
+
new id: JSON(response.body)['Location']['objectID']
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy
|
50
|
+
body = {
|
51
|
+
securityToken: Vng.configuration.security_token,
|
52
|
+
method: '4',
|
53
|
+
objectID: id,
|
54
|
+
}
|
55
|
+
|
56
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Locations/'
|
57
|
+
|
58
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
59
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
60
|
+
request.body = body.to_json
|
61
|
+
|
62
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
63
|
+
http.request request
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
data/lib/vng/lock.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo locks.
|
3
|
+
class Lock
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
def initialize(id:)
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create(duration:, location_id:, date:, minutes:, route_id:)
|
11
|
+
body = {
|
12
|
+
securityToken: Vng.configuration.security_token,
|
13
|
+
method: '2',
|
14
|
+
serviceTypeID: '14', # only create items of serviceType 'Pet Grooming'
|
15
|
+
duration: duration.to_i,
|
16
|
+
locationID: location_id,
|
17
|
+
dayID: date.strftime('%Y%m%d'),
|
18
|
+
routeID: route_id,
|
19
|
+
startTime: minutes,
|
20
|
+
}
|
21
|
+
|
22
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/availability/'
|
23
|
+
|
24
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
25
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
26
|
+
request.body = body.to_json
|
27
|
+
|
28
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
29
|
+
http.request request
|
30
|
+
end
|
31
|
+
|
32
|
+
id = JSON(response.body)['Ids']['lockID']
|
33
|
+
new id: id
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
body = {
|
38
|
+
securityToken: Vng.configuration.security_token,
|
39
|
+
method: '4',
|
40
|
+
objectID: id,
|
41
|
+
}
|
42
|
+
|
43
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/availability/'
|
44
|
+
|
45
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
46
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
47
|
+
request.body = body.to_json
|
48
|
+
|
49
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
50
|
+
http.request request
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo price items.
|
3
|
+
class PriceItem
|
4
|
+
attr_reader :id, :price_item, :value, :tax_id, :duration_per_unit, :service_badge, :service_category
|
5
|
+
|
6
|
+
def initialize(id:, price_item:, value:, tax_id:, duration_per_unit:, service_badge:, service_category:)
|
7
|
+
@id = id
|
8
|
+
@price_item = price_item
|
9
|
+
@value = value
|
10
|
+
@tax_id = tax_id
|
11
|
+
@duration_per_unit = duration_per_unit
|
12
|
+
@service_badge = service_badge
|
13
|
+
@service_category = service_category
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.where(location_id:, asset_id:)
|
17
|
+
body = {
|
18
|
+
securityToken: Vng.configuration.security_token,
|
19
|
+
method: '2',
|
20
|
+
serviceTypeID: '14', # only return items of serviceType 'Pet Grooming'
|
21
|
+
locationID: location_id,
|
22
|
+
assetID: asset_id,
|
23
|
+
}
|
24
|
+
|
25
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/priceLists/'
|
26
|
+
|
27
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
28
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
29
|
+
request.body = body.to_json
|
30
|
+
|
31
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
32
|
+
http.request request
|
33
|
+
end
|
34
|
+
|
35
|
+
JSON(response.body)['PriceItems'].filter do |body|
|
36
|
+
# TODO: body['serviceBadge'] != 'Not Offered'
|
37
|
+
body['isOnline'] && body['isActive']
|
38
|
+
end.map do |body|
|
39
|
+
id = body['priceItemID']
|
40
|
+
price_item = body['priceItem']
|
41
|
+
value = body['value']
|
42
|
+
tax_id = body['taxID']
|
43
|
+
duration_per_unit = body['durationPerUnit']
|
44
|
+
service_badge = body['serviceBadge']
|
45
|
+
service_category = body['serviceCategory']
|
46
|
+
|
47
|
+
new id: id, price_item: price_item, value: value, tax_id: tax_id, duration_per_unit: duration_per_unit, service_badge: service_badge, service_category: service_category
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo work security tokens.
|
3
|
+
class SecurityToken
|
4
|
+
attr_reader :token
|
5
|
+
|
6
|
+
def initialize(token:, host:)
|
7
|
+
@token = token
|
8
|
+
@host = host
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(host:, username:, password:)
|
12
|
+
body = {
|
13
|
+
app_version: '1',
|
14
|
+
company: 'Vonigo',
|
15
|
+
host: host,
|
16
|
+
password: Digest::MD5.hexdigest(password),
|
17
|
+
username: username,
|
18
|
+
}
|
19
|
+
|
20
|
+
uri = URI::HTTPS.build host: host, path: '/api/v1/security/login/'
|
21
|
+
|
22
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
23
|
+
request.initialize_http_header 'Content-Type' => 'application/json; charset=utf-8'
|
24
|
+
request.body = body.to_json
|
25
|
+
|
26
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
27
|
+
http.request request
|
28
|
+
end
|
29
|
+
|
30
|
+
token = JSON(response.body)['securityToken']
|
31
|
+
|
32
|
+
new token: token, host: host
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
body = {
|
37
|
+
securityToken: @token,
|
38
|
+
}
|
39
|
+
|
40
|
+
uri = URI::HTTPS.build host: @host, path: '/api/v1/security/login/'
|
41
|
+
|
42
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
43
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
44
|
+
request.body = body.to_json
|
45
|
+
|
46
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
47
|
+
http.request request
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo service types.
|
3
|
+
class ServiceType
|
4
|
+
attr_reader :id, :type, :duration
|
5
|
+
|
6
|
+
def initialize(id:, type:, duration:)
|
7
|
+
@id = id
|
8
|
+
@type = type
|
9
|
+
@duration = duration
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO: Needs pagination
|
13
|
+
def self.all
|
14
|
+
body = {
|
15
|
+
securityToken: Vng.configuration.security_token,
|
16
|
+
}
|
17
|
+
|
18
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/serviceTypes/'
|
19
|
+
|
20
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
21
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
22
|
+
request.body = body.to_json
|
23
|
+
|
24
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
25
|
+
http.request request
|
26
|
+
end
|
27
|
+
|
28
|
+
JSON(response.body)['ServiceTypes'].map do |body|
|
29
|
+
id = body['serviceTypeID']
|
30
|
+
type = body['serviceType']
|
31
|
+
duration = body['duration']
|
32
|
+
|
33
|
+
new id: id, type: type, duration: duration
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.where(zip:)
|
38
|
+
body = {
|
39
|
+
securityToken: Vng.configuration.security_token,
|
40
|
+
zip: zip,
|
41
|
+
}
|
42
|
+
|
43
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/serviceTypes/'
|
44
|
+
|
45
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
46
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
47
|
+
request.body = body.to_json
|
48
|
+
|
49
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
50
|
+
http.request request
|
51
|
+
end
|
52
|
+
|
53
|
+
JSON(response.body)['ServiceTypes'].filter do |body|
|
54
|
+
body['isActive']
|
55
|
+
end.map do |body|
|
56
|
+
id = body['serviceTypeID']
|
57
|
+
type = body['serviceType']
|
58
|
+
duration = body['duration']
|
59
|
+
|
60
|
+
new id: id, type: type, duration: duration
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/vng/version.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo work orders.
|
3
|
+
class WorkOrder
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
def initialize(id:)
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create(lock_id:, client_id:, contact_id:, location_id:, duration:, summary:, line_items:)
|
11
|
+
charges = line_items.map do |line_item|
|
12
|
+
{
|
13
|
+
priceItemID: line_item[:price_item_id],
|
14
|
+
taxID: line_item[:tax_id],
|
15
|
+
assetID: line_item[:asset_id],
|
16
|
+
Fields: [
|
17
|
+
{fieldID: 9289, fieldValue: line_item[:description]},
|
18
|
+
{fieldID: 9287, fieldValue: line_item[:price]}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
body = {
|
24
|
+
securityToken: Vng.configuration.security_token,
|
25
|
+
method: '3',
|
26
|
+
serviceTypeID: '14', # only return items of serviceType 'Pet Grooming'
|
27
|
+
lockID: lock_id,
|
28
|
+
clientID: client_id,
|
29
|
+
contactID: contact_id,
|
30
|
+
locationID: location_id,
|
31
|
+
Fields: [
|
32
|
+
{fieldID: 200, fieldValue: summary},
|
33
|
+
{fieldID: 186, fieldValue: duration.to_i},
|
34
|
+
{fieldID: 201, optionID: '9537'} # label: Online Tentative
|
35
|
+
],
|
36
|
+
Charges: charges
|
37
|
+
}
|
38
|
+
|
39
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/WorkOrders/'
|
40
|
+
|
41
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
42
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
43
|
+
request.body = body.to_json
|
44
|
+
|
45
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
46
|
+
http.request request
|
47
|
+
end
|
48
|
+
|
49
|
+
id = JSON(response.body)['WorkOrder']['objectID']
|
50
|
+
new id: id
|
51
|
+
end
|
52
|
+
|
53
|
+
def destroy
|
54
|
+
body = {
|
55
|
+
securityToken: Vng.configuration.security_token,
|
56
|
+
method: '4',
|
57
|
+
objectID: id,
|
58
|
+
}
|
59
|
+
|
60
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/WorkOrders/'
|
61
|
+
|
62
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
63
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
64
|
+
request.body = body.to_json
|
65
|
+
|
66
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
67
|
+
http.request request
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/vng/zip.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Vng
|
2
|
+
# Provides methods to interact with Vonigo ZIP codes.
|
3
|
+
class Zip
|
4
|
+
attr_reader :zip, :state, :zone_name
|
5
|
+
|
6
|
+
def initialize(zip:, state:, zone_name:)
|
7
|
+
@zip = zip
|
8
|
+
@state = state
|
9
|
+
@zone_name = zone_name
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO: Needs pagination
|
13
|
+
def self.all
|
14
|
+
body = {
|
15
|
+
securityToken: Vng.configuration.security_token,
|
16
|
+
}
|
17
|
+
|
18
|
+
uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/zips/'
|
19
|
+
|
20
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
21
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
22
|
+
request.body = body.to_json
|
23
|
+
|
24
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
25
|
+
http.request request
|
26
|
+
end
|
27
|
+
|
28
|
+
JSON(response.body)['Zips'].map do |body|
|
29
|
+
zip = body['zip']
|
30
|
+
state = body['state']
|
31
|
+
zone_name = body['zoneName']
|
32
|
+
|
33
|
+
new zip: zip, state: state, zone_name: zone_name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/vng.rb
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
-
|
1
|
+
require 'date'
|
2
|
+
require 'digest/md5'
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
2
6
|
|
3
|
-
require_relative
|
7
|
+
require_relative 'vng/asset'
|
8
|
+
require_relative 'vng/availability'
|
9
|
+
require_relative 'vng/breed'
|
10
|
+
require_relative 'vng/case'
|
11
|
+
require_relative 'vng/config'
|
12
|
+
require_relative 'vng/contact'
|
13
|
+
require_relative 'vng/franchise'
|
14
|
+
require_relative 'vng/lead'
|
15
|
+
require_relative 'vng/location'
|
16
|
+
require_relative 'vng/lock'
|
17
|
+
require_relative 'vng/price_item'
|
18
|
+
require_relative 'vng/security_token'
|
19
|
+
require_relative 'vng/service_type'
|
20
|
+
require_relative 'vng/version'
|
21
|
+
require_relative 'vng/work_order'
|
22
|
+
require_relative 'vng/zip'
|
4
23
|
|
5
24
|
module Vng
|
6
25
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- claudiob
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simplecov
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: A Ruby client for the Vonigo API.
|
14
28
|
email:
|
15
29
|
- claudiob@users.noreply.github.com
|
@@ -23,12 +37,28 @@ files:
|
|
23
37
|
- README.md
|
24
38
|
- Rakefile
|
25
39
|
- lib/vng.rb
|
40
|
+
- lib/vng/asset.rb
|
41
|
+
- lib/vng/availability.rb
|
42
|
+
- lib/vng/breed.rb
|
43
|
+
- lib/vng/case.rb
|
44
|
+
- lib/vng/config.rb
|
45
|
+
- lib/vng/configuration.rb
|
46
|
+
- lib/vng/contact.rb
|
47
|
+
- lib/vng/franchise.rb
|
48
|
+
- lib/vng/lead.rb
|
49
|
+
- lib/vng/location.rb
|
50
|
+
- lib/vng/lock.rb
|
51
|
+
- lib/vng/price_item.rb
|
52
|
+
- lib/vng/security_token.rb
|
53
|
+
- lib/vng/service_type.rb
|
26
54
|
- lib/vng/version.rb
|
27
|
-
|
55
|
+
- lib/vng/work_order.rb
|
56
|
+
- lib/vng/zip.rb
|
57
|
+
homepage: https://rubygems.org/gems/vng
|
28
58
|
licenses:
|
29
59
|
- MIT
|
30
60
|
metadata:
|
31
|
-
homepage_uri: https://
|
61
|
+
homepage_uri: https://rubygems.org/gems/vng
|
32
62
|
source_code_uri: https://github.com/HouseAccountEng/vng
|
33
63
|
changelog_uri: https://github.com/HouseAccountEng/vng/blob/main/CHANGELOG.md
|
34
64
|
post_install_message:
|