upland_mobile_commons_rest 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/VERSION +1 -1
- data/lib/upland_mobile_commons_rest/profiles.rb +12 -1
- data/spec/fixtures/error_profile_not_found.xml +3 -0
- data/spec/fixtures/profiles/get.xml +42 -0
- data/spec/profiles_spec.rb +33 -3
- data/upland_mobile_commons_rest.gemspec +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 563dc35fc8c63e68ca7f080f7b965493109dcb77d35905954f4144e5c5e91a93
|
4
|
+
data.tar.gz: 1bcb1cb945614e39418878e6636e7c3ab61fc1f89d3983e07edc083466f16bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a81440d9f63e8c4b000751fc6628771b690e4d0736edb406ec4550c35c29ff82ea89bd37741882c5982c6c4aef60a85a1dba8dd9d0bd385ab6c8ef645c3ad1eb
|
7
|
+
data.tar.gz: 6d4437e6f038188d134dfee9e576158ec390304a6061b5ce0cf912d07ba4b858b2b1d1030bcf40e037f1cc50e26b4d9864552cf4981766f917e7afa9c15c32d5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Upland Mobile Commons Ruby Gem
|
2
2
|
[![Build Status](https://travis-ci.org/controlshift/upland_mobile_commons_rest.svg?branch=master)](https://travis-ci.org/controlshift/upland_mobile_commons_rest)
|
3
3
|
|
4
|
-
A ruby gem for interacting with the Upland Mobile Commons API.
|
4
|
+
A ruby gem for interacting with the Upland Mobile Commons API.
|
5
5
|
|
6
6
|
## Usage
|
7
7
|
|
@@ -15,5 +15,8 @@ client.groups.create('Chocolate Lovers')
|
|
15
15
|
|
16
16
|
# create/update a profile
|
17
17
|
client.profiles.update(phone_number: '123-456-7890')
|
18
|
+
|
19
|
+
# retrieve a profile by its phone number
|
20
|
+
client.profiles.get('123-456-7890')
|
18
21
|
```
|
19
22
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -1,8 +1,19 @@
|
|
1
1
|
module UplandMobileCommonsRest
|
2
2
|
class Profiles < Base
|
3
|
+
def base_path
|
4
|
+
'profile'
|
5
|
+
end
|
6
|
+
|
7
|
+
def get(phone_number)
|
8
|
+
resp = client.get_request("#{base_path}?phone_number=#{CGI.escape(phone_number)}")
|
9
|
+
resp.body['response']['profile']
|
10
|
+
# API returns error id '5' (invalid phone number) when profile with phone number is not found
|
11
|
+
rescue UplandMobileCommonsRest::InvalidPhoneNumber
|
12
|
+
nil
|
13
|
+
end
|
3
14
|
|
4
15
|
def update(params)
|
5
16
|
client.post_request('profile_update', params)
|
6
17
|
end
|
7
18
|
end
|
8
|
-
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<response success="true">
|
3
|
+
<profile id="34xxxxxxx">
|
4
|
+
<first_name>John</first_name>
|
5
|
+
<last_name>Doe</last_name>
|
6
|
+
<phone_number>12025551234</phone_number>
|
7
|
+
<email />
|
8
|
+
<status>Active subscriber</status>
|
9
|
+
<created_at>2019-06-21 14:49:40 UTC</created_at>
|
10
|
+
<updated_at>2019-06-21 14:49:40 UTC</updated_at>
|
11
|
+
<opted_out_at />
|
12
|
+
<opted_out_source />
|
13
|
+
<source type="API" name="User1" email="user1@domain.com" />
|
14
|
+
<address>
|
15
|
+
<street1 />
|
16
|
+
<street2 />
|
17
|
+
<city />
|
18
|
+
<state />
|
19
|
+
<postal_code />
|
20
|
+
<country>US</country>
|
21
|
+
</address>
|
22
|
+
<last_saved_location>
|
23
|
+
<latitude>38.906639</latitude>
|
24
|
+
<longitude>-77.016577</longitude>
|
25
|
+
<precision>state</precision>
|
26
|
+
<city />
|
27
|
+
<state>DC</state>
|
28
|
+
<postal_code />
|
29
|
+
<country>US</country>
|
30
|
+
</last_saved_location>
|
31
|
+
<custom_columns>
|
32
|
+
<custom_column name="Age" />
|
33
|
+
<custom_column name="Favorite animal" />
|
34
|
+
<custom_column name="Yes/NO" />
|
35
|
+
</custom_columns>
|
36
|
+
<subscriptions>
|
37
|
+
<subscription campaign_id="162xxx" campaign_name="MC_test2" campaign_description="" opt_in_path_id="" status="Active" opt_in_source="User1" created_at="2019-06-21T14:49:40Z" activated_at="2019-06-22T20:24:36Z" opted_out_at="" opt_out_source="" />
|
38
|
+
</subscriptions>
|
39
|
+
<integrations></integrations>
|
40
|
+
<clicks></clicks>
|
41
|
+
</profile>
|
42
|
+
</response>
|
data/spec/profiles_spec.rb
CHANGED
@@ -12,10 +12,40 @@ describe UplandMobileCommonsRest::Profiles do
|
|
12
12
|
context 'with credentials' do
|
13
13
|
let(:username) { 'username' }
|
14
14
|
let(:password) { 'password' }
|
15
|
+
let(:phone_number) { '123-256-7890' }
|
16
|
+
|
17
|
+
describe 'get' do
|
18
|
+
before(:each) do
|
19
|
+
stub_upland_mobile_commons_request("profile?phone_number=#{phone_number}", method: :get).
|
20
|
+
to_return(status: 200, body: response_body)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'success' do
|
24
|
+
let(:response_body) { fixture('profiles/get.xml') }
|
25
|
+
|
26
|
+
it 'should return profile data' do
|
27
|
+
resp = subject.get(phone_number)
|
28
|
+
expect(resp).to_not be_nil
|
29
|
+
expect(resp['first_name']).to eq('John')
|
30
|
+
expect(resp['last_name']).to eq('Doe')
|
31
|
+
expect(resp['phone_number']).to eq('12025551234')
|
32
|
+
expect(resp['id']).to eq('34xxxxxxx')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'error' do
|
37
|
+
let(:response_body) { fixture('error_profile_not_found.xml') }
|
38
|
+
|
39
|
+
it 'should return nil and not raise' do
|
40
|
+
resp = subject.get(phone_number)
|
41
|
+
expect(resp).to be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
15
45
|
|
16
46
|
describe 'update' do
|
17
47
|
before(:each) do
|
18
|
-
stub_upland_mobile_commons_request('profile_update', method: :post, body:
|
48
|
+
stub_upland_mobile_commons_request('profile_update', method: :post, body: "phone_number=#{phone_number}").
|
19
49
|
to_return(status: 200, body: response_body)
|
20
50
|
end
|
21
51
|
|
@@ -23,7 +53,7 @@ describe UplandMobileCommonsRest::Profiles do
|
|
23
53
|
let(:response_body) { fixture('profiles/update.xml') }
|
24
54
|
|
25
55
|
it 'should succeed' do
|
26
|
-
resp = subject.update(phone_number:
|
56
|
+
resp = subject.update(phone_number: phone_number)
|
27
57
|
expect(resp).to_not be_nil
|
28
58
|
end
|
29
59
|
end
|
@@ -32,7 +62,7 @@ describe UplandMobileCommonsRest::Profiles do
|
|
32
62
|
let(:response_body) { fixture('error.xml') }
|
33
63
|
|
34
64
|
it 'should raise' do
|
35
|
-
expect { subject.update(phone_number:
|
65
|
+
expect { subject.update(phone_number: phone_number) }.to raise_error(UplandMobileCommonsRest::InvalidMessageBody)
|
36
66
|
end
|
37
67
|
end
|
38
68
|
end
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: upland_mobile_commons_rest 0.0
|
5
|
+
# stub: upland_mobile_commons_rest 0.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "upland_mobile_commons_rest".freeze
|
9
|
-
s.version = "0.0
|
9
|
+
s.version = "0.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Nathan Woodhull".freeze]
|
14
|
-
s.date = "2020-06-
|
14
|
+
s.date = "2020-06-25"
|
15
15
|
s.description = "A simple ruby API client gem for the Upland Mobile Commons REST API".freeze
|
16
16
|
s.email = "nathan@controlshiftlabs.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upland_mobile_commons_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Woodhull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vertebrae
|
@@ -194,8 +194,10 @@ files:
|
|
194
194
|
- spec/client_spec.rb
|
195
195
|
- spec/fixtures/campaigns/list.xml
|
196
196
|
- spec/fixtures/error.xml
|
197
|
+
- spec/fixtures/error_profile_not_found.xml
|
197
198
|
- spec/fixtures/groups/create.xml
|
198
199
|
- spec/fixtures/groups/list.xml
|
200
|
+
- spec/fixtures/profiles/get.xml
|
199
201
|
- spec/fixtures/profiles/update.xml
|
200
202
|
- spec/group_spec.rb
|
201
203
|
- spec/profiles_spec.rb
|