rtx-api 0.6.5 → 0.6.7

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: c41a008dcb1d74712eff3591c95d85e30120441d0d754903f19d2767e8c85a3b
4
- data.tar.gz: 65ed7ac4921d37eb2e7e013da78bdd65154ca78a37021d1d7e1e219a726cd04f
3
+ metadata.gz: 8e503ec7870252f05f0a2451b574e46dec10eead92a0216cb15b1773b41ccd72
4
+ data.tar.gz: 01213d979a645793f9a94c4bf3aa3416c3b429bacf9abc7ea6c55ad66d2b3044
5
5
  SHA512:
6
- metadata.gz: e9d0803af24864c904912f9edb3c08bbe77bdabd94db1cd6c46a0b9847d6a3dd343ff0f8c0bd16de2ca3e10206f2040556859088cf3441b3a6ea21af3a5e2b4c
7
- data.tar.gz: '08d2c315eacbce3f05bef6c031432f105adacddc3ba5634be33a8172254ce15b087dcdd2df51239da278f43575950b0200c2b95072cc20bb41716403cad2ad82'
6
+ metadata.gz: ff8e3133df5c3c32dc564e43ff901a9cae17bb77059cab64c5812c08bf83fb10bcbcf5febf0025fe900f7600247d0f6e4ec4880baad6ad1d6a8fad478c2edebc
7
+ data.tar.gz: f8e9a0607ac55714bcdef2c868fc63b53895d870819b117ee3ab1dcfe136025cc84e4d200a4c7cc8c5b44722e7876b090cc0be0099ed089aa0bc48b6f767c85a
@@ -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"
@@ -47,6 +47,7 @@ module RTX
47
47
  template_tags: 'template_tags',
48
48
  urls: 'urls',
49
49
  users: 'users',
50
+ user_location_assignments: 'assignments/location',
50
51
  user_types: 'user_types',
51
52
  whitelabels: 'whitelabels',
52
53
  v2_reviews: 'v2/reviews',
@@ -54,6 +55,31 @@ module RTX
54
55
  }.freeze
55
56
  end
56
57
  # rubocop:enable Metrics/MethodLength
58
+
59
+ def self.allowed_builable_resources
60
+ {
61
+ local_search_location_reports: {
62
+ required_values: %i[account_id location_id],
63
+ resource_method: :build_local_search_location_reports_path
64
+ }
65
+ }.freeze
66
+ end
67
+
68
+ def self.build_resource(resource_name, attrs)
69
+ return unless allowed_builable_resources.key?(resource_name)
70
+
71
+ unless allowed_builable_resources[resource_name][:required_values].all? do |v|
72
+ attrs[v]
73
+ end
74
+ raise API::Errors::InvalidResourceError,
75
+ "Missing required params for (#{resource_name})"
76
+ end
77
+ send(allowed_builable_resources[resource_name][:resource_method], attrs)
78
+ end
79
+
80
+ def self.build_local_search_location_reports_path(attrs)
81
+ "local_search/#{attrs[:account_id]}/locations/#{attrs[:location_id]}/reports"
82
+ end
57
83
  end
58
84
  end
59
85
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RTX
4
4
  module API
5
- VERSION = '0.6.5'
5
+ VERSION = '0.6.7'
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.5
4
+ version: 0.6.7
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: 2024-04-23 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty