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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fea28fb6b44128149d673e0a44a7e709ae20ed9e8df8d23caba96eb61b57ba81
4
- data.tar.gz: 438ffc1b50e2bb7b625d67d09201498030e1882e5b6b250f01c37e0221c0de7c
3
+ metadata.gz: 563dc35fc8c63e68ca7f080f7b965493109dcb77d35905954f4144e5c5e91a93
4
+ data.tar.gz: 1bcb1cb945614e39418878e6636e7c3ab61fc1f89d3983e07edc083466f16bcc
5
5
  SHA512:
6
- metadata.gz: de00accf8fd3630b0cee809b05c952f1a51d6b0552c8ec8995b4ccfe99ee35b11555717c3b8be9292fe5906c1e3c5b19e6ab2a03f692aee72f476d84492e68aa
7
- data.tar.gz: ce9b7d848838ff6ce8e1508ac3e909d355aa6993d020149ac5d1706a4491d5ac973ec292c7226472569fe6fb58c48aa1b3de4c57e24b10a78e10be0e9c26826f
6
+ metadata.gz: a81440d9f63e8c4b000751fc6628771b690e4d0736edb406ec4550c35c29ff82ea89bd37741882c5982c6c4aef60a85a1dba8dd9d0bd385ab6c8ef645c3ad1eb
7
+ data.tar.gz: 6d4437e6f038188d134dfee9e576158ec390304a6061b5ce0cf912d07ba4b858b2b1d1030bcf40e037f1cc50e26b4d9864552cf4981766f917e7afa9c15c32d5
@@ -75,7 +75,7 @@ GEM
75
75
  ast (~> 2.4.0)
76
76
  psych (3.1.0)
77
77
  public_suffix (4.0.5)
78
- rack (2.2.2)
78
+ rack (2.2.3)
79
79
  rainbow (3.0.0)
80
80
  rake (13.0.1)
81
81
  rchardet (1.8.0)
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
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,3 @@
1
+ <response success="false">
2
+ <error id="5" message="Invalid phone number" />
3
+ </response>
@@ -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>
@@ -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: 'phone_number=123-256-7890').
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: '123-256-7890')
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: '123-256-7890') }.to raise_error(UplandMobileCommonsRest::InvalidMessageBody)
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.1 ruby lib
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.1"
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-09"
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.1
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-09 00:00:00.000000000 Z
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