servizehub 1.0.3 → 1.1.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 +4 -4
- data/README.md +110 -0
- data/lib/servizehub/client.rb +16 -4
- data/lib/servizehub/version.rb +3 -3
- metadata +32 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 703bb932d579389a19ba02c1df3efe5f62194d2846d81dc0d327fcd56534c3f4
|
|
4
|
+
data.tar.gz: de1d3ded4f82b5d9de52c225da0a4d1aaf32d35f16ce11c614c0f27819bc89be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12d0866255dfb72862dc2268a28e6aff48cc0e3076c8e44fc633d5c5a47e5040a0f2af364611e74cbf586f6bc2039daeb36d408a36da58108fdf1207bb3a406f
|
|
7
|
+
data.tar.gz: d1335dd0ce59b5dd41caf1bcdfeca621e71dffdac984c0a0ca335dcec6c00e02e94b56bc480211b9500dee921dcba88c28ec41150e3867b15e756789b264eda0
|
data/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# ServizeHub SDK
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
Install using RubyGems:
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
gem install servizehub
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Or add it to your `Gemfile`:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem "servizehub"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Requires Ruby 2.7+. The SDK uses only the standard library (`net/http`, `uri`, `json`, `date`) —
|
|
17
|
+
no runtime dependencies.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
require "servizehub"
|
|
23
|
+
|
|
24
|
+
client = Servizehub::Client.new("encryptedkey")
|
|
25
|
+
|
|
26
|
+
response = client.send_booking(
|
|
27
|
+
date: "2026-04-15",
|
|
28
|
+
service_type: "Photography",
|
|
29
|
+
status: "available"
|
|
30
|
+
)
|
|
31
|
+
puts response
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
| Argument | Required | Default | Description |
|
|
37
|
+
| ---------- | -------- | ----------------------------------------- | -------------------------------------------- |
|
|
38
|
+
| `api_key` | Yes | — | Your ServizeHub vendor API key. |
|
|
39
|
+
| `base_url:`| No | `https://service.servizehub.com/external` | API base URL. Override to target another environment. |
|
|
40
|
+
|
|
41
|
+
### Environments
|
|
42
|
+
|
|
43
|
+
Leave `base_url:` out and the SDK talks to **production**:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
# production — https://service.servizehub.com/external
|
|
47
|
+
client = Servizehub::Client.new("vnd_live_key")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Pass `base_url:` to point the SDK at another environment, such as **dev**:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
# dev — https://servizehubuserdev.notasco.in/external
|
|
54
|
+
client = Servizehub::Client.new(
|
|
55
|
+
"vnd_test_key",
|
|
56
|
+
base_url: "https://servizehubuserdev.notasco.in/external"
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Notes:
|
|
61
|
+
|
|
62
|
+
- `base_url:` is the full base **including** the `/external` path segment. Endpoints
|
|
63
|
+
are appended to it, e.g. `#{base_url}/capture-availability`.
|
|
64
|
+
- Trailing slashes are stripped, so `.../external/` and `.../external` behave the same.
|
|
65
|
+
- The default is exposed as `Servizehub::Client::DEFAULT_BASE_URL`, and the resolved
|
|
66
|
+
value as `client.base_url`.
|
|
67
|
+
|
|
68
|
+
Keep the URL out of your source by reading it from the environment:
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
client = Servizehub::Client.new(
|
|
72
|
+
ENV.fetch("SERVIZEHUB_API_KEY"),
|
|
73
|
+
base_url: ENV["SERVIZEHUB_BASE_URL"] # nil -> production
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Methods
|
|
78
|
+
|
|
79
|
+
### `send_booking(date:, service_type:, status:)`
|
|
80
|
+
|
|
81
|
+
Sends a single availability update. `date` must be `YYYY-MM-DD` and `status` must be
|
|
82
|
+
`available` or `unavailable`. Returns `{ statusCode:, data: }`, or a validation message
|
|
83
|
+
string.
|
|
84
|
+
|
|
85
|
+
### `send_multiple_bookings(bookings)`
|
|
86
|
+
|
|
87
|
+
Sends an array of booking hashes and returns
|
|
88
|
+
`{ message:, successfulBookings:, failedBookings: }`.
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
response = client.send_multiple_bookings([
|
|
92
|
+
{ date: "2026-04-15", service_type: "Photography", status: "available" },
|
|
93
|
+
{ date: "2026-04-16", service_type: "Videography", status: "unavailable" }
|
|
94
|
+
])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tests
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
rake test
|
|
101
|
+
# or: ruby test/client_test.rb
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Uses minitest with `Net::HTTP.start` stubbed — the suite makes no network calls.
|
|
105
|
+
|
|
106
|
+
## 📩 License
|
|
107
|
+
|
|
108
|
+
Created by Notasco Dev Team
|
|
109
|
+
|
|
110
|
+
Happy Coding! 🎯
|
data/lib/servizehub/client.rb
CHANGED
|
@@ -5,15 +5,27 @@ require 'date'
|
|
|
5
5
|
|
|
6
6
|
module Servizehub
|
|
7
7
|
class Client
|
|
8
|
-
|
|
8
|
+
# Production API base URL, used when no base_url is supplied.
|
|
9
|
+
DEFAULT_BASE_URL = "https://service.servizehub.com/external"
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
attr_reader :base_url
|
|
12
|
+
|
|
13
|
+
# Omit base_url to hit production; pass it to target another
|
|
14
|
+
# environment, e.g. "https://servizehubuserdev.notasco.in/external".
|
|
15
|
+
def initialize(api_key, base_url: nil)
|
|
11
16
|
raise ArgumentError, "API key is required" if api_key.nil? || api_key.empty?
|
|
12
17
|
@api_key = api_key
|
|
18
|
+
|
|
19
|
+
resolved = base_url.nil? || base_url.empty? ? DEFAULT_BASE_URL : base_url
|
|
20
|
+
@base_url = resolved.sub(%r{/+\z}, "")
|
|
13
21
|
end
|
|
14
22
|
|
|
15
23
|
# Validate date format YYYY-MM-DD
|
|
24
|
+
# Date.strptime is lenient (it accepts "15-04-2026"), so the shape is
|
|
25
|
+
# checked with a strict regex before parsing.
|
|
16
26
|
def valid_date?(date)
|
|
27
|
+
return false unless date.is_a?(String) && date.match?(/\A\d{4}-\d{2}-\d{2}\z/)
|
|
28
|
+
|
|
17
29
|
Date.strptime(date, '%Y-%m-%d')
|
|
18
30
|
true
|
|
19
31
|
rescue ArgumentError
|
|
@@ -27,11 +39,11 @@ module Servizehub
|
|
|
27
39
|
valid_statuses = ["available", "unavailable"]
|
|
28
40
|
return "Invalid status value" unless valid_statuses.include?(status)
|
|
29
41
|
|
|
30
|
-
uri = URI.parse("#{
|
|
42
|
+
uri = URI.parse("#{@base_url}/capture-availability")
|
|
31
43
|
|
|
32
44
|
request = Net::HTTP::Post.new(uri)
|
|
33
45
|
request["Content-Type"] = "application/json"
|
|
34
|
-
request["
|
|
46
|
+
request["servizehub-api-key"] = @api_key
|
|
35
47
|
|
|
36
48
|
request.body = {
|
|
37
49
|
date: date,
|
data/lib/servizehub/version.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module Servizehub
|
|
2
|
-
VERSION = "1.0
|
|
3
|
-
end
|
|
1
|
+
module Servizehub
|
|
2
|
+
VERSION = "1.1.0"
|
|
3
|
+
end
|
metadata
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: servizehub
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hariraghav S
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: minitest
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '5.0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '5.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rake
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '13.0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '13.0'
|
|
12
40
|
description: Ruby SDK to sync data to ServizeHub.
|
|
13
41
|
executables: []
|
|
14
42
|
extensions: []
|
|
15
43
|
extra_rdoc_files: []
|
|
16
44
|
files:
|
|
45
|
+
- README.md
|
|
17
46
|
- lib/Servizehub.rb
|
|
18
47
|
- lib/servizehub/client.rb
|
|
19
48
|
- lib/servizehub/version.rb
|
|
@@ -34,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
34
63
|
- !ruby/object:Gem::Version
|
|
35
64
|
version: '0'
|
|
36
65
|
requirements: []
|
|
37
|
-
rubygems_version: 4.0.
|
|
66
|
+
rubygems_version: 4.0.16
|
|
38
67
|
specification_version: 4
|
|
39
68
|
summary: Official Ruby SDK for ServizeHub
|
|
40
69
|
test_files: []
|