emarsys-api 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 890db25672b387bda4461974f6bf2d8ceee78655
4
- data.tar.gz: 9248917306c7e8ef992f58b0d30899af729d90a5
3
+ metadata.gz: b7a3c6324b51118157f1675c5f970be0d94d923f
4
+ data.tar.gz: 21526b3a0d8399a87aada11e6a712ba5effc4489
5
5
  SHA512:
6
- metadata.gz: bef97bba206bdef97c806b4715aa399c88ba0b784b48fa0653e541dfa719cf8f4fc69a5c752c065e55eec6ca89ecb8315f96c1c1a70654b6d2a28baee97b8662
7
- data.tar.gz: b87816d59a8bee7fa16b6f4ea1bbe313fb7f6d5d9930e72f58131fb1d6cbda618ef4b746a1a8e133f758f0d97e17792f844a256f29cbba595bda51ef3f74859f
6
+ metadata.gz: ec92c0d7dd66f3413db35c90eb07f21906209d3666ae346bbb4d4f2e3204035edc583ff51109cbeb56a380df8da27bdbb7d7e1d77b151af275a43a7b387dcd60
7
+ data.tar.gz: 296f12b7cf94151cfcc6636d9b901b6a19cf945f1685c7e98b12f4cda4e375cd6e4ee1b4e37cee9c5954888dc650658daa114b271694531c213ce86202f337c0
@@ -12,22 +12,22 @@ Metrics/ParameterLists:
12
12
  Max: 3
13
13
  CountKeywordArgs: false
14
14
 
15
- Style/IndentHash:
15
+ Layout/IndentHash:
16
16
  EnforcedStyle: consistent
17
17
 
18
- Style/IndentArray:
18
+ Layout/IndentArray:
19
19
  EnforcedStyle: consistent
20
20
 
21
21
  Style/FrozenStringLiteralComment:
22
22
  Enabled: false
23
23
 
24
- Style/EmptyLines:
24
+ Layout/EmptyLines:
25
25
  Enabled: false
26
26
 
27
- Style/EmptyLinesAroundClassBody:
27
+ Layout/EmptyLinesAroundClassBody:
28
28
  Enabled: false
29
29
 
30
- Style/MultilineOperationIndentation:
30
+ Layout/MultilineOperationIndentation:
31
31
  EnforcedStyle: indented
32
32
 
33
33
  Style/Documentation:
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require 'rubocop/rake_task'
5
5
  RuboCop::RakeTask.new(:rubocop)
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- task default: [:rubocop, :spec]
8
+ task default: %i[rubocop spec]
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'emarsys/api/version'
@@ -24,22 +24,18 @@ module Emarsys
24
24
  URI.join(Emarsys::Api.base_url, module_path)
25
25
  end
26
26
 
27
-
28
27
  def module_path
29
28
  ''
30
29
  end
31
30
 
32
-
33
31
  def base_url
34
32
  uri.to_s
35
33
  end
36
34
 
37
-
38
35
  def hostname
39
36
  uri.hostname
40
37
  end
41
38
 
42
-
43
39
  def escher_config
44
40
  {
45
41
  credential_scope: 'eu/suite/ems_request',
@@ -49,13 +45,11 @@ module Emarsys
49
45
  }
50
46
  end
51
47
 
52
-
53
48
  def validate_response!(response)
54
49
  error_class = error_class_by_status response.status
55
50
  raise error_class.new(*parse_for_error(response)) if error_class
56
51
  end
57
52
 
58
-
59
53
  def error_class_by_status(status)
60
54
  case status
61
55
  when 200 then nil
@@ -67,7 +61,6 @@ module Emarsys
67
61
  end
68
62
  end
69
63
 
70
-
71
64
  def parse_for_error(response)
72
65
  [response.body, response.status, nil]
73
66
  end
@@ -8,11 +8,20 @@ module Emarsys
8
8
  @customer_id = customer_id
9
9
  end
10
10
 
11
-
12
11
  def campaign_get(campaign_id)
13
12
  client.get("email/#{campaign_id}").tap { |response| validate_response! response }.body['data']
14
13
  end
15
14
 
15
+ def fields_get
16
+ client.get('field/translate/en').tap { |response| validate_response!(response) }.body['data']
17
+ end
18
+
19
+ def voucher_field_create(name)
20
+ params = { name: name, application_type: 'voucher' }
21
+ headers = { 'Content-Type' => 'application/json' }
22
+ client.post('field', params.to_json, headers).tap { |response| validate_response!(response) }.body['data']
23
+ end
24
+
16
25
 
17
26
  private
18
27
 
@@ -20,7 +29,6 @@ module Emarsys
20
29
  "/api/v2/internal/#{customer_id}"
21
30
  end
22
31
 
23
-
24
32
  def parse_for_error(response)
25
33
  if response.body.is_a? Hash
26
34
  [response.body['replyText'], response.status, response.body['replyCode']]
@@ -11,7 +11,6 @@ module Emarsys
11
11
  response.body['contact_ids']
12
12
  end
13
13
 
14
-
15
14
  def email_queue(customer_id, params)
16
15
  response = client.post "customers/#{customer_id}/email_queue/", JSON.generate(params)
17
16
  validate_response! response
@@ -26,7 +25,6 @@ module Emarsys
26
25
  '/api/services'
27
26
  end
28
27
 
29
-
30
28
  def parse_for_error(response)
31
29
  errors = response.body['errors']
32
30
  if response.body.is_a?(Hash) && errors.is_a?(Array) && errors.first.is_a?(Hash)
@@ -1,5 +1,5 @@
1
1
  module Emarsys
2
2
  module Api
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emarsys-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Istvan Demeter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-22 00:00:00.000000000 Z
11
+ date: 2017-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escher-keypool
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.6.8
184
+ rubygems_version: 2.6.11
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Ruby client to make it easier to use the API of emarsys B2C MC