sendgrid4r 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sendgrid4r/rest/api.rb +2 -0
- data/lib/sendgrid4r/rest/users/users.rb +52 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/spec/client_spec.rb +5 -1
- data/spec/rest/users/users_spec.rb +78 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d9fe109c54eb51bf889602332007cf01cee0b0
|
4
|
+
data.tar.gz: 432030e7df5cdd4bac8c6c37aa2c851d4c812d62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1bf3eb32ea9f95972cf026a6aace7671e57f33c85e49a678b662dd8aca66b96a3b98ff5587404acf50cb8d613f086cb8f5886631383423ba95c09bb8c2236e6
|
7
|
+
data.tar.gz: 6d0eb5696b42f4e81074a061f4029fdeb7aee8e18351c094b6d62c8d0b8a61a5aa9c52dc28e98cf199e0bce94607bff729305fafbbbb93a2b683e6002935983a
|
data/lib/sendgrid4r/rest/api.rb
CHANGED
@@ -33,6 +33,7 @@ require 'sendgrid4r/rest/email_activity/email_activity'
|
|
33
33
|
require 'sendgrid4r/rest/whitelabel/domains'
|
34
34
|
require 'sendgrid4r/rest/whitelabel/ips'
|
35
35
|
require 'sendgrid4r/rest/whitelabel/links'
|
36
|
+
require 'sendgrid4r/rest/users/users'
|
36
37
|
|
37
38
|
module SendGrid4r
|
38
39
|
module REST
|
@@ -71,6 +72,7 @@ module SendGrid4r
|
|
71
72
|
include SendGrid4r::REST::Whitelabel::Domains
|
72
73
|
include SendGrid4r::REST::Whitelabel::Ips
|
73
74
|
include SendGrid4r::REST::Whitelabel::Links
|
75
|
+
include SendGrid4r::REST::Users
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'sendgrid4r/rest/request'
|
5
|
+
|
6
|
+
module SendGrid4r
|
7
|
+
module REST
|
8
|
+
#
|
9
|
+
# SendGrid Web API v3 Users
|
10
|
+
#
|
11
|
+
module Users
|
12
|
+
include SendGrid4r::REST::Request
|
13
|
+
|
14
|
+
Profile = Struct.new(
|
15
|
+
:address, :city, :company, :country, :first_name, :last_name,
|
16
|
+
:phone, :state, :website, :zip
|
17
|
+
)
|
18
|
+
|
19
|
+
def self.url
|
20
|
+
url = "#{BASE_URL}/user/profile"
|
21
|
+
url
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create_profile(resp)
|
25
|
+
return resp if resp.nil?
|
26
|
+
Profile.new(
|
27
|
+
resp['address'],
|
28
|
+
resp['city'],
|
29
|
+
resp['company'],
|
30
|
+
resp['country'],
|
31
|
+
resp['first_name'],
|
32
|
+
resp['last_name'],
|
33
|
+
resp['phone'],
|
34
|
+
resp['state'],
|
35
|
+
resp['website'],
|
36
|
+
resp['zip']
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_user_profile(&block)
|
41
|
+
resp = get(@auth, SendGrid4r::REST::Users.url, nil, &block)
|
42
|
+
SendGrid4r::REST::Users.create_profile(resp)
|
43
|
+
end
|
44
|
+
|
45
|
+
def patch_user_profile(params: params, &block)
|
46
|
+
endpoint = SendGrid4r::REST::Users.url
|
47
|
+
resp = patch(@auth, endpoint, params, &block)
|
48
|
+
SendGrid4r::REST::Users.create_profile(resp)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/sendgrid4r/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -236,12 +236,16 @@ describe SendGrid4r::Client do
|
|
236
236
|
expect(@client.respond_to?('get_associated_wl_link')).to eq(true)
|
237
237
|
expect(@client.respond_to?('disassociate_wl_link')).to eq(true)
|
238
238
|
expect(@client.respond_to?('associate_wl_link')).to eq(true)
|
239
|
+
|
240
|
+
# Users API
|
241
|
+
expect(@client.respond_to?('get_user_profile')).to eq(true)
|
242
|
+
expect(@client.respond_to?('patch_user_profile')).to eq(true)
|
239
243
|
end
|
240
244
|
end
|
241
245
|
|
242
246
|
describe 'VERSION' do
|
243
247
|
it 'returns VERSION value' do
|
244
|
-
expect(SendGrid4r::VERSION).to eq('1.
|
248
|
+
expect(SendGrid4r::VERSION).to eq('1.1.0')
|
245
249
|
end
|
246
250
|
end
|
247
251
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::REST::Users do
|
5
|
+
describe 'integration test', :it do
|
6
|
+
before do
|
7
|
+
begin
|
8
|
+
Dotenv.load
|
9
|
+
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
raise e
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'without block call' do
|
17
|
+
it '#get_user_profile' do
|
18
|
+
begin
|
19
|
+
profile = @client.get_user_profile
|
20
|
+
expect(profile).to be_a(SendGrid4r::REST::Users::Profile)
|
21
|
+
rescue RestClient::ExceptionWithResponse => e
|
22
|
+
puts e.inspect
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it '#patch_user_profile' do
|
28
|
+
begin
|
29
|
+
params = {}
|
30
|
+
params['city'] = 'nakano'
|
31
|
+
profile = @client.patch_user_profile(params: params)
|
32
|
+
expect(profile).to be_a(SendGrid4r::REST::Users::Profile)
|
33
|
+
rescue RestClient::ExceptionWithResponse => e
|
34
|
+
puts e.inspect
|
35
|
+
raise e
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'unit test', :ut do
|
42
|
+
let(:client) do
|
43
|
+
SendGrid4r::Client.new(api_key: '')
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:profile) do
|
47
|
+
JSON.parse(
|
48
|
+
'{'\
|
49
|
+
'"address":"814 West Chapman Avenue",'\
|
50
|
+
'"city":"Orange",'\
|
51
|
+
'"company":"SendGrid",'\
|
52
|
+
'"country":"US",'\
|
53
|
+
'"first_name":"Test",'\
|
54
|
+
'"last_name":"User",'\
|
55
|
+
'"phone":"555-555-5555",'\
|
56
|
+
'"state":"CA",'\
|
57
|
+
'"website":"http://www.sendgrid.com",'\
|
58
|
+
'"zip":"92868"'\
|
59
|
+
'}'
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#get_user_profile' do
|
64
|
+
allow(client).to receive(:execute).and_return(profile)
|
65
|
+
actual = client.get_user_profile
|
66
|
+
expect(actual).to be_a(SendGrid4r::REST::Users::Profile)
|
67
|
+
expect(actual.address).to eq('814 West Chapman Avenue')
|
68
|
+
expect(actual.city).to eq('Orange')
|
69
|
+
expect(actual.company).to eq('SendGrid')
|
70
|
+
expect(actual.first_name).to eq('Test')
|
71
|
+
expect(actual.last_name).to eq('User')
|
72
|
+
expect(actual.phone).to eq('555-555-5555')
|
73
|
+
expect(actual.state).to eq('CA')
|
74
|
+
expect(actual.website).to eq('http://www.sendgrid.com')
|
75
|
+
expect(actual.zip).to eq('92868')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
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.
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/sendgrid4r/rest/subusers/subusers.rb
|
157
157
|
- lib/sendgrid4r/rest/templates/templates.rb
|
158
158
|
- lib/sendgrid4r/rest/templates/versions.rb
|
159
|
+
- lib/sendgrid4r/rest/users/users.rb
|
159
160
|
- lib/sendgrid4r/rest/whitelabel/domains.rb
|
160
161
|
- lib/sendgrid4r/rest/whitelabel/ips.rb
|
161
162
|
- lib/sendgrid4r/rest/whitelabel/links.rb
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- spec/rest/subusers/subusers_spec.rb
|
195
196
|
- spec/rest/templates/templates_spec.rb
|
196
197
|
- spec/rest/templates/versions_spec.rb
|
198
|
+
- spec/rest/users/users_spec.rb
|
197
199
|
- spec/rest/whitelabel/domains_spec.rb
|
198
200
|
- spec/rest/whitelabel/ips_spec.rb
|
199
201
|
- spec/rest/whitelabel/links_spec.rb
|
@@ -256,6 +258,7 @@ test_files:
|
|
256
258
|
- spec/rest/subusers/subusers_spec.rb
|
257
259
|
- spec/rest/templates/templates_spec.rb
|
258
260
|
- spec/rest/templates/versions_spec.rb
|
261
|
+
- spec/rest/users/users_spec.rb
|
259
262
|
- spec/rest/whitelabel/domains_spec.rb
|
260
263
|
- spec/rest/whitelabel/ips_spec.rb
|
261
264
|
- spec/rest/whitelabel/links_spec.rb
|