woodpecker 0.1.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: f4acded5023888075c59e421ade26c58a571a042
4
+ data.tar.gz: b2ae88caadaa09cf6e424661582c7e2cd71eb8b6
5
+ SHA512:
6
+ metadata.gz: 4cb437d016207040b2740c3f36674092e4cdf8e3ea8a0446bf4c857f0549cefbb4f78ae3b5765e17e7954d8c0582ee086c37fd1cc52473f3124b9e6bc171d340
7
+ data.tar.gz: 51bcf4dad947dd080459e43935c0b11a20c5e1c403b7043871bf4c02acee38f2c9cf3eda6d4c377e6858fa850a22534535377ce7916702a36e05c67808940562
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,26 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.3
4
+
5
+ Metrics/AbcSize:
6
+ Enabled: false
7
+
8
+ Metrics/CyclomaticComplexity:
9
+ Enabled: false
10
+
11
+ Metrics/PerceivedComplexity:
12
+ Enabled: false
13
+
14
+ Metrics/LineLength:
15
+ AllowURI: true
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ CountComments: false
20
+ Max: 20
21
+
22
+ Style/Documentation:
23
+ Enabled: false
24
+
25
+ Style/FrozenStringLiteralComment:
26
+ Enabled: false
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2016-08-02)
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in woodpecker.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Michał Zając
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ # Woodpecker
2
+
3
+ A simple API client for [Woodpecker](https://woodpecker.co/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'woodpecker'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install woodpecker
20
+
21
+ ## Usage
22
+
23
+ An API key must be configured for this gem to work. This can be done anywhere in your application as long as it's done before you make any API calls.
24
+
25
+ ```ruby
26
+ Woodpecker.configure do |config|
27
+ config.api_key = "insert api key here" # This is required
28
+ config.dummy_password = "insert dummy password here" # This is optional.
29
+ end
30
+ ```
31
+
32
+ * `config.api_key` - this is your API key and it's **required**, you can read about how to generate one [here](http://help.woodpecker.co/article/16-api-docs)
33
+ * config.dummy_password - this is **optional** since Woodpecker's API doesn't really care what's here. It's "X" by default.
34
+
35
+ These keys are available during runtime as:
36
+
37
+ ```ruby
38
+ Woodpecker.configuration.api_key
39
+ Woodpecker.configuration.dummy_password
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Quintasan/woodpecker.
51
+
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
56
+
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:spec) do |t|
5
+ t.libs << 'spec'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task default: :spec
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'woodpecker'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,54 @@
1
+ require 'json'
2
+ require 'typhoeus'
3
+
4
+ require 'woodpecker/version'
5
+
6
+ require 'woodpecker/configuration'
7
+ require 'woodpecker/errors/configuration'
8
+
9
+ require 'woodpecker/utils/request'
10
+
11
+ require 'woodpecker/campaign'
12
+ require 'woodpecker/prospect'
13
+ require 'woodpecker/errors/prospect'
14
+
15
+ require 'pry'
16
+
17
+ module Woodpecker
18
+ class << self
19
+ attr_accessor :configuration
20
+ end
21
+
22
+ def self.configuration
23
+ @configuration ||= Configuration.new
24
+ end
25
+
26
+ def self.reset
27
+ @configuration = Configuration.new
28
+ end
29
+
30
+ def self.configure
31
+ yield(configuration)
32
+ end
33
+
34
+ def self.campaign_list
35
+ Woodpecker::Utils::Request.get('campaign_list').map { |campaign| Campaign.new(campaign) }
36
+ end
37
+
38
+ def self.add_prospects_campaign(campaign_id, params = {}, prospects)
39
+ payload = { campaign: { campaign_id: campaign_id },
40
+ update: 'true',
41
+ prospects: prospects }.to_json
42
+ Woodpecker::Utils::Request.post('add_prospects_campaign', params, payload)
43
+ end
44
+
45
+ def self.add_prospects_list(params = {}, prospects)
46
+ payload = { update: 'true', prospects: prospects }.to_json
47
+ Woodpecker::Utils::Request.post('add_prospects_list', params, payload)
48
+ end
49
+
50
+ def self.stop_followups(params = {}, prospect)
51
+ payload = { prospect: { email: prospect.email } }.to_json
52
+ Woodpecker::Utils::Request.post('stop_followups', params, payload)
53
+ end
54
+ end
@@ -0,0 +1,14 @@
1
+ module Woodpecker
2
+ class Campaign
3
+ attr_accessor :id, :name, :status, :from_name, :from_email, :created
4
+
5
+ def initialize(campaign)
6
+ @id = campaign[:id]
7
+ @name = campaign[:name]
8
+ @status = campaign[:status]
9
+ @from_name = campaign[:from_name]
10
+ @from_email = campaign[:from_email]
11
+ @created = DateTime.iso8601(campaign[:created])
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ module Woodpecker
2
+ class Configuration
3
+ # Woodpecker API uses HTTP Basic Authentication where the token is the
4
+ # username and password can be anything. Weird.
5
+ attr_writer :api_key, :dummy_password
6
+
7
+ def initialize
8
+ @api_key = nil
9
+ @dummy_password = nil
10
+ end
11
+
12
+ def api_key
13
+ raise Errors::Configuration, 'Woodpecker API key missing!' unless @api_key
14
+ @api_key
15
+ end
16
+
17
+ def dummy_password
18
+ raise Errors::Configuration, 'Dummy password is missing!' unless @dummy_password
19
+ @dummy_password
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ module Woodpecker
2
+ module Errors
3
+ class Configuration < StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Woodpecker
2
+ module Errors
3
+ class Prospect < StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,49 @@
1
+ module Woodpecker
2
+ class Prospect
3
+ VALID_STATUSES = %w(active replied bounced autoreplied invalid blacklist).freeze
4
+ ATTRS = [:email, :status, :first_name, :last_name, :tags, :company,
5
+ :industry, :title, :phone, :address, :city, :state, :country, :website,
6
+ :snipet1, :snipet2, :snipet3, :snipet4].freeze
7
+
8
+ attr_accessor(*ATTRS)
9
+
10
+ def initialize(prospect)
11
+ @email = prospect[:email]
12
+ raise Errors::Prospect, "Invalid status, valid states are: #{VALID_STATUSES}." unless VALID_STATUSES.include?(prospect[:status])
13
+ @status = prospect[:status].upcase
14
+ @first_name = prospect[:first_name] || ''
15
+ @last_name = prospect[:last_name] || ''
16
+ @tags = prospect[:tags] || ''
17
+ @company = prospect[:company] || ''
18
+ @industry = prospect[:industry] || ''
19
+ @title = prospect[:title] || ''
20
+ @phone = prospect[:phone] || ''
21
+ @address = prospect[:address] || ''
22
+ @city = prospect[:city] || ''
23
+ @state = prospect[:state] || ''
24
+ @country = prospect[:country] || ''
25
+ @website = prospect[:website] || ''
26
+ @snipet1 = prospect[:snipet1] || ''
27
+ @snipet2 = prospect[:snipet2] || ''
28
+ @snipet3 = prospect[:snipet3] || ''
29
+ @snipet4 = prospect[:snipet4] || ''
30
+ end
31
+
32
+ def email
33
+ raise Errors::Prospect, 'Missing email' unless @email
34
+ @email
35
+ end
36
+
37
+ def to_h
38
+ hash = {}
39
+ ATTRS.each do |attr|
40
+ hash[attr.to_sym] = send(attr)
41
+ end
42
+ hash
43
+ end
44
+
45
+ def to_json(*_args)
46
+ to_h.to_json
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,24 @@
1
+ module Woodpecker
2
+ module Utils
3
+ module Request
4
+ module_function
5
+
6
+ def get(endpoint, params = {})
7
+ request = Typhoeus::Request.get("https://api.woodpecker.co/rest/v1/#{endpoint}",
8
+ userpwd: "#{Woodpecker.configuration.api_key}:#{Woodpecker.configuration.dummy_password}",
9
+ params: params)
10
+ data = JSON.parse(request.response_body, symbolize_names: true)
11
+ data
12
+ end
13
+
14
+ def post(endpoint, params = {}, body = {})
15
+ request = Typhoeus::Request.post("https://api.woodpecker.co/rest/v1/#{endpoint}",
16
+ userpwd: "#{Woodpecker.configuration.api_key}:#{Woodpecker.configuration.dummy_password}",
17
+ params: params,
18
+ body: body)
19
+ data = JSON.parse(request.response_body, symbolize_names: true)
20
+ data
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ module Woodpecker
2
+ module Version
3
+ module_function
4
+
5
+ def major
6
+ 0
7
+ end
8
+
9
+ def minor
10
+ 1
11
+ end
12
+
13
+ def patch
14
+ 0
15
+ end
16
+
17
+ def to_a
18
+ [major, minor, patch].compact
19
+ end
20
+
21
+ def to_s
22
+ to_a.join('.')
23
+ end
24
+ end
25
+ 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 'woodpecker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'woodpecker'
8
+ spec.version = Woodpecker::Version
9
+ spec.authors = ['Michał Zając']
10
+ spec.summary = 'Simple Woodpecker API client'
11
+ spec.description = 'Simple API client for Woodpecker. Woodpecker is a service to send personalized cold emails & follow-ups to your users. '
12
+ spec.homepage = 'https://github.com/Quintasan/woodpecker'
13
+ spec.license = 'MIT'
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
+ spec.bindir = 'exe'
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'typhoeus', '~> 1.1.0'
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.12'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'minitest', '~> 5.0'
24
+ spec.add_development_dependency 'minitest-reporters', '~> 1.1.11'
25
+ spec.add_development_dependency 'pry-byebug'
26
+ spec.add_development_dependency 'rubocop', '~> 0.42.0'
27
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: woodpecker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michał Zając
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typhoeus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.11
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.1.11
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
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: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.42.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.42.0
111
+ description: 'Simple API client for Woodpecker. Woodpecker is a service to send personalized
112
+ cold emails & follow-ups to your users. '
113
+ email:
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rubocop.yml"
120
+ - ".travis.yml"
121
+ - CHANGELOG.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/woodpecker.rb
129
+ - lib/woodpecker/campaign.rb
130
+ - lib/woodpecker/configuration.rb
131
+ - lib/woodpecker/errors/configuration.rb
132
+ - lib/woodpecker/errors/prospect.rb
133
+ - lib/woodpecker/prospect.rb
134
+ - lib/woodpecker/utils/request.rb
135
+ - lib/woodpecker/version.rb
136
+ - woodpecker.gemspec
137
+ homepage: https://github.com/Quintasan/woodpecker
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.5.1
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Simple Woodpecker API client
161
+ test_files: []