nvlope 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8cd510beb0984f8e9ba22af3a1e68663d875669b
4
+ data.tar.gz: 6ef841b1008c40533ed7dd2a1e9541c89648dca8
5
+ SHA512:
6
+ metadata.gz: 53da464862a6a87a2a01a1384cd11cdd650842b1876c10e88e2b29838400d5d9c16ce120c20c907e8c2bd8908ca9e9b14e7fa16a6728d0a85e2b55bf4a0d238d
7
+ data.tar.gz: 4fb3d419f8d0d2578b7fa78a06e3f57ec9ac03eb6ad0747849529fb7d1f2716dc7611402126b38f5f34c52a2e02e849da4d82538b54816f7d7832f013ea62c3c
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nvlope.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jared Grippe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,73 @@
1
+ # Nvlope
2
+
3
+ Ruby wrapper for the nvlope.com API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nvlope'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nvlope
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+
23
+ evlope = Evlope.new(
24
+ username: 'INTENTIONALLY LEFT BLANK',
25
+ password: 'INTENTIONALLY LEFT BLANK',
26
+ client_id: 'INTENTIONALLY LEFT BLANK',
27
+ client_secret: 'INTENTIONALLY LEFT BLANK',
28
+ )
29
+
30
+ evlope.get_access_token
31
+ evlope.revoke_access_token
32
+ evlope.get_session
33
+ evlope.mail.send
34
+
35
+ evlope.messages.query
36
+ evlope.messages.bulk_get
37
+ evlope.messages.delete
38
+ evlope.messages.unread
39
+ evlope.messages.update_labels
40
+ evlope.messages.get_labels
41
+
42
+ evlope.notification.receive
43
+
44
+ evlope.files.upload
45
+ evlope.files.query
46
+ evlope.files.delete
47
+ evlope.files.set_expiration
48
+ evlope.files.get_public_link
49
+ evlope.files.get_private_link
50
+
51
+ evlope.account.profile
52
+ evlope.account.quota
53
+ evlope.account.mailboxes
54
+ evlope.account.domains
55
+
56
+ evlope.contacts.create
57
+ evlope.contacts.update
58
+ evlope.contacts.list
59
+ evlope.contacts.delete
60
+
61
+ ```
62
+
63
+ ## Documentation
64
+
65
+ http://developer.nvlope.com/
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( http://github.com/<my-github-username>/nvlope/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,105 @@
1
+ require 'uri'
2
+ require 'httparty'
3
+ require 'nvlope/version'
4
+
5
+ class Nvlope
6
+
7
+ autoload :Arguments, 'nvlope/arguments'
8
+ autoload :Model, 'nvlope/model'
9
+ autoload :Session, 'nvlope/session'
10
+ autoload :AccessToken, 'nvlope/access_token'
11
+ autoload :Account, 'nvlope/account'
12
+ autoload :Client, 'nvlope/client'
13
+ autoload :Messages, 'nvlope/messages'
14
+ autoload :MessageCollection, 'nvlope/message_collection'
15
+ autoload :Message, 'nvlope/message'
16
+ autoload :EmailAddress, 'nvlope/email_address'
17
+
18
+ def self.Arguments hash
19
+ Nvlope::Arguments.new hash
20
+ end
21
+
22
+ def initialize arguments
23
+ arguments = Nvlope::Arguments(arguments)
24
+
25
+ @username = arguments.require(:username ).to_s
26
+ @password = arguments.require(:password ).to_s
27
+ @client_id = arguments.require(:client_id ).to_s
28
+ @client_secret = arguments.require(:client_secret).to_s
29
+ @grant_type = arguments.optional(:grant_type ){ 'password' }.to_s
30
+ @domain = arguments.optional(:domain ){ 'https://api.nvlope.com/' }.to_s
31
+ @api_version = arguments.optional(:api_version){ 'v1' }.to_s
32
+ end
33
+
34
+ attr_accessor :grant_type, :username, :password, :client_id, :client_secret, :domain, :api_version
35
+
36
+ def url path
37
+ File.join(domain, api_version, path)
38
+ end
39
+
40
+ def access_token
41
+ @access_token ||= AccessToken.new(self, get_access_token)
42
+ end
43
+
44
+ def session
45
+ @session ||= Session.new(self, get_session)
46
+ end
47
+
48
+ def messages
49
+ @messages ||= Messages.new(self)
50
+ end
51
+
52
+ def request method, path, query={}, headers={}
53
+ headers['Authorization'] ||= "Bearer #{access_token}"
54
+ url = url(path)
55
+ # puts "Nvlope: #{method.upcase} #{url}"
56
+ HTTParty.send(method, url, query: query, headers: headers)
57
+ end
58
+
59
+
60
+ def get_access_token
61
+ @access_token = begin
62
+ url = url('oauth2/token')
63
+ # puts "Nvlope: POST #{url}"
64
+ response = HTTParty.post(url, query:{
65
+ grant_type: grant_type,
66
+ username: username,
67
+ password: password,
68
+ client_id: client_id,
69
+ client_secret: client_secret,
70
+ })
71
+ response['access_token']
72
+ end
73
+ end
74
+
75
+ def revoke_access_token
76
+ # DELETE v1/oauth2/token
77
+ response = request(:delete, 'oauth2/token')
78
+ return false unless response.code < 300
79
+ @access_token = nil
80
+ response
81
+ end
82
+
83
+ def get_session
84
+ request(:get, '/oauth2/session')
85
+ end
86
+
87
+
88
+ def to_hash
89
+ {
90
+ username: username,
91
+ password: password,
92
+ client_id: client_id,
93
+ client_secret: client_secret,
94
+ grant_type: grant_type,
95
+ domain: domain,
96
+ api_version: api_version,
97
+ }
98
+ end
99
+
100
+ def inspect
101
+ attributes = to_hash.map{|k,v| "#{k}: #{v.inspect}" }.join(', ')
102
+ %(#<#{self.class} #{attributes}>)
103
+ end
104
+
105
+ end
@@ -0,0 +1,9 @@
1
+ class Nvlope::AccessToken < String
2
+
3
+ def initialize nvlope, string
4
+ @nvlope = nvlope
5
+ super(string)
6
+ end
7
+ attr_reader :nvlope
8
+
9
+ end
@@ -0,0 +1,30 @@
1
+ class Nvlope::Account
2
+
3
+ def initialize nvlope, raw
4
+ @nvlope = nvlope
5
+ @id = raw['id']
6
+ @handle = raw['handle']
7
+ @first_name = raw['first_name']
8
+ @last_name = raw['last_name']
9
+ @url = raw['url']
10
+ @company = raw['company']
11
+ end
12
+ attr_reader :nvlope, :raw, :id, :handle, :first_name, :last_name, :url, :company
13
+
14
+ def to_hash
15
+ {
16
+ id: id,
17
+ handle: handle,
18
+ first_name: first_name,
19
+ last_name: last_name,
20
+ url: url,
21
+ company: company,
22
+ }
23
+ end
24
+
25
+ def inspect
26
+ values = to_hash.map{|k,v| "#{k}: #{v.inspect}" }.join(', ')
27
+ %(#<#{self.class} #{values}>)
28
+ end
29
+
30
+ end
@@ -0,0 +1,24 @@
1
+ class Nvlope::Arguments
2
+
3
+ Error = Class.new(ArgumentError)
4
+
5
+ def initialize hash
6
+ hash.respond_to?(:to_hash) or raise ArgumentError, "Arguments should be a hash"
7
+ @hash = hash.to_hash
8
+ end
9
+
10
+ def [] key
11
+ @hash[key]
12
+ end
13
+
14
+ def require key
15
+ return @hash[key] if @hash.key?(key)
16
+ raise Error, "#{key} is a required option", caller(2)
17
+ end
18
+
19
+ def optional key
20
+ return @hash[key] if @hash.key?(key)
21
+ return yield if block_given?
22
+ end
23
+
24
+ end
@@ -0,0 +1,28 @@
1
+ class Nvlope::Client
2
+
3
+ def initialize nvlope, raw
4
+ @nvlope = nvlope
5
+ @id = raw['id']
6
+ @name = raw['name']
7
+ @description = raw['description']
8
+ @url = raw['url']
9
+ @image_url = raw['image_url']
10
+ end
11
+ attr_reader :nvlope, :raw, :id, :name, :description, :url, :image_url
12
+
13
+ def to_hash
14
+ {
15
+ id: id,
16
+ name: name,
17
+ description: description,
18
+ url: url,
19
+ image_url: image_url,
20
+ }
21
+ end
22
+
23
+ def inspect
24
+ values = to_hash.map{|k,v| "#{k}: #{v.inspect}" }.join(', ')
25
+ %(#<#{self.class} #{values}>)
26
+ end
27
+
28
+ end
@@ -0,0 +1,35 @@
1
+ require 'mail'
2
+
3
+ class Nvlope::EmailAddress
4
+
5
+ def initialize name, address
6
+ @name, @address = name, address
7
+ end
8
+
9
+ def mail_address
10
+ @mail_address ||= begin
11
+ mail_address = Mail::Address.new
12
+ mail_address.display_name = @name
13
+ mail_address.address = @address
14
+ mail_address
15
+ end
16
+ end
17
+ alias_method :to_mail_address, :mail_address
18
+
19
+ def method_missing method, *args, &block
20
+ return super unless mail_address.respond_to?(method)
21
+ mail_address.send(method, *args, &block)
22
+ end
23
+
24
+ def to_s
25
+ mail_address.to_s
26
+ end
27
+ alias_method :to_str, :to_s
28
+
29
+ def inspect
30
+ %(#<#{self.class} #{to_s}>)
31
+ end
32
+
33
+ end
34
+
35
+
@@ -0,0 +1,73 @@
1
+ require 'mail'
2
+
3
+ class Nvlope::Message < Nvlope::Model
4
+
5
+ autoload :Header, 'nvlope/message/header'
6
+
7
+ keys %w{
8
+ id
9
+ created
10
+ labels
11
+ files
12
+ header
13
+ text
14
+ html
15
+ abstract
16
+ references
17
+ sender
18
+ recipients
19
+ subject
20
+ }
21
+
22
+ def created_at
23
+ @created_at ||= Time.at(created)
24
+ end
25
+
26
+ def header
27
+ @header ||= Nvlope::Message::Header.new(nvlope, raw['header'])
28
+ end
29
+
30
+ def sender
31
+ @sender ||= Nvlope::EmailAddress.new(raw['sender']['name'], raw['sender']['address'])
32
+ end
33
+
34
+ def recipients
35
+ @recipients ||= Array(raw['recipients']).map do |recipient|
36
+ Nvlope::EmailAddress.new(recipient['name'], recipient['address'])
37
+ end
38
+ end
39
+
40
+ def files
41
+ @files ||= Array(raw['files']).map do |raw|
42
+ Nvlope::File.new(nvlope, raw)
43
+ end
44
+ end
45
+
46
+ Nvlope::Message::Header.keys.each do |key|
47
+ key = Nvlope::Model.key_to_method_name(key)
48
+ define_method(key){ header.send(key) }
49
+ end
50
+
51
+ def mail_message
52
+ mail_message = Mail::Message.new
53
+ mail_message.date = header.date
54
+ mail_message.from = header.from
55
+ mail_message.reply_to = header.reply_to
56
+ mail_message.to = header.to
57
+ mail_message.message_id = header.message_id
58
+ mail_message.in_reply_to = header.in_reply_to
59
+ mail_message.references = references
60
+ mail_message.subject = subject
61
+ mail_message.mime_version = header.mime_version
62
+ mail_message.content_type = header.content_type
63
+ mail_message.body = text
64
+ html = self.html
65
+ mail_message.html_part do
66
+ content_type "text/html; charset=#{html.encoding.to_s}"
67
+ body html
68
+ end unless html.nil?
69
+ # files.each add attachment
70
+ mail_message
71
+ end
72
+
73
+ end
@@ -0,0 +1,31 @@
1
+ class Nvlope::Message::Header < Nvlope::Model
2
+
3
+ keys %w{
4
+ content-type
5
+ date
6
+ dkim-signature
7
+ domainkey-signature
8
+ from
9
+ reply-to
10
+ in-reply-to
11
+ message-id
12
+ mime-version
13
+ received
14
+ sender
15
+ subject
16
+ to
17
+ }
18
+
19
+ def message_id
20
+ raw['message-id'].first
21
+ end
22
+
23
+ def mime_version
24
+ raw['mime-version'].first
25
+ end
26
+
27
+ def content_type
28
+ raw['content-type'].first
29
+ end
30
+
31
+ end
@@ -0,0 +1,31 @@
1
+ class Nvlope::MessageCollection
2
+
3
+ include Enumerable
4
+
5
+ def initialize nvlope, raw
6
+ @nvlope, @raw = nvlope, raw
7
+ end
8
+ attr_reader :nvlope, :raw
9
+
10
+ def to_a
11
+ @to_a ||= raw['messages'].map do |raw|
12
+ Nvlope::Message.new(nvlope, raw)
13
+ end
14
+ end
15
+
16
+ def each &block
17
+ to_a.each(&block)
18
+ end
19
+
20
+ alias_method :size, :count
21
+ alias_method :length, :count
22
+
23
+ def bookmark
24
+ raw['bookmark']
25
+ end
26
+
27
+ def inspect
28
+ %(#<#{self.class} #{size}>)
29
+ end
30
+
31
+ end
@@ -0,0 +1,38 @@
1
+ class Nvlope::Messages
2
+
3
+ def initialize nvlope
4
+ @nvlope = nvlope
5
+ end
6
+ attr_reader :nvlope
7
+
8
+ def query params={}, headers={}
9
+ params[:include] ||= 'all'
10
+ raw = nvlope.request(:get, '/messages', params, headers)
11
+ Nvlope::MessageCollection.new(nvlope, raw)
12
+ end
13
+
14
+ def bulk_get message_ids, params={}, headers={}
15
+ params["message_ids"] = message_ids
16
+ raw = nvlope.request(:post, '/messages', params, headers)
17
+ Nvlope::MessageCollection.new(nvlope, raw)
18
+ end
19
+
20
+ def delete message_ids, params={}, headers={}
21
+ params["message_ids"] = message_ids
22
+ nvlope.request(:delete, '/messages', params, headers)
23
+ self
24
+ end
25
+
26
+ def unread
27
+
28
+ end
29
+
30
+ def update_labels
31
+
32
+ end
33
+
34
+ def get_labels
35
+ nvlope.request(:delete, '/messages/labels')['labels']
36
+ end
37
+
38
+ end
@@ -0,0 +1,37 @@
1
+ class Nvlope::Model
2
+
3
+ def self.key_to_method_name key
4
+ key.downcase.gsub('-','_')
5
+ end
6
+
7
+ def self.keys *keys
8
+ @keys ||= Set[]
9
+ return @keys if keys.empty?
10
+ keys = keys.flatten.map(&:to_s).to_set
11
+ keys.each do |key|
12
+ define_method(key_to_method_name(key)){ raw[key] }
13
+ end
14
+ @keys += keys
15
+ end
16
+
17
+ def initialize nvlope, raw={}
18
+ @nvlope, @raw = nvlope, raw
19
+ end
20
+ attr_reader :nvlope, :raw
21
+
22
+ def to_hash
23
+ self.class.keys.inject({}) do |hash, key|
24
+ hash.update key => send(Nvlope::Model.key_to_method_name(key))
25
+ end
26
+ end
27
+
28
+ def [] key
29
+ raw[key.to_s]
30
+ end
31
+
32
+ def inspect
33
+ values = to_hash.map{|k,v| "#{k}: #{v.inspect}" }.join(', ')
34
+ %(#<#{self.class} #{values}>)
35
+ end
36
+
37
+ end
@@ -0,0 +1,8 @@
1
+ class Nvlope::Request
2
+
3
+ def initialize nvlope, raw
4
+ @nvlope, @raw = nvlope, raw
5
+ end
6
+ attr_reader :nvlope, :raw
7
+
8
+ end
@@ -0,0 +1,24 @@
1
+ class Nvlope::Session
2
+
3
+ def initialize nvlope, raw
4
+ @nvlope, @raw = nvlope, raw
5
+ end
6
+ attr_reader :nvlope, :raw
7
+
8
+ def access_token
9
+ @access_token ||= Nvlope::AccessToken.new(nvlope, raw['access_token'])
10
+ end
11
+
12
+ def account
13
+ @account ||= Nvlope::Account.new(nvlope, raw['account'])
14
+ end
15
+
16
+ def client
17
+ @client ||= Nvlope::Client.new(nvlope, raw['access_token'])
18
+ end
19
+
20
+ def inspect
21
+ %(#<#{self.class} access_token: #{access_token.inspect}, account: #{account.inspect}, client: #{client.inspect}>)
22
+ end
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ class Nvlope
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nvlope/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nvlope"
8
+ spec.version = Nvlope::VERSION
9
+ spec.authors = ["Jared Grippe"]
10
+ spec.email = ["jared@other.io"]
11
+ spec.summary = %q{Ruby wrapper for the nvlope.com API}
12
+ spec.description = %q{Ruby wrapper for the nvlope.com API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "mail"
22
+ spec.add_dependency "httparty"
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "pry-debugger"
27
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nvlope::Client do
4
+
5
+ end
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nvlope do
4
+
5
+ subject{ nvlope }
6
+
7
+ let :nvlope do
8
+ described_class.new(config)
9
+ end
10
+
11
+ def config
12
+ {
13
+ # grant_type: grant_type,
14
+ username: username,
15
+ password: password,
16
+ client_id: client_id,
17
+ client_secret: client_secret,
18
+ # domain: domain,
19
+ }
20
+ end
21
+
22
+ # let(:grant_type) { 'password' }
23
+ let(:username) { 'Newman' }
24
+ let(:password) { 'lostinthemail' }
25
+ let(:client_id) { 'FAKE_CLIENT_ID' }
26
+ let(:client_secret){ 'FAKE_CLIENT_SECRET' }
27
+ # let(:domain) { }
28
+
29
+ its(:username) { should eq 'Newman' }
30
+ its(:password) { should eq 'lostinthemail' }
31
+ its(:client_id) { should eq 'FAKE_CLIENT_ID' }
32
+ its(:client_secret){ should eq 'FAKE_CLIENT_SECRET' }
33
+ its(:grant_type) { should eq 'password'}
34
+ its(:domain) { should eq 'https://api.nvlope.com/' }
35
+ its(:api_version) { should eq 'v1'}
36
+
37
+
38
+ describe 'new' do
39
+ context 'with invalid arguments' do
40
+ it 'raises an ArgumentError' do
41
+ expect{
42
+ described_class.new
43
+ }.to raise_error ArgumentError
44
+
45
+ expect{
46
+ described_class.new({})
47
+ }.to raise_error ArgumentError, 'username is a required option'
48
+
49
+ expect{
50
+ described_class.new(username: 'u')
51
+ }.to raise_error ArgumentError, 'password is a required option'
52
+
53
+ expect{
54
+ described_class.new(username: 'u', password: 'p')
55
+ }.to raise_error ArgumentError, 'client_id is a required option'
56
+
57
+ expect{
58
+ described_class.new(username: 'u', password: 'p', client_id: 'c')
59
+ }.to raise_error ArgumentError, 'client_secret is a required option'
60
+
61
+ expect{
62
+ described_class.new(username: 'u', password: 'p', client_id: 'c', client_secret: 's')
63
+ }.to_not raise_error
64
+ end
65
+ end
66
+ end
67
+
68
+ describe '#url' do
69
+ context 'when given "/oauth2/token"' do
70
+ let(:path){ '/oauth2/token' }
71
+ subject{ nvlope.url(path) }
72
+ it { should eq 'https://api.nvlope.com/v1/oauth2/token' }
73
+ end
74
+ end
75
+
76
+
77
+ describe '#access_token' do
78
+ subject{ nvlope.access_token }
79
+ before do
80
+ expect(HTTParty).to receive(:post).with('https://api.nvlope.com/v1/oauth2/token', query:{
81
+ grant_type: nvlope.grant_type,
82
+ username: nvlope.username,
83
+ password: nvlope.password,
84
+ client_id: nvlope.client_id,
85
+ client_secret: nvlope.client_secret,
86
+ }).and_return('access_token' => 'FAKE_OAUTH_ACCESS_TOKEN')
87
+ end
88
+ it { should eq 'FAKE_OAUTH_ACCESS_TOKEN'}
89
+ end
90
+
91
+ describe '#request' do
92
+ it 'makes an http request via HTTParty' do
93
+ expect(nvlope).to receive(:access_token).and_return('FAKE_ACCESS_TOKEN')
94
+ query = {foo: 'bar'}
95
+ headers = {'Accepts' => 'application/json'}
96
+ expect(HTTParty).to receive(:get).with('https://api.nvlope.com/v1/some/path',
97
+ query: query,
98
+ headers: headers.merge('Authorization' => 'Bearer FAKE_ACCESS_TOKEN'),
99
+ )
100
+ nvlope.request(:get, 'some/path', query, headers)
101
+ end
102
+ end
103
+
104
+ end
@@ -0,0 +1,19 @@
1
+ require 'nvlope'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # Require this file using `require "spec_helper"` to ensure that it is only
6
+ # loaded once.
7
+ #
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nvlope
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jared Grippe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mail
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-debugger
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby wrapper for the nvlope.com API
98
+ email:
99
+ - jared@other.io
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/nvlope.rb
111
+ - lib/nvlope/access_token.rb
112
+ - lib/nvlope/account.rb
113
+ - lib/nvlope/arguments.rb
114
+ - lib/nvlope/client.rb
115
+ - lib/nvlope/email_address.rb
116
+ - lib/nvlope/message.rb
117
+ - lib/nvlope/message/header.rb
118
+ - lib/nvlope/message_collection.rb
119
+ - lib/nvlope/messages.rb
120
+ - lib/nvlope/model.rb
121
+ - lib/nvlope/request.rb
122
+ - lib/nvlope/session.rb
123
+ - lib/nvlope/version.rb
124
+ - nvlope.gemspec
125
+ - spec/nvlope/client_spec.rb
126
+ - spec/nvlope_spec.rb
127
+ - spec/spec_helper.rb
128
+ homepage: ''
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.1.11
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Ruby wrapper for the nvlope.com API
152
+ test_files:
153
+ - spec/nvlope/client_spec.rb
154
+ - spec/nvlope_spec.rb
155
+ - spec/spec_helper.rb