servizehub 1.0.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 +7 -0
- data/lib/Servizehub.rb +3 -0
- data/lib/servizehub/client.rb +41 -0
- data/lib/servizehub/version.rb +3 -0
- metadata +40 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2ad17f2598f80495edfdc88c5acca9ef84abd40efb3ff7aec36e37d0d4bfeb10
|
|
4
|
+
data.tar.gz: e847a02b64d205c7c72287894b9d95848395c88f1e62ae63c4ee133558e72d9e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 997207dfc4ebeae33e0859e393ee5a3ee98ab3cf471afababbfc2a080e823c956f5711c75159c29fc25d5c00e75555fa488be8381ec7d318758b287c48b0a2fc
|
|
7
|
+
data.tar.gz: 1339cfffc7b1d878c6b4099a60626d7f88c903e200d3ff1d703d2b5038a96c0ccf33c648e14ef4477541094d6802648864af77b5004bd6278026d50b26a25c7d
|
data/lib/Servizehub.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
module Servizehub
|
|
6
|
+
class Client
|
|
7
|
+
BASE_URL = "https://servizehubuserdev.notasco.in"
|
|
8
|
+
|
|
9
|
+
def initialize(api_key)
|
|
10
|
+
raise ArgumentError, "API key is required" if api_key.nil? || api_key.empty?
|
|
11
|
+
@api_key = api_key
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def send_booking(date:, service_type:, status:)
|
|
15
|
+
raise ArgumentError, "All booking details are required" if date.nil? || service_type.nil? || status.nil?
|
|
16
|
+
|
|
17
|
+
valid_statuses = ["available", "unavailable"]
|
|
18
|
+
raise ArgumentError, "Invalid status value" unless valid_statuses.include?(status)
|
|
19
|
+
|
|
20
|
+
uri = URI.parse("#{BASE_URL}/external/capture-availability")
|
|
21
|
+
request = Net::HTTP::Post.new(uri)
|
|
22
|
+
request["Content-Type"] = "application/json"
|
|
23
|
+
request["servizhub-api-key"] = @api_key
|
|
24
|
+
request.body = {
|
|
25
|
+
date: date,
|
|
26
|
+
serviceType: service_type,
|
|
27
|
+
status: status
|
|
28
|
+
}.to_json
|
|
29
|
+
|
|
30
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
31
|
+
http.request(request)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
unless response.code.to_i < 400
|
|
35
|
+
raise "Booking failed: #{response.body}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
{ message: "Booking availability sent successfully" }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: servizehub
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Hariraghav S
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Ruby SDK to sync data to ServizeHub.
|
|
13
|
+
executables: []
|
|
14
|
+
extensions: []
|
|
15
|
+
extra_rdoc_files: []
|
|
16
|
+
files:
|
|
17
|
+
- lib/Servizehub.rb
|
|
18
|
+
- lib/servizehub/client.rb
|
|
19
|
+
- lib/servizehub/version.rb
|
|
20
|
+
licenses:
|
|
21
|
+
- MIT
|
|
22
|
+
metadata: {}
|
|
23
|
+
rdoc_options: []
|
|
24
|
+
require_paths:
|
|
25
|
+
- lib
|
|
26
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
27
|
+
requirements:
|
|
28
|
+
- - ">="
|
|
29
|
+
- !ruby/object:Gem::Version
|
|
30
|
+
version: '2.7'
|
|
31
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
requirements: []
|
|
37
|
+
rubygems_version: 4.0.6
|
|
38
|
+
specification_version: 4
|
|
39
|
+
summary: Official Ruby SDK for ServizeHub
|
|
40
|
+
test_files: []
|