sendgrid4r 1.2.1 → 1.3.0

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: eb7caee98231bb2a059edc759bb2a60ed9e36998
4
- data.tar.gz: 851393635739f5d439861e41a658e7fefbc28201
3
+ metadata.gz: f917e5bad6e118fb4038ed40d03c754cf0c47a29
4
+ data.tar.gz: 36b3c7f7bf0a50841a9a6970c017f76d41669c67
5
5
  SHA512:
6
- metadata.gz: 24f52934d7a0f7832b835fe47fc925d617dd1822673b8496d51a3f200b4b0329dcd5ff421b04605cd3db71e17ead302a926632684294ab6807594e5f45049510
7
- data.tar.gz: 0e0e57d4ab406865b937ec4478e61476b935c18315bb17f8fc717a9be99d679776dfebead26c257712b75ae99e80c54959592c3cc655af3d48d8de2bab15cbc0
6
+ metadata.gz: e58bdc185eee38e7a8e07a9ab6720639e65d20fb4484e8ab98b94223a9b100f210bd5cc47be5adc76c58bcc3fe0c4702e898b3e611aa98102a1706fe39f11bc5
7
+ data.tar.gz: fde6e1b9d2abf15276d6f700a2d169c583752c73b946b364aabb3bdd30f1cabbb5f6564cf7d3756383d3bbaffa33ff3078d246115af1ab02e8e1edc6901d3cfe
data/.rubocop.yml CHANGED
@@ -7,6 +7,10 @@ MethodLength:
7
7
  CountComments: true # count full line comments?
8
8
  Max: 20
9
9
 
10
+ # Change limitation of module length
11
+ ModuleLength:
12
+ Max: 300
13
+
10
14
  # Change limitation of the number of params
11
15
  ParameterLists:
12
16
  Max: 8
@@ -16,10 +20,6 @@ ParameterLists:
16
20
  AbcSize:
17
21
  Max: 21
18
22
 
19
- # Change limitation of the number of '/' within %r
20
- RegexpLiteral:
21
- MaxSlashes: 0
22
-
23
23
  # Change numeric literals
24
24
  NumericLiterals:
25
25
  MinDigits: 20
@@ -18,7 +18,7 @@ module SendGrid4r
18
18
  aggregated_by: nil,
19
19
  country: nil,
20
20
  &block
21
- )
21
+ )
22
22
  params = {
23
23
  start_date: start_date,
24
24
  end_date: end_date,
@@ -34,7 +34,7 @@ module SendGrid4r
34
34
  end_date: nil,
35
35
  aggregated_by: nil,
36
36
  &block
37
- )
37
+ )
38
38
  params = {
39
39
  start_date: start_date,
40
40
  end_date: end_date,
@@ -49,7 +49,7 @@ module SendGrid4r
49
49
  end_date: nil,
50
50
  aggregated_by: nil,
51
51
  &block
52
- )
52
+ )
53
53
  params = {
54
54
  start_date: start_date,
55
55
  end_date: end_date,
@@ -65,7 +65,7 @@ module SendGrid4r
65
65
  aggregated_by: nil,
66
66
  client_type:,
67
67
  &block
68
- )
68
+ )
69
69
  params = {
70
70
  start_date: start_date,
71
71
  end_date: end_date,
@@ -83,7 +83,7 @@ module SendGrid4r
83
83
  aggregated_by: nil,
84
84
  esps: nil,
85
85
  &block
86
- )
86
+ )
87
87
  params = {
88
88
  start_date: start_date,
89
89
  end_date: end_date,
@@ -101,7 +101,7 @@ module SendGrid4r
101
101
  aggregated_by: nil,
102
102
  browsers: nil,
103
103
  &block
104
- )
104
+ )
105
105
  params = {
106
106
  start_date: start_date,
107
107
  end_date: end_date,
@@ -18,7 +18,7 @@ module SendGrid4r
18
18
  MONTH = 'month'
19
19
  end
20
20
 
21
- TopStat = Struct.new(:date, :stats)
21
+ TopStat = Struct.new(:date, :stats)
22
22
  Stat = Struct.new(:metrics, :name, :type)
23
23
  Metric = Struct.new(
24
24
  :blocks,
@@ -16,8 +16,10 @@ module SendGrid4r
16
16
  :phone, :state, :website, :zip
17
17
  )
18
18
 
19
- def self.url
20
- url = "#{BASE_URL}/user/profile"
19
+ Account = Struct.new(:type, :reputation)
20
+
21
+ def self.url(path)
22
+ url = "#{BASE_URL}/user/#{path}"
21
23
  url
22
24
  end
23
25
 
@@ -37,16 +39,29 @@ module SendGrid4r
37
39
  )
38
40
  end
39
41
 
42
+ def self.create_account(resp)
43
+ return resp if resp.nil?
44
+ Account.new(
45
+ resp['type'],
46
+ resp['reputation']
47
+ )
48
+ end
49
+
40
50
  def get_user_profile(&block)
41
- resp = get(@auth, SendGrid4r::REST::Users.url, nil, &block)
51
+ resp = get(@auth, SendGrid4r::REST::Users.url('profile'), nil, &block)
42
52
  SendGrid4r::REST::Users.create_profile(resp)
43
53
  end
44
54
 
45
- def patch_user_profile(params: nil, &block)
46
- endpoint = SendGrid4r::REST::Users.url
55
+ def patch_user_profile(params:, &block)
56
+ endpoint = SendGrid4r::REST::Users.url('profile')
47
57
  resp = patch(@auth, endpoint, params, &block)
48
58
  SendGrid4r::REST::Users.create_profile(resp)
49
59
  end
60
+
61
+ def get_user_account(&block)
62
+ resp = get(@auth, SendGrid4r::REST::Users.url('account'), nil, &block)
63
+ SendGrid4r::REST::Users.create_account(resp)
64
+ end
50
65
  end
51
66
  end
52
67
  end
@@ -103,9 +103,20 @@ module SendGrid4r
103
103
  ValidationResult.new(resp['valid'], resp['reason'])
104
104
  end
105
105
 
106
- def get_wl_links(&block)
106
+ def get_wl_links(
107
+ limit: nil, offset: nil, exclude_subusers: nil, username: nil,
108
+ domain: nil, &block
109
+ )
110
+ params = {}
111
+ params['limit'] = limit unless limit.nil?
112
+ params['offset'] = offset unless offset.nil?
113
+ unless exclude_subusers.nil?
114
+ params['exclude_subusers'] = exclude_subusers
115
+ end
116
+ params['username'] = username unless username.nil?
117
+ params['domain'] = domain unless domain.nil?
107
118
  endpoint = SendGrid4r::REST::Whitelabel::Links.url
108
- resp = get(@auth, endpoint, nil, &block)
119
+ resp = get(@auth, endpoint, params, &block)
109
120
  SendGrid4r::REST::Whitelabel::Links.create_links(resp)
110
121
  end
111
122
 
@@ -2,5 +2,5 @@
2
2
  # SendGrid API v3 wrapper implementation.
3
3
  #
4
4
  module SendGrid4r
5
- VERSION = '1.2.1'
5
+ VERSION = '1.3.0'
6
6
  end
data/sendgrid4r.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency('rest-client', '>=1.8.0', '<1.9.0')
22
- spec.add_development_dependency('rubocop', '>=0.29.0', '<0.30.0')
22
+ spec.add_development_dependency('rubocop', '>=0.29.0', '<0.34.3')
23
23
  spec.add_development_dependency('bundler', '>=1.6.0', '<1.11.0')
24
- spec.add_development_dependency('rspec', '3.1.0')
25
- spec.add_development_dependency('dotenv', '>=0.11.0', '<0.12.0')
24
+ spec.add_development_dependency('rspec', '3.3.0')
25
+ spec.add_development_dependency('dotenv', '=0.11.0', '<=2.0.2')
26
26
  end
data/spec/client_spec.rb CHANGED
@@ -253,12 +253,13 @@ describe SendGrid4r::Client do
253
253
  # Users API
254
254
  expect(@client.respond_to?('get_user_profile')).to eq(true)
255
255
  expect(@client.respond_to?('patch_user_profile')).to eq(true)
256
+ expect(@client.respond_to?('get_user_account')).to eq(true)
256
257
  end
257
258
  end
258
259
 
259
260
  describe 'VERSION' do
260
261
  it 'returns VERSION value' do
261
- expect(SendGrid4r::VERSION).to eq('1.2.1')
262
+ expect(SendGrid4r::VERSION).to eq('1.3.0')
262
263
  end
263
264
  end
264
265
  end
@@ -11,7 +11,7 @@ describe SendGrid4r::REST::Subusers do
11
11
  @username2 = ENV['SUBUSER2']
12
12
  @username3 = ENV['SUBUSER3']
13
13
  @email1 = ENV['MAIL']
14
- @password1 = ENV['PASS']
14
+ @password1 = ENV['PASS']
15
15
  @ip = @client.get_ips[0].ip
16
16
  # celan up test env
17
17
  subusers = @client.get_subusers
@@ -35,6 +35,16 @@ describe SendGrid4r::REST::Users do
35
35
  raise e
36
36
  end
37
37
  end
38
+
39
+ it '#get_user_account' do
40
+ begin
41
+ account = @client.get_user_account
42
+ expect(account).to be_a(SendGrid4r::REST::Users::Account)
43
+ rescue RestClient::ExceptionWithResponse => e
44
+ puts e.inspect
45
+ raise e
46
+ end
47
+ end
38
48
  end
39
49
  end
40
50
 
@@ -60,10 +70,37 @@ describe SendGrid4r::REST::Users do
60
70
  )
61
71
  end
62
72
 
73
+ let(:account) do
74
+ JSON.parse(
75
+ '{'\
76
+ '"type": "free",'\
77
+ '"reputation": 99.7'\
78
+ '}'
79
+ )
80
+ end
81
+
63
82
  it '#get_user_profile' do
64
83
  allow(client).to receive(:execute).and_return(profile)
65
84
  actual = client.get_user_profile
66
85
  expect(actual).to be_a(SendGrid4r::REST::Users::Profile)
86
+ end
87
+
88
+ it '#patch_user_profile' do
89
+ allow(client).to receive(:execute).and_return(profile)
90
+ params = {}
91
+ params['city'] = 'nakano'
92
+ actual = client.patch_user_profile(params: params)
93
+ expect(actual).to be_a(SendGrid4r::REST::Users::Profile)
94
+ end
95
+
96
+ it '#get_user_account' do
97
+ allow(client).to receive(:execute).and_return(account)
98
+ actual = client.get_user_account
99
+ expect(actual).to be_a(SendGrid4r::REST::Users::Account)
100
+ end
101
+
102
+ it 'creates profile instance' do
103
+ actual = SendGrid4r::REST::Users.create_profile(profile)
67
104
  expect(actual.address).to eq('814 West Chapman Avenue')
68
105
  expect(actual.city).to eq('Orange')
69
106
  expect(actual.company).to eq('SendGrid')
@@ -74,5 +111,11 @@ describe SendGrid4r::REST::Users do
74
111
  expect(actual.website).to eq('http://www.sendgrid.com')
75
112
  expect(actual.zip).to eq('92868')
76
113
  end
114
+
115
+ it 'creates account instance' do
116
+ actual = SendGrid4r::REST::Users.create_account(account)
117
+ expect(actual.type).to eq('free')
118
+ expect(actual.reputation).to eq(99.7)
119
+ end
77
120
  end
78
121
  end
@@ -62,7 +62,10 @@ describe SendGrid4r::REST::Whitelabel::Links do
62
62
  context 'without block call' do
63
63
  it '#get_wl_links' do
64
64
  begin
65
- links = @client.get_wl_links
65
+ links = @client.get_wl_links(
66
+ limit: 100, offset: 0,
67
+ exclude_subusers: true, username: 'somebody', domain: 'example.com'
68
+ )
66
69
  expect(links).to be_a(Array)
67
70
  links.each do |link|
68
71
  expect(link).to be_a(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - awwa500@gmail.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2015-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 0.29.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 0.30.0
42
+ version: 0.34.3
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 0.29.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 0.30.0
52
+ version: 0.34.3
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -76,34 +76,34 @@ dependencies:
76
76
  requirements:
77
77
  - - '='
78
78
  - !ruby/object:Gem::Version
79
- version: 3.1.0
79
+ version: 3.3.0
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - '='
85
85
  - !ruby/object:Gem::Version
86
- version: 3.1.0
86
+ version: 3.3.0
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: dotenv
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ">="
91
+ - - '='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 0.11.0
94
- - - "<"
94
+ - - "<="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.12.0
96
+ version: 2.0.2
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.11.0
104
- - - "<"
104
+ - - "<="
105
105
  - !ruby/object:Gem::Version
106
- version: 0.12.0
106
+ version: 2.0.2
107
107
  description: SendGrid Web API v3 module
108
108
  email:
109
109
  - awwa500@gmail.com
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  version: '0'
225
225
  requirements: []
226
226
  rubyforge_project:
227
- rubygems_version: 2.2.2
227
+ rubygems_version: 2.2.5
228
228
  signing_key:
229
229
  specification_version: 4
230
230
  summary: SendGrid Web API v3 module