persistiq 1.0.0

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: f1b653e4604c538a802400807c10016f6ae47ace
4
+ data.tar.gz: 4aae8fd7a205d02ef057b08c293dc9ad96210fcd
5
+ SHA512:
6
+ metadata.gz: 4ce83e3b9f81b2f22d4668c25098465ba24caec5ef8f7aedc8b564bfb6ccdc3063ae65d61d0f0c7a34865f51c56b184abf54acafa45b5a3cccf76c8cce4ce1c4
7
+ data.tar.gz: 532dc48198f4aa1f9e1cc39e6b42c1aa46da88b1fdf89f423e825445d2ac3208320e109a09e3ea0114b49150cf3abeda661641326a6724220ea381077736c76f
Binary file
@@ -0,0 +1,2 @@
1
+ persistiq-*.gem
2
+ .env
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ persistiq (1.0.0)
5
+ faraday
6
+ faraday_middleware
7
+ hashie
8
+ json
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.3.7)
14
+ crack (0.4.2)
15
+ safe_yaml (~> 1.0.0)
16
+ faraday (0.9.1)
17
+ multipart-post (>= 1.2, < 3)
18
+ faraday_middleware (0.9.1)
19
+ faraday (>= 0.7.4, < 0.10)
20
+ hashie (3.4.0)
21
+ json (1.8.2)
22
+ minitest (5.5.1)
23
+ multipart-post (2.0.0)
24
+ rake (10.1.0)
25
+ safe_yaml (1.0.4)
26
+ vcr (2.9.3)
27
+ webmock (1.20.4)
28
+ addressable (>= 2.3.6)
29
+ crack (>= 0.3.2)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler
36
+ persistiq!
37
+ minitest
38
+ rake
39
+ vcr
40
+ webmock
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jamie Quint
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,6 @@
1
+ ### A Ruby wrapper for the Persist IQ API
2
+
3
+ Based on the Taylor Brooks Ruby Close.io API Wrapper: https://github.com/taylorbrooks/closeio
4
+
5
+ ### Copyright
6
+ Copyright (c) 2015 Jamie Quint. See LICENSE for details.
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rdoc/task'
4
+ Rake::RDocTask.new do |rdoc|
5
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
6
+
7
+ rdoc.rdoc_dir = 'rdoc'
8
+ rdoc.title = "persistiq #{version}"
9
+ rdoc.rdoc_files.include('README*')
10
+ rdoc.rdoc_files.include('lib/**/*.rb')
11
+ end
Binary file
@@ -0,0 +1,4 @@
1
+ require_relative 'persistiq/client'
2
+
3
+ module Persistiq
4
+ end
Binary file
@@ -0,0 +1,66 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
5
+
6
+ module Persistiq
7
+ class Client
8
+ include Persistiq::Client::User
9
+ include Persistiq::Client::Lead
10
+ include Persistiq::Client::Campaign
11
+
12
+ attr_reader :api_key, :logger
13
+
14
+ def initialize(api_key, logger = true)
15
+ @api_key = api_key
16
+ @logger = logger
17
+ end
18
+
19
+ def get(path, options={})
20
+ connection.get(path, options).body
21
+ end
22
+
23
+ def post(path, req_body)
24
+ connection.post do |req|
25
+ req.url(path)
26
+ req.body = req_body
27
+ end.body
28
+ end
29
+
30
+ def put(path, options={})
31
+ connection.put(path, options).body
32
+ end
33
+
34
+ def delete(path, options = {})
35
+ connection.delete(path, options).body
36
+ end
37
+
38
+ def paginate(path)
39
+ results = []
40
+
41
+ begin
42
+ res = get(path)
43
+ unless res.data.empty?
44
+ results.push res.data
45
+ page = res.next_page
46
+ page.slice!('https://api.persistiq.com/v1/')
47
+ path = page
48
+ end
49
+ end while res.has_more
50
+ json = {has_more: false, data: results.flatten}
51
+ Hashie::Mash.new json
52
+ end
53
+
54
+ private
55
+
56
+ def connection
57
+ Faraday.new(url: "https://api.persistiq.com/v1", headers: { 'accept' => 'application/json', 'x-api-key' => api_key }) do |conn|
58
+ conn.request :json
59
+ conn.response :logger if logger
60
+ conn.use FaradayMiddleware::Mashify
61
+ conn.response :json
62
+ conn.adapter Faraday.default_adapter
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,32 @@
1
+ module Persistiq
2
+ class Client
3
+ module Campaign
4
+
5
+ def list_campaigns(paginate = true)
6
+ get(campaign_path)
7
+ end
8
+
9
+ def add_leads_to_campaign(id, options={})
10
+ post(campaign_path(id), options)
11
+ end
12
+
13
+ private
14
+
15
+ def campaign_path(id=nil)
16
+ id ? "campaigns/#{id}/leads" : "campaigns"
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
23
+ # def list_leads(query = {}, paginate = false, fields = nil, options = {})
24
+ # options[:_fields] = fields if fields
25
+ # params = assemble_list_query query, options
26
+ #
27
+ # if paginate
28
+ # paginate(lead_path, params)
29
+ # else
30
+ # get(lead_path, params)
31
+ # end
32
+ # end
@@ -0,0 +1,25 @@
1
+ module Persistiq
2
+ class Client
3
+ module Lead
4
+
5
+ def list_leads(paginate = true)
6
+ get(lead_path)
7
+ end
8
+
9
+ def create_lead(options={})
10
+ post(lead_path, options)
11
+ end
12
+
13
+ def get_lead(id, options={})
14
+ get(lead_path(id), options)
15
+ end
16
+
17
+ private
18
+
19
+ def lead_path(id=nil)
20
+ id ? "leads/#{id}/" : "leads"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ module Persistiq
2
+ class Client
3
+ module User
4
+
5
+ def list_users
6
+ get(user_path)
7
+ end
8
+
9
+ private
10
+
11
+ def user_path(id=nil)
12
+ id ? "users/#{id}/" : "user"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Persistiq
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "persistiq/version"
4
+ require "base64"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "persistiq"
8
+ s.version = Persistiq::VERSION
9
+ s.authors = ["Jamie Quint"]
10
+ s.homepage = "https://github.com/jamiequint/persistiq"
11
+ s.summary = %q{A Ruby wrapper for the PersistIQ API}
12
+ s.description = %q{A Ruby wrapper for the PersistIQ API}
13
+ s.license = "MIT"
14
+
15
+ s.files = `git ls-files`.split($/)
16
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test)/})
18
+
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency 'faraday'
22
+ s.add_runtime_dependency 'faraday_middleware'
23
+ s.add_runtime_dependency 'json'
24
+ s.add_runtime_dependency 'hashie'
25
+
26
+ s.add_development_dependency 'bundler'
27
+ s.add_development_dependency 'rake'
28
+ s.add_development_dependency 'minitest'
29
+ s.add_development_dependency 'vcr'
30
+ s.add_development_dependency 'webmock'
31
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: persistiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jamie Quint
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
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: faraday_middleware
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: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: bundler
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: rake
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
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: A Ruby wrapper for the PersistIQ API
140
+ email:
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - .DS_Store
146
+ - .gitignore
147
+ - Gemfile
148
+ - Gemfile.lock
149
+ - LICENSE
150
+ - README.md
151
+ - Rakefile
152
+ - lib/.DS_Store
153
+ - lib/persistiq.rb
154
+ - lib/persistiq/.DS_Store
155
+ - lib/persistiq/client.rb
156
+ - lib/persistiq/resources/.DS_Store
157
+ - lib/persistiq/resources/campaign.rb
158
+ - lib/persistiq/resources/lead.rb
159
+ - lib/persistiq/resources/user.rb
160
+ - lib/persistiq/version.rb
161
+ - persistiq.gemspec
162
+ homepage: https://github.com/jamiequint/persistiq
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.0.14
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: A Ruby wrapper for the PersistIQ API
186
+ test_files: []