fantasticstay_api 0.1.8 → 0.1.11
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/.gitignore +2 -0
- data/.irbrc +7 -0
- data/Gemfile.lock +12 -12
- data/docker-compose.yml +1 -2
- data/lib/fantasticstay_api/api.rb +20 -7
- data/lib/fantasticstay_api/client.rb +44 -0
- data/lib/fantasticstay_api/version.rb +1 -1
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc5c5fa20b06a9c957ecc4fff66c82404c60e7f08826e9d99218d0a491064ad9
|
4
|
+
data.tar.gz: d72c3cdba569e622a600681e18b35263d0bfaebba294187b5ebb2d255d8f5aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e3c76f33cc3691855e87ae24fd758268802b6819b3e38f74a4841dbaac79ca26fe407c46a9c1b207ad6f2052bba7762bcf0cf36388bc975ca3089629355a6c
|
7
|
+
data.tar.gz: 91911d1412ceb3a9ab46c853936edbe8e0d70cabc74f84e7cbbfe5ae40b2c18c2c2d4ca01098f23bbf08377dd05786f8f8ae286447ea90a0e254b39341d339cf
|
data/.gitignore
CHANGED
data/.irbrc
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fantasticstay_api (0.1.
|
4
|
+
fantasticstay_api (0.1.10)
|
5
5
|
api_cache (~> 0.3.0)
|
6
6
|
dry-configurable (~> 0.13)
|
7
7
|
faraday (~> 2.6.0)
|
@@ -15,8 +15,8 @@ GEM
|
|
15
15
|
api_cache (0.3.0)
|
16
16
|
ast (2.4.2)
|
17
17
|
base64 (0.2.0)
|
18
|
-
bigdecimal (3.1.
|
19
|
-
concurrent-ruby (1.3.
|
18
|
+
bigdecimal (3.1.9)
|
19
|
+
concurrent-ruby (1.3.5)
|
20
20
|
crack (1.0.0)
|
21
21
|
bigdecimal
|
22
22
|
rexml
|
@@ -31,26 +31,26 @@ GEM
|
|
31
31
|
faraday-net_http (>= 2.0, < 3.1)
|
32
32
|
ruby2_keywords (>= 0.0.4)
|
33
33
|
faraday-net_http (3.0.2)
|
34
|
-
hashdiff (1.1.
|
35
|
-
oj (3.16.
|
34
|
+
hashdiff (1.1.2)
|
35
|
+
oj (3.16.9)
|
36
36
|
bigdecimal (>= 3.0)
|
37
37
|
ostruct (>= 0.2)
|
38
|
-
ostruct (0.6.
|
38
|
+
ostruct (0.6.1)
|
39
39
|
parallel (1.26.3)
|
40
|
-
parser (3.3.
|
40
|
+
parser (3.3.6.0)
|
41
41
|
ast (~> 2.4.1)
|
42
42
|
racc
|
43
43
|
public_suffix (6.0.1)
|
44
44
|
racc (1.8.1)
|
45
45
|
rainbow (3.1.1)
|
46
46
|
rake (13.2.1)
|
47
|
-
regexp_parser (2.
|
48
|
-
rexml (3.
|
47
|
+
regexp_parser (2.10.0)
|
48
|
+
rexml (3.4.0)
|
49
49
|
rspec (3.13.0)
|
50
50
|
rspec-core (~> 3.13.0)
|
51
51
|
rspec-expectations (~> 3.13.0)
|
52
52
|
rspec-mocks (~> 3.13.0)
|
53
|
-
rspec-core (3.13.
|
53
|
+
rspec-core (3.13.2)
|
54
54
|
rspec-support (~> 3.13.0)
|
55
55
|
rspec-expectations (3.13.3)
|
56
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
rspec-mocks (3.13.2)
|
59
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
60
60
|
rspec-support (~> 3.13.0)
|
61
|
-
rspec-support (3.13.
|
61
|
+
rspec-support (3.13.2)
|
62
62
|
rubocop (0.93.1)
|
63
63
|
parallel (~> 1.10)
|
64
64
|
parser (>= 2.7.1.5)
|
@@ -68,7 +68,7 @@ GEM
|
|
68
68
|
rubocop-ast (>= 0.6.0)
|
69
69
|
ruby-progressbar (~> 1.7)
|
70
70
|
unicode-display_width (>= 1.4.0, < 2.0)
|
71
|
-
rubocop-ast (1.
|
71
|
+
rubocop-ast (1.37.0)
|
72
72
|
parser (>= 3.3.1.0)
|
73
73
|
ruby-progressbar (1.13.0)
|
74
74
|
ruby2_keywords (0.0.5)
|
data/docker-compose.yml
CHANGED
@@ -24,7 +24,8 @@ module FantasticstayApi
|
|
24
24
|
'default' => ApiError
|
25
25
|
}.freeze
|
26
26
|
API_ENDPOINT = 'https://api.fsapp.io'
|
27
|
-
API_TIMEOUT =
|
27
|
+
API_TIMEOUT = 5 # API response timeout
|
28
|
+
API_STALE_VALIDITY = :forever # 604800 = 7 days - Maximum time to use old data
|
28
29
|
API_TOKEN = 'TESTING'
|
29
30
|
|
30
31
|
setting :follow_redirects, default: true
|
@@ -35,6 +36,9 @@ module FantasticstayApi
|
|
35
36
|
# The timeout in requests made to fsapp
|
36
37
|
setting :timeout, default: ENV['FANTASTICSTAY_API_TIMEOUT'] || API_TIMEOUT, reader: true
|
37
38
|
|
39
|
+
# The stale validity in requests that fail to fsapp
|
40
|
+
setting :stale_validity, default: ENV['FANTASTICSTAY_API_STALE_VALIDITY'] || API_STALE_VALIDITY, reader: true
|
41
|
+
|
38
42
|
# The token included in request header 'x-api-key'
|
39
43
|
setting :token, default: ENV['FANTASTICSTAY_API_TOKEN'] || API_TOKEN, reader: true
|
40
44
|
|
@@ -78,21 +82,30 @@ module FantasticstayApi
|
|
78
82
|
@client ||= Faraday.new(config.endpoint) do |client|
|
79
83
|
client.request :url_encoded
|
80
84
|
client.adapter Faraday.default_adapter
|
81
|
-
client.headers['Content-Type'] = 'application/json'
|
82
|
-
client.headers['x-api-key'] = config.token
|
83
|
-
client.headers['User-Agent'] = config.user_agent
|
84
85
|
client.options.timeout = config.timeout
|
86
|
+
init_client_headers(client)
|
85
87
|
client.response :raise_error # raise Faraday::Error on status code 4xx or 5xx
|
88
|
+
client.response :logger, ::Logger.new($stdout), body: true, bodies: { request: true, response: true }
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
89
|
-
def
|
92
|
+
def init_client_headers(client)
|
93
|
+
client.headers['Content-Type'] = 'application/json'
|
94
|
+
client.headers['x-api-key'] = config.token
|
95
|
+
client.headers['User-Agent'] = config.user_agent
|
96
|
+
end
|
97
|
+
|
98
|
+
def request(http_method:, endpoint:, params: {}, body: {}, cache_ttl: 3600)
|
90
99
|
response = APICache.get(
|
91
|
-
Digest::SHA256.bubblebabble(config.token) + http_method.to_s + endpoint + params.to_s,
|
100
|
+
Digest::SHA256.bubblebabble(config.token) + http_method.to_s + endpoint + params.to_s + body.to_s,
|
92
101
|
cache: cache_ttl,
|
102
|
+
valid: config.stale_validity,
|
93
103
|
timeout: config.timeout
|
94
104
|
) do
|
95
|
-
client.public_send(http_method, endpoint
|
105
|
+
client.public_send(http_method, endpoint) do |req|
|
106
|
+
req.params = params
|
107
|
+
req.body = body.to_json if body.size
|
108
|
+
end
|
96
109
|
end
|
97
110
|
|
98
111
|
process_http_response(response)
|
@@ -63,6 +63,50 @@ module FantasticstayApi
|
|
63
63
|
process_response(response)
|
64
64
|
end
|
65
65
|
|
66
|
+
def custom_fields(global_params = {})
|
67
|
+
response = request(
|
68
|
+
http_method: :get,
|
69
|
+
endpoint: "custom_fields",
|
70
|
+
params: global_params
|
71
|
+
)
|
72
|
+
process_response(response)
|
73
|
+
end
|
74
|
+
|
75
|
+
def reservation_set_custom_field_value(reservation_id, custom_field_id, value, global_params: {})
|
76
|
+
response = request(
|
77
|
+
http_method: :post,
|
78
|
+
endpoint: "reservations/custom_field_update",
|
79
|
+
params: global_params ,
|
80
|
+
body: {
|
81
|
+
reservation_id: reservation_id,
|
82
|
+
custom_field_id: custom_field_id,
|
83
|
+
value: value,
|
84
|
+
}
|
85
|
+
)
|
86
|
+
process_response(response)
|
87
|
+
end
|
88
|
+
|
89
|
+
def set_custom_field_value(id, value, listing_ids: [], reservation_ids: [], global_params: {})
|
90
|
+
response = request(
|
91
|
+
http_method: :post,
|
92
|
+
endpoint: "custom_fields/set_values",
|
93
|
+
params: {
|
94
|
+
custom_field_id: id,
|
95
|
+
# value: value,
|
96
|
+
# listing_ids: listing_ids.to_json,
|
97
|
+
# reservation_ids: reservation_ids.to_json
|
98
|
+
}.merge!(global_params),
|
99
|
+
body: {
|
100
|
+
value: value,
|
101
|
+
listing_ids: listing_ids,
|
102
|
+
reservation_ids: reservation_ids
|
103
|
+
# listing_ids: "{\"listing_ids\":[#{listing_ids.join(',')}]}",
|
104
|
+
# reservation_ids: "{\"reservation_ids\":[#{reservation_ids.join(',')}]}"
|
105
|
+
},
|
106
|
+
)
|
107
|
+
process_response(response)
|
108
|
+
end
|
109
|
+
|
66
110
|
def guest(guest_id, global_params = {})
|
67
111
|
response = request(
|
68
112
|
http_method: :get,
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fantasticstay_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dinis
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-08-10 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: api_cache
|
@@ -75,6 +74,7 @@ extra_rdoc_files: []
|
|
75
74
|
files:
|
76
75
|
- ".github/workflows/main.yml"
|
77
76
|
- ".gitignore"
|
77
|
+
- ".irbrc"
|
78
78
|
- ".rspec"
|
79
79
|
- ".rubocop.yml"
|
80
80
|
- CHANGELOG.md
|
@@ -104,7 +104,6 @@ metadata:
|
|
104
104
|
homepage_uri: https://github.com/dlage/fantasticstay_api_gem
|
105
105
|
source_code_uri: https://github.com/dlage/fantasticstay_api_gem
|
106
106
|
changelog_uri: https://github.com/dlage/fantasticstay_api_gem/blob/master/CHANGELOG.md
|
107
|
-
post_install_message:
|
108
107
|
rdoc_options: []
|
109
108
|
require_paths:
|
110
109
|
- lib
|
@@ -119,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
118
|
- !ruby/object:Gem::Version
|
120
119
|
version: '0'
|
121
120
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
-
signing_key:
|
121
|
+
rubygems_version: 3.6.2
|
124
122
|
specification_version: 4
|
125
123
|
summary: FantasticStay API Wrapper.
|
126
124
|
test_files: []
|