mrkt 0.4.0 → 0.5.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: 3002468b0ce903416cfff2fa51ef03940cf35252
4
- data.tar.gz: 410bed015b4ecc50ef564c63a72aafdb528fff68
3
+ metadata.gz: 1e7f61fce15d29887b4a005927f6f194cf5ab71c
4
+ data.tar.gz: ec88ab8e0a07767870ac7696e0bbee9d93d21af5
5
5
  SHA512:
6
- metadata.gz: ccfddbff9633674fd87973063e3cff57fda750cb28d2087b334c2d17a536f9fb73032cd69edcf3f0be6e0fbb264cf4e2f8376b6f6cfa2fc2f2ad0d699f97816c
7
- data.tar.gz: d4ff3f1a12d64609f3dab730c30f7bfc8b6e6767e6e527524c0cfc6441033c2c3ae5bee757182c92d26f5d0fb56b9f25ba865b7a320c4c63ebed6560a41e72d4
6
+ metadata.gz: 143a6acf4d42ed294a4d64d3367a6c4fdf1b783e25529500ba16007deb4e3c79024c5802f1be549537b3eed8d328ea5422adcf8d84afbad09a5280852f8fc90d
7
+ data.tar.gz: 001c7bced04d32e4e7118a3db7ae21b933491ee71d86bb929538bb4223986f05b5db4acb1e4fe1567804eff37bb596623faddb95f3b2010b4398d5adfb9c6dc4
data/.travis.yml CHANGED
@@ -3,3 +3,5 @@ rvm:
3
3
  - 2.0.0
4
4
  - 2.1.5
5
5
  - 2.2.0
6
+ addons:
7
+ code_climate: 45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mrkt (0.4.0)
4
+ mrkt (0.5.0)
5
5
  faraday_middleware (~> 0.9.1)
6
6
 
7
7
  GEM
@@ -10,6 +10,8 @@ GEM
10
10
  addressable (2.3.8)
11
11
  byebug (4.0.5)
12
12
  columnize (= 0.9.0)
13
+ codeclimate-test-reporter (0.4.7)
14
+ simplecov (>= 0.7.1, < 1.0.0)
13
15
  coderay (1.1.0)
14
16
  columnize (0.9.0)
15
17
  crack (0.4.2)
@@ -60,6 +62,7 @@ PLATFORMS
60
62
 
61
63
  DEPENDENCIES
62
64
  bundler (~> 1.3)
65
+ codeclimate-test-reporter (~> 0.4.7)
63
66
  mrkt!
64
67
  pry-byebug (~> 3.1.0)
65
68
  rake (~> 10.0)
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Mrkt
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/raszi/mrkt.png)](http://travis-ci.org/raszi/mrkt)
4
- [![Gem Version](https://badge.fury.io/rb/mrkt.png)](http://badge.fury.io/rb/mrkt)
4
+ [![Code Climate](https://codeclimate.com/github/raszi/mrkt/badges/gpa.svg)](https://codeclimate.com/github/raszi/mrkt)
5
+ [![Test Coverage](https://codeclimate.com/github/raszi/mrkt/badges/coverage.svg)](https://codeclimate.com/github/raszi/mrkt)
5
6
 
6
7
  This gem provides some level of abstraction to Marketo REST APIs. Please note that this gem is alpha quality.
7
8
 
@@ -53,7 +54,7 @@ client.debug = true
53
54
 
54
55
  ```ruby
55
56
  response = client.get_leads :email, 'sammy@acme.com'
56
- response.body[:result].each do |result|
57
+ response[:result].each do |result|
57
58
  p "id: #{result[:id]}, email: #{result[:email]}"
58
59
  end
59
60
  ```
@@ -62,7 +63,7 @@ end
62
63
 
63
64
  ```ruby
64
65
  response = client.createupdate_leads([ email: 'sample@example.com', firstName: 'John' ], lookup_field: :email)
65
- response.body[:result].each do |result|
66
+ response[:result].each do |result|
66
67
  p "id: #{result[:id]}, email: #{result[:email]}"
67
68
  end
68
69
  ```
data/lib/mrkt.rb CHANGED
@@ -28,10 +28,12 @@ module Mrkt
28
28
  define_method(http_method) do |path, payload = {}, &block|
29
29
  authenticate!
30
30
 
31
- connection.send(http_method, path, payload) do |req|
31
+ resp = connection.send(http_method, path, payload) do |req|
32
32
  add_authorization(req)
33
33
  block.call(req) unless block.nil?
34
34
  end
35
+
36
+ resp.body
35
37
  end
36
38
  end
37
39
  end
@@ -14,13 +14,7 @@ module Mrkt
14
14
  end
15
15
 
16
16
  def authenticate
17
- params = {
18
- grant_type: 'client_credentials',
19
- client_id: @client_id,
20
- client_secret: @client_secret
21
- }
22
-
23
- connection.get('/identity/oauth/token', params).tap do |response|
17
+ connection.get('/identity/oauth/token', authentication_params).tap do |response|
24
18
  data = response.body
25
19
 
26
20
  @token = data.fetch(:access_token)
@@ -30,6 +24,14 @@ module Mrkt
30
24
  end
31
25
  end
32
26
 
27
+ def authentication_params
28
+ {
29
+ grant_type: 'client_credentials',
30
+ client_id: @client_id,
31
+ client_secret: @client_secret
32
+ }
33
+ end
34
+
33
35
  def add_authorization(req)
34
36
  req.headers[:authorization] = "Bearer #{@token}"
35
37
  end
data/lib/mrkt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mrkt
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
data/mrkt.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Mrkt::VERSION
9
9
  spec.authors = ['KARASZI István', 'Jacques Lemieux']
10
10
  spec.email = ['github@spam.raszi.hu', 'jalemieux@gmail.com']
11
- spec.description = 'Marketo REST API Facade'
12
- spec.summary = ''
13
- spec.homepage = ''
11
+ spec.summary = 'Marketo REST API Facade'
12
+ spec.description = 'This gem helps you to use the Marketo REST API'
13
+ spec.homepage = 'https://github.com/raszi/mrkt'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'webmock', '~> 1.21.0'
29
29
  spec.add_development_dependency 'simplecov', '~> 0.10.0'
30
30
  spec.add_development_dependency 'pry-byebug', '~> 3.1.0'
31
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.7'
31
32
  end
@@ -28,7 +28,7 @@ describe Mrkt::CrudLeads do
28
28
  .to_return(json_stub(response_stub))
29
29
  end
30
30
 
31
- it { is_expected.to be_success }
31
+ it { is_expected.to eq(response_stub) }
32
32
  end
33
33
 
34
34
  describe '#createupdate_leads' do
@@ -72,7 +72,7 @@ describe Mrkt::CrudLeads do
72
72
  .to_return(json_stub(response_stub))
73
73
  end
74
74
 
75
- it { is_expected.to be_success }
75
+ it { is_expected.to eq(response_stub) }
76
76
  end
77
77
 
78
78
  describe '#delete_leads' do
@@ -101,7 +101,7 @@ describe Mrkt::CrudLeads do
101
101
  .to_return(json_stub(response_stub))
102
102
  end
103
103
 
104
- it { is_expected.to be_success }
104
+ it { is_expected.to eq(response_stub) }
105
105
  end
106
106
 
107
107
  describe '#associate_lead' do
@@ -126,7 +126,7 @@ describe Mrkt::CrudLeads do
126
126
  }
127
127
  end
128
128
 
129
- it { is_expected.to be_success }
129
+ it { is_expected.to eq(response_stub) }
130
130
  end
131
131
 
132
132
  context 'with a non-existing lead id' do
@@ -35,7 +35,7 @@ describe Mrkt::ImportLeads do
35
35
  tempfile.unlink
36
36
  end
37
37
 
38
- it { is_expected.to be_success }
38
+ it { is_expected.to eq(response_stub) }
39
39
  end
40
40
 
41
41
  describe '#import_lead_status' do
@@ -63,14 +63,12 @@ describe Mrkt::ImportLeads do
63
63
  .to_return(json_stub(response_stub))
64
64
  end
65
65
 
66
- it { is_expected.to be_success }
66
+ it { is_expected.to eq(response_stub) }
67
67
  end
68
68
 
69
69
  describe '#import_lead_failures' do
70
70
  let(:id) { 1 }
71
- let(:respose_stub) do
72
-
73
- end
71
+ let(:response_stub) { '' }
74
72
  subject { client.import_lead_failures(1) }
75
73
 
76
74
  before do
@@ -78,14 +76,12 @@ describe Mrkt::ImportLeads do
78
76
  .to_return(headers: { content_length: 0 })
79
77
  end
80
78
 
81
- it { is_expected.to be_success }
79
+ it { is_expected.to eq(response_stub) }
82
80
  end
83
81
 
84
82
  describe '#import_lead_warnings' do
85
83
  let(:id) { 1 }
86
- let(:respose_stub) do
87
-
88
- end
84
+ let(:response_stub) { '' }
89
85
  subject { client.import_lead_warnings(1) }
90
86
 
91
87
  before do
@@ -93,6 +89,6 @@ describe Mrkt::ImportLeads do
93
89
  .to_return(headers: { content_length: 0 })
94
90
  end
95
91
 
96
- it { is_expected.to be_success }
92
+ it { is_expected.to eq(response_stub) }
97
93
  end
98
94
  end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,11 @@ if ENV['COVERAGE']
3
3
  SimpleCov.start
4
4
  end
5
5
 
6
+ if ENV['CODECLIMATE_REPO_TOKEN']
7
+ require "codeclimate-test-reporter"
8
+ CodeClimate::TestReporter.start
9
+ end
10
+
6
11
  require 'bundler/setup'
7
12
  Bundler.setup
8
13
 
@@ -1,10 +1,16 @@
1
1
  require 'webmock/rspec'
2
2
 
3
- RSpec.configure do
3
+ RSpec.configure do |config|
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
10
16
  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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KARASZI István
@@ -109,7 +109,21 @@ dependencies:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: 3.1.0
112
- description: Marketo REST API Facade
112
+ - !ruby/object:Gem::Dependency
113
+ name: codeclimate-test-reporter
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: 0.4.7
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: 0.4.7
126
+ description: This gem helps you to use the Marketo REST API
113
127
  email:
114
128
  - github@spam.raszi.hu
115
129
  - jalemieux@gmail.com
@@ -132,7 +146,6 @@ files:
132
146
  - lib/mrkt/concerns/import_leads.rb
133
147
  - lib/mrkt/errors.rb
134
148
  - lib/mrkt/faraday_middleware.rb
135
- - lib/mrkt/faraday_middleware/request.rb
136
149
  - lib/mrkt/faraday_middleware/response.rb
137
150
  - lib/mrkt/version.rb
138
151
  - mrkt.gemspec
@@ -144,7 +157,7 @@ files:
144
157
  - spec/spec_helper.rb
145
158
  - spec/support/initialized_client.rb
146
159
  - spec/support/webmock.rb
147
- homepage: ''
160
+ homepage: https://github.com/raszi/mrkt
148
161
  licenses:
149
162
  - MIT
150
163
  metadata: {}
@@ -167,7 +180,7 @@ rubyforge_project:
167
180
  rubygems_version: 2.4.3
168
181
  signing_key:
169
182
  specification_version: 4
170
- summary: ''
183
+ summary: Marketo REST API Facade
171
184
  test_files:
172
185
  - spec/concerns/authentication_spec.rb
173
186
  - spec/concerns/crud_leads_spec.rb
@@ -1,58 +0,0 @@
1
- require 'faraday_middleware'
2
-
3
- module Mrkt
4
- module FaradayMiddleware
5
- class Request < Faraday::Middleware
6
- def initialize(app, client_id, client_secret)
7
- super(app)
8
-
9
- @client_id = client_id
10
- @client_secret = client_secret
11
- end
12
-
13
- def call(env)
14
- authenticate(env) unless authenticated? || env[:authentication]
15
-
16
- env.request_headers[:authorization] = "Bearer #{@token}"
17
- @app.call(env)
18
- end
19
-
20
- def authenticated?
21
- @token && token_valid?
22
- end
23
-
24
- def token_valid?
25
- @valid_until && Time.now < @valid_until
26
- end
27
-
28
- def authenticate(orig_env)
29
- env = Faraday::Env.from(orig_env)
30
-
31
- body = env[:body]
32
- params = Faraday::Utils::ParamsHash.new
33
- params.update(
34
- grant_type: 'client_credentials',
35
- client_id: @client_id,
36
- client_secret: @client_secret
37
- )
38
- env[:authentication] = true
39
- env[:method] = :get
40
-
41
- env[:url] = env[:url].dup
42
- env[:url].path = '/identity/oauth/token'
43
- env[:url].query = params.to_query
44
-
45
- orig_env[:body] = body
46
-
47
- response = @app.call(env)
48
- data = response.body
49
-
50
- @token = data[:access_token]
51
- @token_type = data[:token_type]
52
- @expires_in = data[:expires_in]
53
- @valid_until = Time.now + data[:expires_in]
54
- @scope = data[:scope]
55
- end
56
- end
57
- end
58
- end