mrkt 0.10.0 → 1.1.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
  SHA256:
3
- metadata.gz: 4121a615d6e3099a58b81831bcfc5831aba8f331d22d3cfb98501ebcfb7c2272
4
- data.tar.gz: b7b345f6f78c47bef04395b88924bc62231b1fd49a27ce9dd91564ca87557db4
3
+ metadata.gz: 9555446a2b866d1d3e66dcd8b00e95f334adf3d6016914c4c2db9f22861949c2
4
+ data.tar.gz: 78ed8e860c4541e8153ce6571ff7f49e2b60be711df8945369ddf043c9079dde
5
5
  SHA512:
6
- metadata.gz: a40cf98b97f10e619bb6066637567a946f26a6fef586c55bdfe7341ae102550be1d812e5e468cd13ca4cc12dfa772b9f697e431aeda728464e2150ea1148b4d7
7
- data.tar.gz: 2fccf0ded04505d6c7a0049bff1040876e74540adab38543aa7b35aa667f7f266f52df739158921547031796ffc9a18c2b89fd35f2a4c0a7b13ff97f0de86048
6
+ metadata.gz: a883d2016a279f6424e29a549d0eba209079cf060d0304c290765254ee30c5226fb78df64d46ce132ae286f8e2256c3921c01862dbf26eb2c67dca85387af4c1
7
+ data.tar.gz: adbedc7b1075222d4ed881b99f1fb2d05b4aaef56b89278633d0563438ba2adc65a36d400fa89caeffa65bfe6dc03bf91c509cce69e009978404047ab8438174
data/.rubocop.yml CHANGED
@@ -1,31 +1,71 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.5
3
3
  Exclude:
4
4
  - 'bin/**/*'
5
- Documentation:
6
- Enabled: false
7
- LineLength:
5
+ - 'vendor/**/*'
6
+
7
+ Layout/EmptyLinesAroundAttributeAccessor:
8
8
  Enabled: true
9
- Max: 128
10
- MethodLength:
11
- Max: 20
12
- IndentHash:
9
+ Layout/EmptyLineAfterGuardClause:
13
10
  Enabled: false
14
-
15
- Layout/AlignHash:
11
+ Layout/FirstHashElementIndentation:
16
12
  Enabled: false
17
- Layout/EmptyLineAfterGuardClause:
13
+ Layout/HashAlignment:
18
14
  Enabled: false
15
+ Layout/LineLength:
16
+ Max: 128
19
17
  Layout/MultilineMethodCallIndentation:
20
18
  EnforcedStyle: indented
21
- Naming/AccessorMethodName:
22
- Enabled: false
19
+ Layout/SpaceAroundMethodCallOperator:
20
+ Enabled: true
21
+
22
+ Lint/DeprecatedOpenSSLConstant:
23
+ Enabled: true
24
+ Lint/MixedRegexpCaptureTypes:
25
+ Enabled: true
26
+ Lint/RaiseException:
27
+ Enabled: true
28
+ Lint/StructNewOverride:
29
+ Enabled: true
30
+
31
+ Metrics/AbcSize:
32
+ Max: 17
23
33
  Metrics/BlockLength:
24
34
  Exclude:
25
35
  - 'spec/**/*'
36
+ Metrics/MethodLength:
37
+ Max: 20
26
38
  Metrics/ParameterLists:
27
39
  Max: 6
40
+
41
+ Naming/AccessorMethodName:
42
+ Enabled: false
43
+
44
+ Style/AccessorGrouping:
45
+ Enabled: true
46
+ Style/BisectedAttrAccessor:
47
+ Enabled: true
28
48
  Style/ClassAndModuleChildren:
29
49
  Enabled: false
50
+ Style/Documentation:
51
+ Enabled: false
52
+ Style/ExponentialNotation:
53
+ Enabled: true
30
54
  Style/FrozenStringLiteralComment:
31
55
  Enabled: false
56
+ Style/HashEachMethods:
57
+ Enabled: true
58
+ Style/HashTransformKeys:
59
+ Enabled: true
60
+ Style/HashTransformValues:
61
+ Enabled: true
62
+ Style/RedundantAssignment:
63
+ Enabled: true
64
+ Style/RedundantFetchBlock:
65
+ Enabled: true
66
+ Style/RedundantRegexpCharacterClass:
67
+ Enabled: true
68
+ Style/RedundantRegexpEscape:
69
+ Enabled: true
70
+ Style/SlicingWithRange:
71
+ Enabled: true
data/.travis.yml CHANGED
@@ -1,11 +1,22 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
4
+ - COVERAGE=on
1
5
  language: ruby
2
6
  rvm:
3
- - 2.3.6
4
- - 2.4.3
5
- - 2.5.0
6
- - 2.6.0
7
- addons:
8
- code_climate:
9
- repo_token: 45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
10
- after_success:
11
- - bundle exec codeclimate-test-reporter
7
+ - 2.5
8
+ - 2.6
9
+ - 2.7
10
+ - 3.0
11
+ before_install:
12
+ - gem update --system
13
+ - bundle update --bundler
14
+ before_script:
15
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
16
+ - chmod +x ./cc-test-reporter
17
+ - ./cc-test-reporter before-build
18
+ script:
19
+ - bundle exec rspec
20
+ - bundle exec rubocop
21
+ after_script:
22
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile.lock CHANGED
@@ -1,92 +1,103 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mrkt (0.10.0)
5
- faraday (> 0.9.0, < 0.16.0)
6
- faraday_middleware (> 0.9.0, < 0.16.0)
4
+ mrkt (1.1.0)
5
+ faraday (~> 1.0)
6
+ faraday_middleware (~> 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.6.0)
12
- public_suffix (>= 2.0.2, < 4.0)
13
- ast (2.4.0)
14
- byebug (11.0.1)
15
- codeclimate-test-reporter (1.0.9)
16
- simplecov (<= 0.13)
17
- coderay (1.1.2)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.1)
14
+ byebug (11.1.3)
15
+ coderay (1.1.3)
18
16
  crack (0.4.3)
19
17
  safe_yaml (~> 1.0.0)
20
- diff-lcs (1.3)
21
- docile (1.1.5)
22
- faraday (0.15.4)
18
+ diff-lcs (1.4.4)
19
+ docile (1.3.2)
20
+ faraday (1.4.1)
21
+ faraday-excon (~> 1.1)
22
+ faraday-net_http (~> 1.0)
23
+ faraday-net_http_persistent (~> 1.1)
23
24
  multipart-post (>= 1.2, < 3)
24
- faraday_middleware (0.13.1)
25
- faraday (>= 0.7.4, < 1.0)
26
- hashdiff (0.3.8)
27
- jaro_winkler (1.5.2)
28
- json (2.2.0)
29
- method_source (0.9.2)
30
- multipart-post (2.0.0)
31
- parallel (1.14.0)
32
- parser (2.6.2.0)
33
- ast (~> 2.4.0)
34
- pry (0.12.2)
35
- coderay (~> 1.1.0)
36
- method_source (~> 0.9.0)
37
- pry-byebug (3.7.0)
25
+ ruby2_keywords (>= 0.0.4)
26
+ faraday-excon (1.1.0)
27
+ faraday-net_http (1.0.1)
28
+ faraday-net_http_persistent (1.1.0)
29
+ faraday_middleware (1.0.0)
30
+ faraday (~> 1.0)
31
+ gem-release (2.1.1)
32
+ hashdiff (1.0.1)
33
+ json (2.3.1)
34
+ method_source (1.0.0)
35
+ multipart-post (2.1.1)
36
+ parallel (1.19.2)
37
+ parser (2.7.1.4)
38
+ ast (~> 2.4.1)
39
+ pry (0.13.1)
40
+ coderay (~> 1.1)
41
+ method_source (~> 1.0)
42
+ pry-byebug (3.9.0)
38
43
  byebug (~> 11.0)
39
- pry (~> 0.10)
40
- psych (3.1.0)
41
- public_suffix (3.0.3)
44
+ pry (~> 0.13.0)
45
+ public_suffix (4.0.5)
42
46
  rainbow (3.0.0)
43
- rake (12.3.2)
44
- rspec (3.8.0)
45
- rspec-core (~> 3.8.0)
46
- rspec-expectations (~> 3.8.0)
47
- rspec-mocks (~> 3.8.0)
48
- rspec-core (3.8.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-expectations (3.8.2)
47
+ rake (12.3.3)
48
+ regexp_parser (1.7.1)
49
+ rexml (3.2.5)
50
+ rspec (3.9.0)
51
+ rspec-core (~> 3.9.0)
52
+ rspec-expectations (~> 3.9.0)
53
+ rspec-mocks (~> 3.9.0)
54
+ rspec-core (3.9.2)
55
+ rspec-support (~> 3.9.3)
56
+ rspec-expectations (3.9.2)
51
57
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-mocks (3.8.0)
58
+ rspec-support (~> 3.9.0)
59
+ rspec-mocks (3.9.1)
54
60
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.8.0)
56
- rspec-support (3.8.0)
57
- rubocop (0.66.0)
58
- jaro_winkler (~> 1.5.1)
61
+ rspec-support (~> 3.9.0)
62
+ rspec-support (3.9.3)
63
+ rubocop (0.87.1)
59
64
  parallel (~> 1.10)
60
- parser (>= 2.5, != 2.5.1.1)
61
- psych (>= 3.1.0)
65
+ parser (>= 2.7.1.1)
62
66
  rainbow (>= 2.2.2, < 4.0)
67
+ regexp_parser (>= 1.7)
68
+ rexml
69
+ rubocop-ast (>= 0.1.0, < 1.0)
63
70
  ruby-progressbar (~> 1.7)
64
- unicode-display_width (>= 1.4.0, < 1.6)
65
- ruby-progressbar (1.10.0)
71
+ unicode-display_width (>= 1.4.0, < 2.0)
72
+ rubocop-ast (0.1.0)
73
+ parser (>= 2.7.0.1)
74
+ ruby-progressbar (1.10.1)
75
+ ruby2_keywords (0.0.4)
66
76
  safe_yaml (1.0.5)
67
- simplecov (0.13.0)
68
- docile (~> 1.1.0)
77
+ simplecov (0.17.1)
78
+ docile (~> 1.1)
69
79
  json (>= 1.8, < 3)
70
80
  simplecov-html (~> 0.10.0)
71
81
  simplecov-html (0.10.2)
72
- unicode-display_width (1.5.0)
73
- webmock (3.5.1)
82
+ unicode-display_width (1.7.0)
83
+ webmock (3.8.3)
74
84
  addressable (>= 2.3.6)
75
85
  crack (>= 0.3.2)
76
- hashdiff
86
+ hashdiff (>= 0.4.0, < 2.0.0)
77
87
 
78
88
  PLATFORMS
79
89
  ruby
80
90
 
81
91
  DEPENDENCIES
82
92
  bundler (~> 1.3)
83
- codeclimate-test-reporter (~> 1.0)
93
+ gem-release (~> 2.1)
84
94
  mrkt!
85
95
  pry-byebug (~> 3.7)
86
96
  rake (~> 12.3)
87
97
  rspec (~> 3.2)
88
- rubocop (~> 0.66.0)
98
+ rubocop (~> 0.87.1)
99
+ simplecov (~> 0.17.1)
89
100
  webmock (~> 3.1)
90
101
 
91
102
  BUNDLED WITH
92
- 1.17.2
103
+ 1.17.3
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Code Climate](https://codeclimate.com/github/raszi/mrkt/badges/gpa.svg)](https://codeclimate.com/github/raszi/mrkt)
5
5
  [![Test Coverage](https://codeclimate.com/github/raszi/mrkt/badges/coverage.svg)](https://codeclimate.com/github/raszi/mrkt)
6
6
  [![Gem Version](https://badge.fury.io/rb/mrkt.svg)](https://badge.fury.io/rb/mrkt)
7
+ [![Total Downloads](https://badgen.net/rubygems/dt/mrkt)](https://rubygems.org/gems/mrkt)
7
8
 
8
9
  This gem provides some level of abstraction to Marketo REST APIs. Please note that this gem is alpha quality.
9
10
 
@@ -32,6 +33,7 @@ Get the following from your Marketo admin:
32
33
  * hostname, i.e. `'123-abc-123.mktorest.com'`
33
34
  * client id, e.g. `'4567e1cdf-0fae-4685-a914-5be45043f2d8'`
34
35
  * client secret, e.g. `'7Gn0tuiHZiDHnzeu9P14uDQcSx9xIPPt'`
36
+ * partner id, e.g. `'335b1c91511b8d8b49c7bbf66f53288f16f37b60_a0147938d3135f8ddb5a75850ea3c39313fd23c4'` (optional)
35
37
 
36
38
 
37
39
  ## Usage
@@ -42,7 +44,9 @@ Get the following from your Marketo admin:
42
44
  client = Mrkt::Client.new(
43
45
  host: '123-abc-123.mktorest.com',
44
46
  client_id: '4567e1cdf-0fae-4685-a914-5be45043f2d8',
45
- client_secret: '7Gn0tuiHZiDHnzeu9P14uDQcSx9xIPPt')
47
+ client_secret: '7Gn0tuiHZiDHnzeu9P14uDQcSx9xIPPt',
48
+ partner_id: '335b1c91511b8d8b49c7bbf66f53288f16f37b60_a0147938d3135f8ddb5a75850ea3c39313fd23c4' # optional
49
+ )
46
50
  ```
47
51
 
48
52
  If you need verbosity during troubleshooting, enable debug mode:
data/lib/mrkt.rb CHANGED
@@ -40,6 +40,7 @@ module Mrkt
40
40
 
41
41
  @client_id = options.fetch(:client_id)
42
42
  @client_secret = options.fetch(:client_secret)
43
+ @partner_id = options[:partner_id]
43
44
 
44
45
  @retry_authentication = options.fetch(:retry_authentication, false)
45
46
  @retry_authentication_count = options.fetch(:retry_authentication_count, 3).to_i
@@ -39,15 +39,27 @@ module Mrkt
39
39
  end
40
40
 
41
41
  def authentication_params
42
+ merge_params(required_authentication_params, optional_authentication_params)
43
+ end
44
+
45
+ def add_authorization(req)
46
+ req.headers[:authorization] = "Bearer #{@token}"
47
+ end
48
+
49
+ private
50
+
51
+ def optional_authentication_params
52
+ {
53
+ partner_id: @partner_id
54
+ }
55
+ end
56
+
57
+ def required_authentication_params
42
58
  {
43
59
  grant_type: 'client_credentials',
44
60
  client_id: @client_id,
45
61
  client_secret: @client_secret
46
62
  }
47
63
  end
48
-
49
- def add_authorization(req)
50
- req.headers[:authorization] = "Bearer #{@token}"
51
- end
52
64
  end
53
65
  end
@@ -1,4 +1,4 @@
1
- require 'mrkt/faraday_middleware'
1
+ require 'mrkt/faraday'
2
2
 
3
3
  module Mrkt
4
4
  module Connection
@@ -7,7 +7,7 @@ module Mrkt
7
7
  end
8
8
 
9
9
  def init_connection
10
- Faraday.new(url: "https://#{@host}") do |conn|
10
+ ::Faraday.new(options) do |conn|
11
11
  conn.request :multipart
12
12
  conn.request :url_encoded
13
13
 
@@ -17,8 +17,17 @@ module Mrkt
17
17
  conn.options.timeout = @options[:read_timeout] if @options.key?(:read_timeout)
18
18
  conn.options.open_timeout = @options[:open_timeout] if @options.key?(:open_timeout)
19
19
 
20
- conn.adapter @options.fetch(:adapter, Faraday.default_adapter)
20
+ conn.adapter @options.fetch(:adapter, ::Faraday.default_adapter)
21
21
  end
22
22
  end
23
+
24
+ def options
25
+ {
26
+ url: "https://#{@host}",
27
+ request: {
28
+ params_encoder: Mrkt::Faraday::ParamsEncoder
29
+ }
30
+ }
31
+ end
23
32
  end
24
33
  end
@@ -13,8 +13,8 @@ module Mrkt
13
13
  nextPageToken: next_page_token
14
14
  }
15
15
 
16
- params[:activityTypeIds] = activity_type_ids.join(',') unless blank?(activity_type_ids)
17
- params[:leadIds] = lead_ids.join(',') unless blank?(lead_ids)
16
+ params[:activityTypeIds] = activity_type_ids unless blank?(activity_type_ids)
17
+ params[:leadIds] = lead_ids unless blank?(lead_ids)
18
18
 
19
19
  get('/rest/v1/activities.json', params)
20
20
  end
@@ -2,7 +2,7 @@ module Mrkt
2
2
  module CrudCustomObjects
3
3
  def get_list_of_custom_objects(names = nil)
4
4
  params = {}
5
- params[:names] = names.join(',') if names
5
+ params[:names] = names if names
6
6
 
7
7
  get('/rest/v1/customobjects.json', params)
8
8
  end
@@ -2,7 +2,7 @@ module Mrkt
2
2
  module CrudLeads
3
3
  def get_lead_by_id(id, fields: nil)
4
4
  optional = {
5
- fields: fields&.join(',')
5
+ fields: fields
6
6
  }
7
7
 
8
8
  get("/rest/v1/lead/#{id}.json", {}, optional)
@@ -11,7 +11,7 @@ module Mrkt
11
11
  def get_leads(filter_type, filter_values, fields: nil, batch_size: nil, next_page_token: nil)
12
12
  params = {
13
13
  filterType: filter_type,
14
- filterValues: filter_values.join(',')
14
+ filterValues: filter_values
15
15
  }
16
16
 
17
17
  optional = {
@@ -47,18 +47,20 @@ module Mrkt
47
47
  end
48
48
 
49
49
  def associate_lead(id, cookie)
50
- params = Faraday::Utils::ParamsHash.new
51
- params[:cookie] = cookie
50
+ params = Mrkt::Faraday::ParamsEncoder.encode(cookie: cookie)
52
51
 
53
- post_json("/rest/v1/leads/#{id}/associate.json?#{params.to_query}")
52
+ post_json("/rest/v1/leads/#{id}/associate.json?#{params}")
54
53
  end
55
54
 
56
55
  def merge_leads(winning_lead_id, losing_lead_ids, merge_in_crm: false)
57
- params = Faraday::Utils::ParamsHash.new
56
+ params = {}
57
+
58
58
  params[:mergeInCRM] = merge_in_crm
59
- params[:leadIds] = losing_lead_ids.join(',') if losing_lead_ids
59
+ params[:leadIds] = losing_lead_ids if losing_lead_ids
60
+
61
+ query_params = Mrkt::Faraday::ParamsEncoder.encode(params)
60
62
 
61
- post_json("/rest/v1/leads/#{winning_lead_id}/merge.json?#{params.to_query}")
63
+ post_json("/rest/v1/leads/#{winning_lead_id}/merge.json?#{query_params}")
62
64
  end
63
65
 
64
66
  def describe_lead
@@ -3,7 +3,7 @@ module Mrkt
3
3
  def import_custom_object(file, custom_object, format = 'csv')
4
4
  params = {
5
5
  format: format,
6
- file: Faraday::UploadIO.new(file, 'text/csv')
6
+ file: ::Faraday::UploadIO.new(file, 'text/csv')
7
7
  }
8
8
 
9
9
  post("/bulk/v1/customobjects/#{custom_object}/import.json", params)
@@ -3,7 +3,7 @@ module Mrkt
3
3
  def import_lead(file, format = 'csv', lookup_field: nil, list_id: nil, partition_name: nil)
4
4
  params = {
5
5
  format: format,
6
- file: Faraday::UploadIO.new(file, 'text/csv')
6
+ file: ::Faraday::UploadIO.new(file, 'text/csv')
7
7
  }
8
8
 
9
9
  optional = {
data/lib/mrkt/errors.rb CHANGED
@@ -40,7 +40,26 @@ class Mrkt::Errors
40
40
  1011 => 'FieldNotSupported',
41
41
  1012 => 'InvalidCookieValue',
42
42
  1013 => 'ObjectNotFound',
43
- 1014 => 'FailedToCreateObject'
43
+ 1014 => 'FailedToCreateObject',
44
+ 1015 => 'LeadNotInList',
45
+ 1016 => 'TooManyImports',
46
+ 1017 => 'ObjectAlreadyExists',
47
+ 1018 => 'CRMEnabled',
48
+ 1019 => 'ImportInProgress',
49
+ 1020 => 'TooManyCloneToProgram',
50
+ 1021 => 'CompanyUpdateNotAllowed',
51
+ 1022 => 'ObjectInUse',
52
+ 1025 => 'ProgramStatusNotFound',
53
+ 1026 => 'CustomObjectNotEnabled',
54
+ 1027 => 'MaxActivityTypeLimitReached',
55
+ 1028 => 'MaxFieldLimitReached',
56
+ 1029 => 'BulkExportQuotaExceeded',
57
+ 1035 => 'UnsupportedFilterType',
58
+ 1036 => 'DuplicateObjectFoundInInput',
59
+ 1042 => 'InvalidRunAtDate',
60
+ 1048 => 'CustomObjectDiscardDraftFailed',
61
+ 1049 => 'FailedToCreateActivity',
62
+ 1077 => 'MergeLeadsCallFailedDueToFieldLength'
44
63
  }.freeze
45
64
 
46
65
  RESPONSE_CODE_TO_ERROR.each_value do |class_name|
@@ -0,0 +1,4 @@
1
+ require 'faraday'
2
+
3
+ require 'mrkt/faraday/params_encoder'
4
+ require 'mrkt/faraday_middleware'
@@ -0,0 +1,20 @@
1
+ module Mrkt
2
+ module Faraday
3
+ class ParamsEncoder
4
+ class << self
5
+ def encode(hash)
6
+ new_hash = hash.transform_values { |v| encode_value(v) }
7
+ ::Faraday::NestedParamsEncoder.encode(new_hash)
8
+ end
9
+
10
+ def decode(string)
11
+ ::Faraday::NestedParamsEncoder.decode(string)
12
+ end
13
+
14
+ def encode_value(value)
15
+ value.respond_to?(:join) ? value.join(',') : value
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,11 +1,7 @@
1
- require 'faraday'
1
+ require 'mrkt/faraday_middleware/response'
2
2
 
3
3
  module Mrkt
4
- module FaradayMiddleware
5
- autoload :Response, 'mrkt/faraday_middleware/response'
6
- end
7
-
8
- if Faraday::Middleware.respond_to? :register_middleware
9
- Faraday::Response.register_middleware mkto: -> { Mrkt::FaradayMiddleware::Response }
4
+ if ::Faraday::Middleware.respond_to?(:register_middleware)
5
+ ::Faraday::Response.register_middleware(mkto: Mrkt::FaradayMiddleware::Response)
10
6
  end
11
7
  end
data/lib/mrkt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mrkt
2
- VERSION = '0.10.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
data/mrkt.gemspec CHANGED
@@ -17,16 +17,17 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = %w[lib]
19
19
 
20
- spec.required_ruby_version = '~> 2.3'
20
+ spec.required_ruby_version = '>= 2.5'
21
21
 
22
- spec.add_dependency 'faraday', '> 0.9.0', '< 0.16.0'
23
- spec.add_dependency 'faraday_middleware', '> 0.9.0', '< 0.16.0'
22
+ spec.add_dependency 'faraday', '~> 1.0'
23
+ spec.add_dependency 'faraday_middleware', '~> 1.0'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.3'
26
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
26
+ spec.add_development_dependency 'gem-release', '~> 2.1'
27
27
  spec.add_development_dependency 'pry-byebug', '~> 3.7'
28
28
  spec.add_development_dependency 'rake', '~> 12.3'
29
29
  spec.add_development_dependency 'rspec', '~> 3.2'
30
- spec.add_development_dependency 'rubocop', '~> 0.66.0'
30
+ spec.add_development_dependency 'rubocop', '~> 0.87.1'
31
+ spec.add_development_dependency 'simplecov', '~> 0.17.1'
31
32
  spec.add_development_dependency 'webmock', '~> 3.1'
32
33
  end
@@ -29,6 +29,44 @@ describe Mrkt::Authentication do
29
29
  expect(client.authenticated?).to be true
30
30
  end
31
31
 
32
+ context 'with optional partner_id client option' do
33
+ before { remove_request_stub(@authentication_request_stub) }
34
+
35
+ let(:partner_id) { SecureRandom.uuid }
36
+
37
+ let(:client_options) do
38
+ {
39
+ host: host,
40
+ client_id: client_id,
41
+ client_secret: client_secret,
42
+ partner_id: partner_id
43
+ }
44
+ end
45
+
46
+ let(:query) do
47
+ {
48
+ client_id: client_id,
49
+ client_secret: client_secret,
50
+ partner_id: partner_id,
51
+ grant_type: 'client_credentials'
52
+ }
53
+ end
54
+
55
+ subject(:client) { Mrkt::Client.new(client_options) }
56
+
57
+ before do
58
+ stub_request(:get, "https://#{host}/identity/oauth/token")
59
+ .with(query: query)
60
+ .to_return(json_stub(authentication_stub))
61
+ end
62
+
63
+ it 'should authenticate and then be authenticated?' do
64
+ expect(client.authenticated?).to_not be true
65
+ client.authenticate!
66
+ expect(client.authenticated?).to be true
67
+ end
68
+ end
69
+
32
70
  context 'when the token has expired and @retry_authentication = true' do
33
71
  before { remove_request_stub(@authentication_request_stub) }
34
72
 
@@ -211,7 +211,7 @@ describe Mrkt::CrudLeads do
211
211
  subject { client.merge_leads(id, losing_lead_ids) }
212
212
 
213
213
  before do
214
- params = Faraday::Utils::ParamsHash.new
214
+ params = ::Faraday::Utils::ParamsHash.new
215
215
  params[:mergeInCRM] = false
216
216
  params[:leadIds] = losing_lead_ids.join(',') if losing_lead_ids
217
217
 
@@ -5,7 +5,7 @@ describe Mrkt::ImportLeads do
5
5
  include_context 'initialized client'
6
6
 
7
7
  describe '#import_lead' do
8
- let(:tempfile) { Tempfile.new(['import-leads', 'csv']) }
8
+ let(:tempfile) { Tempfile.new(%w[import-leads csv]) }
9
9
  let(:response_stub) do
10
10
  {
11
11
  requestId: 'c245#14cd6830ae2',
@@ -0,0 +1,24 @@
1
+ describe Mrkt::Faraday::ParamsEncoder do
2
+ describe '.encode' do
3
+ let(:params) do
4
+ {
5
+ string: 'foobar',
6
+ number: 1,
7
+ boolean: true,
8
+ array: [1, 2, 3]
9
+ }
10
+ end
11
+
12
+ subject { described_class.encode(params) }
13
+
14
+ it { is_expected.to eq(Faraday::Utils::ParamsHash.new.merge(params.merge(array: '1,2,3')).to_query) }
15
+ end
16
+
17
+ describe '.decode' do
18
+ let(:value) { 'foo=foo&bar=bar' }
19
+
20
+ subject { described_class.decode(value) }
21
+
22
+ it { is_expected.to eq('foo' => 'foo', 'bar' => 'bar') }
23
+ end
24
+ end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,9 @@ Bundler.setup
8
8
 
9
9
  require 'mrkt'
10
10
 
11
- Dir[File.expand_path('spec/support/**/*.rb')].each { |f| require f }
11
+ Dir[File.expand_path('spec/support/**/*.rb')].sort.each do |file|
12
+ require file
13
+ end
12
14
 
13
15
  RSpec.configure do |config|
14
16
  config.default_formatter = :doc if config.files_to_run.one?
@@ -1,16 +1,10 @@
1
1
  require 'webmock/rspec'
2
2
 
3
- RSpec.configure do |config|
3
+ RSpec.configure do
4
4
  def json_stub(content_stub)
5
5
  {
6
6
  headers: { content_type: 'application/json' },
7
7
  body: JSON.generate(content_stub)
8
8
  }
9
9
  end
10
-
11
- if ENV['CODECLIMATE_REPO_TOKEN']
12
- config.after(:suite) do
13
- WebMock.disable_net_connect!(allow: 'codeclimate.com')
14
- end
15
- end
16
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrkt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KARASZI István
@@ -9,48 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-03-23 00:00:00.000000000 Z
12
+ date: 2021-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">"
19
- - !ruby/object:Gem::Version
20
- version: 0.9.0
21
- - - "<"
18
+ - - "~>"
22
19
  - !ruby/object:Gem::Version
23
- version: 0.16.0
20
+ version: '1.0'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
27
24
  requirements:
28
- - - ">"
29
- - !ruby/object:Gem::Version
30
- version: 0.9.0
31
- - - "<"
25
+ - - "~>"
32
26
  - !ruby/object:Gem::Version
33
- version: 0.16.0
27
+ version: '1.0'
34
28
  - !ruby/object:Gem::Dependency
35
29
  name: faraday_middleware
36
30
  requirement: !ruby/object:Gem::Requirement
37
31
  requirements:
38
- - - ">"
39
- - !ruby/object:Gem::Version
40
- version: 0.9.0
41
- - - "<"
32
+ - - "~>"
42
33
  - !ruby/object:Gem::Version
43
- version: 0.16.0
34
+ version: '1.0'
44
35
  type: :runtime
45
36
  prerelease: false
46
37
  version_requirements: !ruby/object:Gem::Requirement
47
38
  requirements:
48
- - - ">"
49
- - !ruby/object:Gem::Version
50
- version: 0.9.0
51
- - - "<"
39
+ - - "~>"
52
40
  - !ruby/object:Gem::Version
53
- version: 0.16.0
41
+ version: '1.0'
54
42
  - !ruby/object:Gem::Dependency
55
43
  name: bundler
56
44
  requirement: !ruby/object:Gem::Requirement
@@ -66,19 +54,19 @@ dependencies:
66
54
  - !ruby/object:Gem::Version
67
55
  version: '1.3'
68
56
  - !ruby/object:Gem::Dependency
69
- name: codeclimate-test-reporter
57
+ name: gem-release
70
58
  requirement: !ruby/object:Gem::Requirement
71
59
  requirements:
72
60
  - - "~>"
73
61
  - !ruby/object:Gem::Version
74
- version: '1.0'
62
+ version: '2.1'
75
63
  type: :development
76
64
  prerelease: false
77
65
  version_requirements: !ruby/object:Gem::Requirement
78
66
  requirements:
79
67
  - - "~>"
80
68
  - !ruby/object:Gem::Version
81
- version: '1.0'
69
+ version: '2.1'
82
70
  - !ruby/object:Gem::Dependency
83
71
  name: pry-byebug
84
72
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +115,28 @@ dependencies:
127
115
  requirements:
128
116
  - - "~>"
129
117
  - !ruby/object:Gem::Version
130
- version: 0.66.0
118
+ version: 0.87.1
131
119
  type: :development
132
120
  prerelease: false
133
121
  version_requirements: !ruby/object:Gem::Requirement
134
122
  requirements:
135
123
  - - "~>"
136
124
  - !ruby/object:Gem::Version
137
- version: 0.66.0
125
+ version: 0.87.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: simplecov
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: 0.17.1
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: 0.17.1
138
140
  - !ruby/object:Gem::Dependency
139
141
  name: webmock
140
142
  requirement: !ruby/object:Gem::Requirement
@@ -183,6 +185,8 @@ files:
183
185
  - lib/mrkt/concerns/import_custom_objects.rb
184
186
  - lib/mrkt/concerns/import_leads.rb
185
187
  - lib/mrkt/errors.rb
188
+ - lib/mrkt/faraday.rb
189
+ - lib/mrkt/faraday/params_encoder.rb
186
190
  - lib/mrkt/faraday_middleware.rb
187
191
  - lib/mrkt/faraday_middleware/response.rb
188
192
  - lib/mrkt/version.rb
@@ -200,6 +204,7 @@ files:
200
204
  - spec/concerns/import_custom_objects_spec.rb
201
205
  - spec/concerns/import_leads_spec.rb
202
206
  - spec/errors_spec.rb
207
+ - spec/faraday/params_encoder_spec.rb
203
208
  - spec/mkto_rest_spec.rb
204
209
  - spec/spec_helper.rb
205
210
  - spec/support/initialized_client.rb
@@ -214,16 +219,16 @@ require_paths:
214
219
  - lib
215
220
  required_ruby_version: !ruby/object:Gem::Requirement
216
221
  requirements:
217
- - - "~>"
222
+ - - ">="
218
223
  - !ruby/object:Gem::Version
219
- version: '2.3'
224
+ version: '2.5'
220
225
  required_rubygems_version: !ruby/object:Gem::Requirement
221
226
  requirements:
222
227
  - - ">="
223
228
  - !ruby/object:Gem::Version
224
229
  version: '0'
225
230
  requirements: []
226
- rubygems_version: 3.0.3
231
+ rubygems_version: 3.1.4
227
232
  signing_key:
228
233
  specification_version: 4
229
234
  summary: Marketo REST API Facade
@@ -241,6 +246,7 @@ test_files:
241
246
  - spec/concerns/import_custom_objects_spec.rb
242
247
  - spec/concerns/import_leads_spec.rb
243
248
  - spec/errors_spec.rb
249
+ - spec/faraday/params_encoder_spec.rb
244
250
  - spec/mkto_rest_spec.rb
245
251
  - spec/spec_helper.rb
246
252
  - spec/support/initialized_client.rb