fantasticstay_api 0.1.10 → 0.1.12

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: cf9be90bc43b625d86fc4f6a024a4031af806d435b7328499a88e24001d10b4d
4
- data.tar.gz: '09745920add5e1e3c4ca23997b1ca75bf8a8e82ccd7b7bda24cf4ca7cacfa33c'
3
+ metadata.gz: 61c7c8e9ac360e9a4b64ec4813ff0b3da4f9ed73b6c8b89298208ae937a65f66
4
+ data.tar.gz: 527e2dde65e7533e466dfb94016fedea3ce17cd815471f7fd6cf945a3c06f7bb
5
5
  SHA512:
6
- metadata.gz: 98c7479b0c84b51e96dce10274f338ba069c7952bfc977f26af804a51a8b5bb36e58192ccbcc4acdb2ca8fbaaacd8009178c801837eda640fbcde8c95112e780
7
- data.tar.gz: 64dcd5e2faf0138e51a6544ae20c04519c143c3ee010dbf11548611c72b51ef7ddc10cc1bd60d2fe391ccb9593162eb6cb9d7d0d6545e1d869d8069075b3316a
6
+ metadata.gz: 27d89ebc3deb1b633cd32a3024d01641552e46fb2d7000d6c7212b5431b4e80cba979c7069d1a1f5462a9697b1c62221b7c1de66e174704bdaab91a1ff36651a
7
+ data.tar.gz: 33cabc72170bdb2fae13a0e76939f6e9f1ad33b2a8d9bb0040565b31d1c8abdf067c6b15da87ca505ba70f6c4e54a8f19024271405442a76306f83c8ab7b3e6a
data/.gitignore CHANGED
@@ -16,3 +16,5 @@ fantasticstay_api.iml
16
16
 
17
17
  # custom ignores
18
18
  .env
19
+ *.gem
20
+ /.irb_history
data/.irbrc ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'irb'
4
+ require 'irb/completion'
5
+ require 'rubygems'
6
+ require 'pp'
7
+ IRB.conf[:SAVE_HISTORY] = 500
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fantasticstay_api (0.1.9)
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)
@@ -16,7 +16,7 @@ GEM
16
16
  ast (2.4.2)
17
17
  base64 (0.2.0)
18
18
  bigdecimal (3.1.9)
19
- concurrent-ruby (1.3.4)
19
+ concurrent-ruby (1.3.5)
20
20
  crack (1.0.0)
21
21
  bigdecimal
22
22
  rexml
data/docker-compose.yml CHANGED
@@ -1,7 +1,6 @@
1
- version: "3.9"
2
1
  services:
3
2
  app:
4
3
  build: .
5
4
  command: bash -c "rake"
6
5
  volumes:
7
- - .:/usr/src/app
6
+ - .:/usr/src/app
@@ -95,14 +95,17 @@ module FantasticstayApi
95
95
  client.headers['User-Agent'] = config.user_agent
96
96
  end
97
97
 
98
- def request(http_method:, endpoint:, params: {}, cache_ttl: 3600)
98
+ def request(http_method:, endpoint:, params: {}, body: {}, cache_ttl: 3600)
99
99
  response = APICache.get(
100
- 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,
101
101
  cache: cache_ttl,
102
102
  valid: config.stale_validity,
103
103
  timeout: config.timeout
104
104
  ) do
105
- client.public_send(http_method, endpoint, params)
105
+ client.public_send(http_method, endpoint) do |req|
106
+ req.params = params
107
+ req.body = body.to_json if body.size
108
+ end
106
109
  end
107
110
 
108
111
  process_http_response(response)
@@ -42,14 +42,14 @@ module FantasticstayApi
42
42
  end
43
43
 
44
44
  # FantasticstayApi::Client.new.reservations(38859)
45
- def reservations(listing_id, filters = [], sort = { order: 'checkIn', direction: 'desc' }, global_params = {})
45
+ def reservations(listing_id, filters = [], sort = { order: 'checkIn', direction: 'desc' }, global_params = {}, cache_ttl = 3600 * 24)
46
46
  response = request(
47
47
  http_method: :get,
48
48
  endpoint: 'reservations',
49
49
  params: {
50
50
  listing_id: listing_id, filters: filters.to_json, sort: sort[:order], direction: sort[:direction]
51
51
  }.merge!(global_params),
52
- cache_ttl: 3600 * 24
52
+ cache_ttl: cache_ttl
53
53
  )
54
54
  process_response(response)
55
55
  end
@@ -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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FantasticstayApi
4
- VERSION = '0.1.10'.freeze
4
+ VERSION = '0.1.12'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fantasticstay_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dinis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-14 00:00:00.000000000 Z
11
+ date: 2025-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_cache
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".github/workflows/main.yml"
77
77
  - ".gitignore"
78
+ - ".irbrc"
78
79
  - ".rspec"
79
80
  - ".rubocop.yml"
80
81
  - CHANGELOG.md
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  - !ruby/object:Gem::Version
120
121
  version: '0'
121
122
  requirements: []
122
- rubygems_version: 3.3.26
123
+ rubygems_version: 3.5.22
123
124
  signing_key:
124
125
  specification_version: 4
125
126
  summary: FantasticStay API Wrapper.