upland_mobile_commons_rest 0.4.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 64826a63e52f8acfb89b11bffe980ecf792d85d46e1411d9b64c32bbfb370ebe
4
- data.tar.gz: 1531851674b67567bb8dc9bbb07d835b223e0bf947e7dc326dcc60c5300f1b44
3
+ metadata.gz: 7eeb5aa6f582aae208a7c1ed4e627a69454b7b5bad0edbba363c3276aa9e5bba
4
+ data.tar.gz: 4733707638a2af5f2d40ed67d409c297e60863c876c9aa6a8e1c8d133cab0a88
5
5
  SHA512:
6
- metadata.gz: f0b51a4a4a404ac3cc3b7652039adbd3d58420c15bd60844db1bd5869558913db700b1dc68e632ad4e2d2e3ceeb282ca1acaf2e457ee1015175565ea871d44e1
7
- data.tar.gz: 4b60067ac93f25cb21446d26d9dcd4bb170edd9548f9cb07dcc4d60e6bd122e3fae109bcd41dd9b7c7367da1d93259bf666eecc776740184690cae2b16cc3b0a
6
+ metadata.gz: 9b990cd60a602fd296391f8bbef791dce0d9137b5aee8868d96b02963895bcd6db6f13631147a9279db5f47ded6095e7073888c7dfcef9e90c0aba23285855df
7
+ data.tar.gz: 125fd17ffd7bbcf82932c6db8fe37817c5801c20fb616d92a8e32998910e537e6f08c9f72f484331da888445e019e715612dc9c688b29da02eb5fc2884ced697
data/README.md CHANGED
@@ -6,7 +6,7 @@ A ruby gem for interacting with the Upland Mobile Commons API.
6
6
  ## Usage
7
7
 
8
8
  ```ruby
9
- client = UplandMobileCommonsRest.new(username: 'user', password: 'password')
9
+ client = UplandMobileCommonsRest.new(api_key: 'api-key')
10
10
  # List Campaigns
11
11
  client.campaigns.list
12
12
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 1.0.1
data/example.rb CHANGED
@@ -8,7 +8,7 @@ require 'byebug'
8
8
 
9
9
  Dotenv.load('.env')
10
10
 
11
- client = UplandMobileCommonsRest.new(username: ENV['USERNAME'], password: ENV['PASSWORD']) # rubocop:disable Lint/UselessAssignment
11
+ client = UplandMobileCommonsRest.new(api_key: ENV['API_KEY']) # rubocop:disable Lint/UselessAssignment
12
12
 
13
13
  puts "Ready to call MobileCommons API using 'client' object"
14
14
  byebug # rubocop:disable Lint/Debugger
@@ -2,12 +2,10 @@
2
2
 
3
3
  module UplandMobileCommonsRest
4
4
  class Client < Vertebrae::API
5
- attr_accessor :username, :password, :company_key
5
+ attr_accessor :api_key
6
6
 
7
7
  def initialize(options = {}, &block)
8
- self.username = options[:username]
9
- self.password = options[:password]
10
- self.company_key = options[:company_key]
8
+ self.api_key = options.delete(:api_key)
11
9
  super(options, &block)
12
10
  end
13
11
 
@@ -28,10 +26,7 @@ module UplandMobileCommonsRest
28
26
  # Request middlewares, in the order they should run
29
27
  builder.use Faraday::Request::Multipart
30
28
  builder.use Faraday::Request::UrlEncoded
31
- if connection.configuration.authenticated?
32
- builder.use Faraday::Request::BasicAuthentication, connection.configuration.username,
33
- connection.configuration.password
34
- end
29
+ builder.use Faraday::Request::Authorization, 'Bearer', self.api_key
35
30
 
36
31
  # Response middlewares, in the *reverse* order they should run
37
32
  builder.use UplandMobileCommonsRest::TypedErrorMiddleware
@@ -3,17 +3,16 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe UplandMobileCommonsRest::Campaigns do
6
- let(:client) { UplandMobileCommonsRest::Client.new(username: 'username', password: 'password') }
6
+ let(:client) { UplandMobileCommonsRest::Client.new(api_key: 'abcde-123456') }
7
7
 
8
- subject { UplandMobileCommonsRest::Campaigns.new(client: client) }
8
+ subject { UplandMobileCommonsRest::Campaigns.new(client:) }
9
9
 
10
10
  it 'should initialize' do
11
11
  expect(subject.client).to eq(client)
12
12
  end
13
13
 
14
14
  context 'with credentials' do
15
- let(:username) { 'username' }
16
- let(:password) { 'password' }
15
+ let(:api_key) { 'abcde-123456' }
17
16
 
18
17
  describe 'list' do
19
18
  let(:response_body) { fixture('campaigns/list.xml') }
data/spec/client_spec.rb CHANGED
@@ -21,7 +21,7 @@ describe UplandMobileCommonsRest::Client do
21
21
  describe 'error handling' do
22
22
  let(:request_params) { {example: 'data'} }
23
23
 
24
- subject { UplandMobileCommonsRest::Client.new(username: 'foo', password: 'bar') }
24
+ subject { UplandMobileCommonsRest::Client.new(api_key: 'abcde-123456') }
25
25
 
26
26
  before :each do
27
27
  stub_request(:post, 'https://secure.mcommons.com/api/do_something')
data/spec/group_spec.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe UplandMobileCommonsRest::Groups do
6
- let(:client) { UplandMobileCommonsRest::Client.new(username: 'username', password: 'password') }
6
+ let(:client) { UplandMobileCommonsRest::Client.new(api_key: 'abcde-123456') }
7
7
 
8
8
  subject { UplandMobileCommonsRest::Groups.new(client: client) }
9
9
 
@@ -12,8 +12,7 @@ describe UplandMobileCommonsRest::Groups do
12
12
  end
13
13
 
14
14
  context 'with credentials' do
15
- let(:username) { 'username' }
16
- let(:password) { 'password' }
15
+ let(:api_key) { 'abcde-123456' }
17
16
 
18
17
  describe 'list' do
19
18
  let(:response_body) { fixture('groups/list.xml') }
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe UplandMobileCommonsRest::Profiles do
6
- let(:client) { UplandMobileCommonsRest::Client.new(username: 'username', password: 'password') }
6
+ let(:client) { UplandMobileCommonsRest::Client.new(api_key: 'abcde-123456') }
7
7
 
8
8
  subject { UplandMobileCommonsRest::Profiles.new(client: client) }
9
9
 
@@ -12,8 +12,7 @@ describe UplandMobileCommonsRest::Profiles do
12
12
  end
13
13
 
14
14
  context 'with credentials' do
15
- let(:username) { 'username' }
16
- let(:password) { 'password' }
15
+ let(:api_key) { 'abcde-123456' }
17
16
  let(:phone_number) { '123-256-7890' }
18
17
 
19
18
  describe 'get' do
@@ -2,5 +2,5 @@
2
2
 
3
3
  def stub_upland_mobile_commons_request(path, method:, body: nil)
4
4
  stub_request(method, "https://secure.mcommons.com/api/#{path}")
5
- .with(body: body, basic_auth: [username, password])
5
+ .with(body: body, headers: {'Authorization' => "Bearer #{api_key}"})
6
6
  end
@@ -4,9 +4,8 @@ require 'spec_helper'
4
4
 
5
5
  describe UplandMobileCommonsRest do
6
6
  it 'returns a client' do
7
- client = UplandMobileCommonsRest.new(username: 'foo', password: 'bar')
7
+ client = UplandMobileCommonsRest.new(api_key: 'abcde-123456')
8
8
  expect(client).to be_an_instance_of(UplandMobileCommonsRest::Client)
9
- expect(client.username).to eq('foo')
10
- expect(client.password).to eq('bar')
9
+ expect(client.api_key).to eq('abcde-123456')
11
10
  end
12
11
  end
@@ -2,11 +2,11 @@
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.4.0 ruby lib
5
+ # stub: upland_mobile_commons_rest 1.0.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "upland_mobile_commons_rest".freeze
9
- s.version = "0.4.0".freeze
9
+ s.version = "1.0.1".freeze
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]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upland_mobile_commons_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kathy Lu