rtx-api 0.6.4 → 0.6.6

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: b345317b29f9a774fd308ba1c37ef496248d129b1363a187510b0da2d94cde8f
4
- data.tar.gz: 8e996e7386cf9b7264eefdf061c21d3f648ac252bc057957996057a62be9b4ef
3
+ metadata.gz: 408b8a58e0ff9761a884d58ef645a46a4ce9a620734dcbb715ecbdba8701b4df
4
+ data.tar.gz: 6b50a573f9ceeed9def34a0d681a4fb62f2e29912194f550a17a5ce041ac76f1
5
5
  SHA512:
6
- metadata.gz: 854d2745236c8e5b2be8c3bc4011573c0176fc67061806e52d8afe1526ca6e06df5af88a36987d26f6b27d8e7aed1737a5ed942bc85e3e212cc508456de47c2c
7
- data.tar.gz: 8c00c5bb192f82276126eae49480d65403c0425ec2c7c385d2981279609db6e88a4d3952c869b87585b2ffd8b1e86d2eddc9a750babe6011d6891f4eee5643cf
6
+ metadata.gz: 4407961c6508c5ca6c38fd541753aaf951e7288b77206057cd89dc5beeb1d265a369b23c255329beb6d184189a3c3edc5978f8fbd86bf442174daf3fc26d1a56
7
+ data.tar.gz: 1aac284d6c4c4b7b66ad473aef3918e21e20024d68268b859b4ba65efa47704395a1ed35bfb173d43dd884caa7881f4206bdae047eab2e815c9f244de400c8cf
@@ -77,7 +77,7 @@ module RTX
77
77
  # rubocop:disable Style/MissingRespondToMissing
78
78
  # rubocop:disable Style/MethodMissingSuper
79
79
  def method_missing(method, *args)
80
- return unless resource_path(method)
80
+ return unless allowed_resource?(method)
81
81
 
82
82
  attrs = {}
83
83
  if args.size.positive?
@@ -93,6 +93,16 @@ module RTX
93
93
  # rubocop:enable Style/MethodMissingSuper
94
94
  # rubocop:enable Lint/RedundantCopDisableDirective
95
95
 
96
+ def allowed_resource?(method)
97
+ unless API::Resources.allowed_resources[method.to_sym] ||
98
+ API::Resources.allowed_builable_resources.key?(method.to_sym)
99
+ raise API::Errors::InvalidResourceError,
100
+ "The resource provided (#{method}) is not allowed"
101
+ end
102
+
103
+ true
104
+ end
105
+
96
106
  def collection(resource_name, attrs = {})
97
107
  request = self.class.get("#{rtx_api_url}/#{resource_path(resource_name)}",
98
108
  options(:get, attrs))
@@ -108,7 +118,7 @@ module RTX
108
118
  end
109
119
 
110
120
  def post(resource_name, attrs = {})
111
- request = self.class.post("#{rtx_api_url}/#{resource_path(resource_name)}",
121
+ request = self.class.post("#{rtx_api_url}/#{resource_path(resource_name, attrs)}",
112
122
  options(:post, attrs))
113
123
  handle_request(request)
114
124
  end
@@ -158,8 +168,10 @@ module RTX
158
168
  end
159
169
  end
160
170
 
161
- def resource_path(resource_name)
171
+ def resource_path(resource_name, attrs = {})
162
172
  path = API::Resources.allowed_resources[resource_name.to_sym]
173
+ path ||= API::Resources.build_resource(resource_name.to_sym, attrs)
174
+
163
175
  if !path
164
176
  raise API::Errors::InvalidResourceError,
165
177
  "The resource provided (#{resource_name}) is not allowed"
@@ -18,6 +18,7 @@ module RTX
18
18
  contacts: 'contacts',
19
19
  countries: 'countries',
20
20
  crawlers: 'crawlers',
21
+ google_posts: 'google_posts',
21
22
  groups: 'groups',
22
23
  keywords: 'insights/keywords',
23
24
  items: 'items',
@@ -53,6 +54,31 @@ module RTX
53
54
  }.freeze
54
55
  end
55
56
  # rubocop:enable Metrics/MethodLength
57
+
58
+ def self.allowed_builable_resources
59
+ {
60
+ local_search_location_reports: {
61
+ required_values: %i[account_id location_id],
62
+ resource_method: :build_local_search_location_reports_path
63
+ }
64
+ }.freeze
65
+ end
66
+
67
+ def self.build_resource(resource_name, attrs)
68
+ return unless allowed_builable_resources.key?(resource_name)
69
+
70
+ unless allowed_builable_resources[resource_name][:required_values].all? do |v|
71
+ attrs[v]
72
+ end
73
+ raise API::Errors::InvalidResourceError,
74
+ "Missing required params for (#{resource_name})"
75
+ end
76
+ send(allowed_builable_resources[resource_name][:resource_method], attrs)
77
+ end
78
+
79
+ def self.build_local_search_location_reports_path(attrs)
80
+ "local_search/#{attrs[:account_id]}/locations/#{attrs[:location_id]}/reports"
81
+ end
56
82
  end
57
83
  end
58
84
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RTX
4
4
  module API
5
- VERSION = '0.6.4'
5
+ VERSION = '0.6.6'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtx-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Review Trackers Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-14 00:00:00.000000000 Z
11
+ date: 2024-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty