emarsys_suite_services_api_client 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: e43ed0cc981eb2ed6e1d906f110415d3e8cf256f
4
- data.tar.gz: 13d3c2227336fc0e3889a4efbd0b28a8913e1150
3
+ metadata.gz: dbb78821408b2802dc4f34b7e31f5c74cc09cf5a
4
+ data.tar.gz: d9e8e20fe46eb04408a56e841c081507ec481334
5
5
  SHA512:
6
- metadata.gz: 97dab3bf13dfc75fe086f0b6b1b2c9380599811fc0ed91d7e943c6e334cd09c3511d5c627ac73829b00598983c8069ae0546581cad03567b16379a459170f446
7
- data.tar.gz: f4b70d546453be6ea28bd5c6d43198133b645c6d9a5ae8d57adde9d8ff36ecc7115f7060847328fd2e74b79f499a9e0b2185e3f6cc802b760b927ac5ea670d8d
6
+ metadata.gz: e1d645fca2a737a3ec16843238ce68ad4f53e6088afd6ec46f499bfa90953003e20c1b68b2f0dc54b84652adcbb9a753266f75102d849736fdb01877540035bd
7
+ data.tar.gz: 4c48d06eb4ed38f45ceae4aed3d41082e27bed12dbe4fd29b0b9a8efd014b72e74f4793d581d9b4f3063c528f4bd5afb7eab1855f96cda4bc4cc19f99d8be00f
@@ -21,44 +21,72 @@ module Emarsys
21
21
 
22
22
 
23
23
  def authenticated_healthcheck
24
- request_data = {
25
- method: 'GET',
26
- uri: '/api/services/authenticated_healthcheck',
27
- headers: [['host', @host]],
28
- }
24
+ method = 'GET'
25
+ uri = '/api/services/authenticated_healthcheck'
26
+ request_data = assemble_request(method, uri)
29
27
 
30
28
  escher.sign!(request_data, client)
31
29
 
32
- RestClient::Request.execute(
33
- method: :get,
34
- url: "#{@protocol}://#{@host}/api/services/authenticated_healthcheck",
35
- headers: request_data[:headers],
36
- ssl_version: :TLSv1
37
- )
30
+ send_request(method, request_data, uri, false)
38
31
  end
39
32
 
40
33
 
41
34
 
42
- def list_integrations(customer)
43
- request_data = {
44
- method: 'GET',
45
- uri: "/api/services/customers/#{customer}/integrations",
46
- headers: [['host', @host]],
47
- }
35
+ def list_integrations(customer_id)
36
+ method = 'GET'
37
+ uri = "/api/services/customers/#{customer_id}/integrations"
38
+ request_data = assemble_request(method, uri)
48
39
 
49
40
  escher.sign!(request_data, client)
50
41
 
51
- JSON.parse(RestClient::Request.execute(
52
- method: 'GET',
53
- url: "#{@protocol}://#{@host}/api/services/customers/#{customer}/integrations",
54
- headers: request_data[:headers],
55
- ssl_version: :TLSv1
56
- ))
42
+ send_request(method, request_data, uri)
43
+ end
44
+
45
+
46
+
47
+ def get_integration(customer_id, integration_id)
48
+ method = 'GET'
49
+ uri = "/api/services/customers/#{customer_id}/integrations/#{integration_id}"
50
+ request_data = assemble_request(method, uri)
51
+
52
+ escher.sign!(request_data, client)
53
+
54
+ send_request(method, request_data, uri)
57
55
  end
58
56
 
59
57
 
60
58
 
61
59
  private
60
+
61
+ def url(uri)
62
+ "#{@protocol}://#{@host}#{uri}"
63
+ end
64
+
65
+
66
+
67
+ def assemble_request(method, uri)
68
+ { method: method, uri: uri, headers: [['host', @host]] }
69
+ end
70
+
71
+
72
+
73
+ def send_request(method, request_data, uri, return_json = true)
74
+ response = (RestClient::Request.execute(
75
+ method: method,
76
+ url: url(uri),
77
+ headers: request_data[:headers],
78
+ ssl_version: :TLSv1
79
+ ))
80
+
81
+ if return_json
82
+ JSON.parse(response)
83
+ else
84
+ response
85
+ end
86
+ end
87
+
88
+
89
+
62
90
  def escher
63
91
  Escher::Auth.new('eu/suite/ems_request', {
64
92
  algo_prefix: 'EMS',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emarsys_suite_services_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emarsys
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: dotenv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.2
55
69
  description: Client for the services api of the Emarsys Suite.
56
70
  email: andras.barthazi@emarsys.com
57
71
  executables: []