nilpart 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d5ed84f607d7a35d58cfb5f83a075fb0030f3b54c51929f805e25919eebc1e2a
4
+ data.tar.gz: df5aba9d1c3094f0160b78a79c4c058892a93e5651f85a0dd6b41ce9aaba6917
5
+ SHA512:
6
+ metadata.gz: 39cdc4447bd8a36000dc23ec7ffa783da7e1682d406adad1f9d887422751a6edd338b1d79e920e74056eda25df7b8335eaccb6dcb9d0773c1e49487df114e246
7
+ data.tar.gz: 5b32dba2790bcd5667bfde39447bc73079af1372729754abd97d386b139c05f386f3d78ac1bdaceb986a009b91237bbb8bff1ef7d2b3447978c0ce4894620a6c
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .idea
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+
2
+ # Nilpart USAGE
3
+
4
+ You need a Partoo.co Api-Key.
5
+
6
+ ## Initialize Nilpart
7
+
8
+ np = Nilpart::Nilpart.new({ api_key: "machin", mode: "prod" }) # mode must be 'prod' or 'sandbox'
9
+
10
+ ## Example of data returned
11
+
12
+ np.businesses_search.first.dig('businesses',0,'name') # name of business
13
+ np.businesses_search.first.dig('businesses',0,'city') # City
14
+ np.businesses_search.first.dig('businesses',0,'zipcode') # Postcode
15
+ np.businesses_search.first.dig('businesses',0,'address2')
16
+ np.businesses_search.first.dig('businesses',0,'address_details','street_type')
17
+ np.businesses_search.first.dig('businesses',0,'address_details','street_name')
18
+ np.businesses_search.first.dig('businesses',0,'contacts',0,'phone_numbers')
19
+ np.businesses_search.first.dig('businesses',0,'contacts',0,'email')
20
+
21
+ ## Open hours
22
+
23
+ np.businesses_search.first.dig('businesses',0,'open_hours')
24
+ np.businesses_search.first.dig('businesses',0,'open_hours','monday')
25
+ np.businesses_search.first.dig('businesses',0,'open_hours','tuesday')
26
+ np.businesses_search.first.dig('businesses',0,'open_hours','wednesday')
27
+ np.businesses_search.first.dig('businesses',0,'open_hours','thursday')
28
+ np.businesses_search.first.dig('businesses',0,'open_hours','friday')
29
+ np.businesses_search.first.dig('businesses',0,'open_hours','saturday')
30
+ np.businesses_search.first.dig('businesses',0,'open_hours','sunday')
31
+
32
+ ## More ?
33
+
@@ -0,0 +1,454 @@
1
+ require_relative './version'
2
+ require 'faraday'
3
+ require 'json'
4
+
5
+ module Nilpart
6
+ class Nilpart
7
+ PRODUCTION_SERVER = "https://api.partoo.co/v2/"
8
+ SANDBOX_SERVER = "https://sandbox.api.partoo.co/v2/"
9
+
10
+ attr_accessor :my_api_key
11
+ attr_accessor :production # prod / sandbox
12
+
13
+ #
14
+ # +api_key+ your api_key
15
+ # +mode+ "prod" for production / "sandbox" for sandbox
16
+ #
17
+ def initialize(params)
18
+ @my_api_key = params[:api_key]
19
+
20
+ raise ':api_key is required !' if @my_api_key.to_s.empty?
21
+ raise ':mode params must be "prod" or "sandbox"' unless ['prod', 'sandbox'].include?(params[:mode])
22
+
23
+ @production = params[:mode].to_s == 'prod'
24
+ end
25
+
26
+ def server_url
27
+ @production ? PRODUCTION_SERVER : SANDBOX_SERVER
28
+ end
29
+
30
+ def get_request(path, params = {})
31
+ response = Faraday.get("#{self.server_url}#{path}", params, { 'x-APIKey' => @my_api_key })
32
+ if response.status != 200 # Faraday has not constante for status 200
33
+ puts "#{__method__} : Path => #{path} : Status => #{response.status}"
34
+ end
35
+ return JSON.parse(response.body)
36
+ end
37
+
38
+ def delete_request(path, params = {})
39
+ response = Faraday.delete("#{self.server_url}#{path}", params, { 'x-APIKey' => @my_api_key })
40
+ if response.status != 200 # Faraday has not constante for status 200
41
+ puts "#{__method__} : Path => #{path} : Status => #{response.status}"
42
+ end
43
+ return JSON.parse(response.body)
44
+ end
45
+
46
+ def post_request(path, body = {})
47
+ response = Faraday.post("#{self.server_url}#{path}", body.to_json, { 'x-APIKey' => @my_api_key, "Content-Type" => "application/json" })
48
+ if response.status != 200 # Faraday has not constante for status 200
49
+ puts "#{__method__} : Path => #{path} : Status => #{response.status}"
50
+ end
51
+ return JSON.parse(response.body)
52
+ end
53
+
54
+ def put_request(path, body = {})
55
+ response = Faraday.put("#{self.server_url}#{path}", body.to_json, { 'x-APIKey' => @my_api_key, "Content-Type" => "application/json" })
56
+ if response.status != 200 # Faraday has not constante for status 200
57
+ puts "#{__method__} : Path => #{path} : Status => #{response.status}"
58
+ end
59
+ return JSON.parse(response.body)
60
+ end
61
+
62
+ ##########################################
63
+ ##########################################
64
+ # Map Partoo RestAPI #
65
+ ##########################################
66
+ ##########################################
67
+
68
+ ##############
69
+ # Api-Key
70
+ ##############
71
+
72
+ def api_keys(params = {})
73
+ get_request('api_keys', params)
74
+ end
75
+
76
+ def api_key_get(id)
77
+ get_request("api_keys/#{id}")
78
+ end
79
+
80
+ def api_key_update(id, params = {})
81
+ put_request("api_keys/#{id}", params)
82
+ end
83
+
84
+ def api_key_revoke(id)
85
+ post_request("api_keys/revoke/#{id}")
86
+ end
87
+
88
+ ####################
89
+ # Connection Tokens
90
+ ####################
91
+
92
+ def connection_generate_token(params = {})
93
+ post_request("connection/generate_token", params)
94
+ end
95
+
96
+ def connection_revoke_token(params = {})
97
+ post_request("connection/revoke_token", params)
98
+ end
99
+
100
+ def connection_check_token(params = {})
101
+ get_request("connection/check_token", params)
102
+ end
103
+
104
+ ####################
105
+ # ORGANISATION
106
+ ####################
107
+
108
+ def organisation_search(params = {})
109
+ get_request("org/search", params)
110
+ end
111
+
112
+ def organisation_get(id)
113
+ get_request("org/#{id}")
114
+ end
115
+
116
+ def organisation_create(params = {})
117
+ post_request("org", params)
118
+ end
119
+
120
+ def organisation_update(id, params = {})
121
+ post_request("org/#{id}", params)
122
+ end
123
+
124
+ def organisation_delete(id, params = {})
125
+ delete_request("org/#{id}", params)
126
+ end
127
+
128
+ ################
129
+ # BUSINESS
130
+ ################
131
+
132
+ def businesses_search(params = {})
133
+ get_request("business/search", params)
134
+ end
135
+
136
+ def business_create(params = {})
137
+ post_request("business", params)
138
+ end
139
+
140
+ def business_connections_stats
141
+ get_request("business/connections_stats")
142
+ end
143
+
144
+ def business_get(id)
145
+ get_request("business/#{id}")
146
+ end
147
+
148
+ def business_update(id, params = {})
149
+ post_request("business/#{id}", params)
150
+ end
151
+
152
+ def business_delete(id)
153
+ delete_request("business/#{id}")
154
+ end
155
+
156
+ def business_partner_urls(id)
157
+ get_request("business/#{id}/partner_urls")
158
+ end
159
+
160
+ def business_integration_data(id)
161
+ get_request("business/#{id}/integration_status")
162
+ end
163
+
164
+ def business_subscription(id)
165
+ get_request("business/#{id}/subscription")
166
+ end
167
+
168
+ def business_get_additional_data(id)
169
+ get_request("business/#{id}/additional_data")
170
+ end
171
+
172
+ def business_set_additional_data(id, params = {})
173
+ post_request("business/#{id}/additional_data", params)
174
+ end
175
+
176
+ def business_get_google_attributes(id, params = {})
177
+ get_request("business/#{id}/attributes", params)
178
+ end
179
+
180
+ def business_set_google_attributes(id, params = {})
181
+ post_request("business/#{id}/attributes", params)
182
+ end
183
+
184
+ ##################
185
+ # Business Fields
186
+ ##################
187
+
188
+ def business_fields_for_business(id)
189
+ get_request("business/#{id}/business_fields")
190
+ end
191
+ alias business_get_business_fields business_fields_for_business
192
+
193
+ def business_fields_for_organization(id)
194
+ get_request("business/#{id}/business_fields")
195
+ end
196
+ alias organization_get_business_fields business_fields_for_organization
197
+
198
+ def business_fields_for_provider(id)
199
+ get_request("business/#{id}/business_fields")
200
+ end
201
+ alias provider_get_business_fields business_fields_for_provider
202
+
203
+ ##################
204
+ # Users
205
+ ##################
206
+
207
+ def user_me
208
+ get_request("user/me")
209
+ end
210
+
211
+ def user_create(params = {})
212
+ post_request("user", params)
213
+ end
214
+
215
+ def user_get(id)
216
+ get_request("user/#{id}")
217
+ end
218
+
219
+ def user_update(id, params = {})
220
+ post_request("user/#{id}", params)
221
+ end
222
+
223
+ def user_delete(id, params = {})
224
+ delete_request("user/#{id}", params)
225
+ end
226
+
227
+ def users_search(params = {})
228
+ get_request("user/search", params)
229
+ end
230
+
231
+ def users_count(params = {})
232
+ get_request("user/search/count", params)
233
+ end
234
+
235
+ def user_reinvite(id)
236
+ post_request("user/#{id}/invite")
237
+ end
238
+
239
+ def user_get_businesses(id)
240
+ get_request("user/#{id}/businesses")
241
+ end
242
+
243
+ ###############
244
+ # Groups
245
+ ###############
246
+
247
+ def groups_get
248
+ get_request("groups")
249
+ end
250
+
251
+ def group_create(params = {})
252
+ post_request("groups", params)
253
+ end
254
+
255
+ def group_get(id)
256
+ get_request("groups/#{id}")
257
+ end
258
+
259
+ def group_update(id, params = {})
260
+ put_request("groups/#{id}", params)
261
+ end
262
+
263
+ def group_delete(id)
264
+ delete_request("groups/#{id}")
265
+ end
266
+
267
+ def group_get_businesses(id)
268
+ get_request("groups/#{id}/businesses")
269
+ end
270
+
271
+ def group_manage_businesses(id, params = {})
272
+ put_request("groups/#{id}/businesses", params)
273
+ end
274
+
275
+ #################
276
+ # Subscriptions
277
+ #################
278
+
279
+ def subscribe_a_business(id)
280
+ post_request("business/#{id}/subscribe")
281
+ end
282
+ alias business_subscribe subscribe_a_business
283
+
284
+ def unsubscribe_a_business(id)
285
+ post_request("business/#{id}/unsubscribe")
286
+ end
287
+ alias business_unsubscribe unsubscribe_a_business
288
+
289
+ ##################
290
+ # Reviews
291
+ ##################
292
+
293
+ def reviews_search(params = {})
294
+ get_request("reviews", params)
295
+ end
296
+
297
+ def review_post_a_reply(params = {})
298
+ post_request("comments", params)
299
+ end
300
+
301
+ def review_modify_a_reply(id, params = {})
302
+ put_request("comments/#{id}", params)
303
+ end
304
+
305
+ def review_delete_a_reply(id)
306
+ delete_request("comments/#{id}")
307
+ end
308
+
309
+ ##################
310
+ # Reply templates
311
+ ##################
312
+
313
+ def reply_templates_search(params = {})
314
+ get_request("reviews/templates/search", params)
315
+ end
316
+
317
+ def reply_template_create(params = {})
318
+ post_request("reviews/template", params)
319
+ end
320
+
321
+ def reply_template_delete(id)
322
+ delete_request("reviews/template/#{id}")
323
+ end
324
+
325
+ def reply_templates_placeholders
326
+ get_request("reviews/templates/placeholders")
327
+ end
328
+
329
+ ####################
330
+ # Reviews Analytics
331
+ ####################
332
+
333
+ def reviews_statistics(params = {})
334
+ get_request("reviews/stats", params)
335
+ end
336
+
337
+ def reviews_qualitative_evolution(params = {})
338
+ get_request("reviews/qualitative-evolution", params)
339
+ end
340
+
341
+ def reviews_quantitative_evolution(params = {})
342
+ get_request("reviews/quantitative-evolution", params)
343
+ end
344
+
345
+ ####################
346
+ # Categories
347
+ ####################
348
+
349
+ def category_get(id, params = {})
350
+ get_request("category/#{id}", params)
351
+ end
352
+
353
+ def category_get(params = {})
354
+ get_request("categories", params)
355
+ end
356
+
357
+ #####################
358
+ # Address ??
359
+ #####################
360
+
361
+ #####################
362
+ # Boosts
363
+ #####################
364
+
365
+ def boost_send_invitation(params = {})
366
+ post_request("review_booster/send_invitation", params)
367
+ end
368
+
369
+ def boost_invitation_status(params = {})
370
+ get_request("review_booster/invitation_status", params)
371
+ end
372
+
373
+ def boost_invitation_search(params = {})
374
+ get_request("review_booster/search-invitation", params)
375
+ end
376
+
377
+ #####################
378
+ # Presence
379
+ #####################
380
+
381
+ def presence_business_info(params = {})
382
+ get_request("publisher_states/business_info", params)
383
+ end
384
+
385
+ def presence_businesses_info(params = {})
386
+ get_request("publisher_states/businesses_info", params)
387
+ end
388
+
389
+ #####################
390
+ # Presence analytics
391
+ #####################
392
+
393
+ def presence_analytics_get(params = {})
394
+ get_request("presence_analytics", params)
395
+ end
396
+
397
+ def presence_analytics_export(params = {})
398
+ get_request("presence_analytics_export", params)
399
+ end
400
+
401
+ #####################
402
+ # Google post
403
+ #####################
404
+
405
+ def google_posts_search(params = {})
406
+ get_request("google_posts", params)
407
+ end
408
+
409
+ def google_post_create(params = {})
410
+ post_request("google_posts", params)
411
+ end
412
+
413
+ def google_post_get(id)
414
+ get_request("google_posts/#{id}")
415
+ end
416
+
417
+ def google_post_update(id, params = {})
418
+ put_request("google_posts/#{id}", params)
419
+ end
420
+
421
+ def google_post_delete(id)
422
+ delete_request("google_posts/#{id}")
423
+ end
424
+
425
+ #####################
426
+ # Custom Fields
427
+ #####################
428
+
429
+ def custom_field_create(params = {})
430
+ post_request("custom_fields", params)
431
+ end
432
+
433
+ def custom_field_update(id, params = {})
434
+ put_request("custom_fields/#{id}", params)
435
+ end
436
+
437
+ def custom_field_delete(id)
438
+ delete_request("custom_fields/#{id}")
439
+ end
440
+
441
+ def custom_fields_order(params = {})
442
+ post_request("custom_fields/order", params)
443
+ end
444
+
445
+ #####################
446
+ # GMB Attributes
447
+ #####################
448
+
449
+ def gmb_attributes_list(params = {})
450
+ get_request("attributes/list", params)
451
+ end
452
+
453
+ end
454
+ end
@@ -0,0 +1,3 @@
1
+ module Nilpart
2
+ VERSION = "1.0.0"
3
+ end
data/nilpart.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ require_relative "lib/nilpart/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'nilpart'
5
+ s.version = Nilpart::VERSION
6
+ s.summary = "Partoo RestApi Connector"
7
+ s.description = "Nilpart allow you to connect to Partoo RestAPI !"
8
+ s.authors = ["Sylvain Claudel"]
9
+ s.email = 'claudel.sylvain@gmail.com'
10
+
11
+ all_files = `git ls-files`.split("\n").reject{ |filepath| filepath.start_with? 'test/' }
12
+ s.files = all_files
13
+
14
+ s.require_paths = ["lib/nilpart"]
15
+
16
+ s.homepage = 'https://rubygems.org/gems/nilpart'
17
+ s.license = 'MIT'
18
+
19
+ s.add_runtime_dependency("faraday")
20
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nilpart
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sylvain Claudel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Nilpart allow you to connect to Partoo RestAPI !
28
+ email: claudel.sylvain@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".gitignore"
34
+ - README.md
35
+ - lib/nilpart/nilpart.rb
36
+ - lib/nilpart/version.rb
37
+ - nilpart.gemspec
38
+ homepage: https://rubygems.org/gems/nilpart
39
+ licenses:
40
+ - MIT
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib/nilpart
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.1.4
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Partoo RestApi Connector
61
+ test_files: []