convertkit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +25 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +10 -0
- data/convertkit.gemspec +26 -0
- data/lib/convertkit/client.rb +35 -0
- data/lib/convertkit/course.rb +7 -0
- data/lib/convertkit/form.rb +45 -0
- data/lib/convertkit/version.rb +3 -0
- data/lib/convertkit.rb +8 -0
- data/spec/convertkit/client_spec.rb +29 -0
- data/spec/convertkit/form_spec.rb +6 -0
- data/spec/spec_helper.rb +96 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 726a66a66a65b27bd72bfc3522a69e4d47749d62
|
4
|
+
data.tar.gz: 01967e6c7b5be8c969067a752f6108c1492bdf95
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73d289743b9bf788e3e4c80129957946a6b92182dbb73a0378e83df1a80aa258709021170a92ceb4b54ca647de9d2c387616c21ea03aee791be251619b0ebd97
|
7
|
+
data.tar.gz: afda1511792aa2dab1a87ecedc27d8d5352428081a7c27c5fa5072353e710b1b5026b8d36a908c45661213eeca59a1ac0c8603a9b724d907a45f4cedc16a40f5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
- 2.1
|
7
|
+
- jruby-19mode
|
8
|
+
- jruby-head
|
9
|
+
- rbx-2
|
10
|
+
- ruby-head
|
11
|
+
|
12
|
+
sudo: false
|
13
|
+
|
14
|
+
bundler_args: --without development --retry=3 --jobs=3
|
15
|
+
|
16
|
+
env:
|
17
|
+
global:
|
18
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
19
|
+
|
20
|
+
matrix:
|
21
|
+
allow_failures:
|
22
|
+
- rvm: jruby-head
|
23
|
+
- rvm: rbx-2
|
24
|
+
- rvm: ruby-head
|
25
|
+
fast_finish: true
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Steve Corona
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Convertkit
|
2
|
+
|
3
|
+
Rubygem for the excellent Converkit. Allows you to get forms, courses, and subscribe people to your mailing lists.
|
4
|
+
|
5
|
+
*Only supports the v2 API*
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'convertkit'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install convertkit
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
First, configure your client like so:
|
26
|
+
|
27
|
+
client = Convertkit::Client.new(key: "apikey")
|
28
|
+
|
29
|
+
### Get list of forms
|
30
|
+
|
31
|
+
forms = client.forms
|
32
|
+
|
33
|
+
Will give you back something like this (a ConvertKit::Form object)
|
34
|
+
|
35
|
+
#<ConvertKit::Form:0x007fc5020ae460
|
36
|
+
@client=
|
37
|
+
#<ConvertKit::Client:0x007fc502846830
|
38
|
+
@key="xxxx",
|
39
|
+
@uri="https://api.convertkit.com",
|
40
|
+
@version=2>,
|
41
|
+
@created_at="2014-12-02T14:15:47Z",
|
42
|
+
@details="https://api.convertkit.com/forms/4812558?k=xxx&v=2",
|
43
|
+
@embed="https://api.convertkit.com/forms/4812558/embed?k=xxx&v=2",
|
44
|
+
@id=481,
|
45
|
+
@name="10 days to a better gem",
|
46
|
+
@subscriber_count=4,
|
47
|
+
@updated_at="2014-12-12T13:26:14Z">
|
48
|
+
|
49
|
+
## Subscribe to a form
|
50
|
+
|
51
|
+
form = client.form(4)
|
52
|
+
form.subscribe(email: "email@email.com", fname: "name", course_opted: true)
|
53
|
+
|
54
|
+
## Form details
|
55
|
+
|
56
|
+
form = client.form(4)
|
57
|
+
|
58
|
+
## Get Courses
|
59
|
+
|
60
|
+
courses = client.courses
|
61
|
+
|
62
|
+
## Get Course Details
|
63
|
+
|
64
|
+
course = client.courses(4)
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
1. Fork it ( https://github.com/stevencorona/convertkit/fork )
|
72
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/convertkit.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'convertkit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "convertkit"
|
8
|
+
spec.version = ConvertKit::VERSION
|
9
|
+
spec.authors = ["Steve Corona"]
|
10
|
+
spec.email = ["thestevecorona@gmail.com"]
|
11
|
+
spec.summary = %q{Rubygem for the Convertkit API}
|
12
|
+
spec.description = %q{Rubygem for the Convertkit 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 "httparty", "~> 0.13.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module ConvertKit
|
4
|
+
|
5
|
+
class Client
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
attr_reader :key, :uri, :version
|
9
|
+
|
10
|
+
def initialize(key, uri="https://api.convertkit.com")
|
11
|
+
@key = key
|
12
|
+
@uri = uri
|
13
|
+
@version = 2
|
14
|
+
end
|
15
|
+
|
16
|
+
def form(id)
|
17
|
+
form = ConvertKit::Form.new(id)
|
18
|
+
form.client = self
|
19
|
+
|
20
|
+
form
|
21
|
+
end
|
22
|
+
|
23
|
+
def courses()
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def get_request(url)
|
30
|
+
json = self.class.get("#{@uri}/#{url}?k=#{@key}&v=#{@version}")
|
31
|
+
JSON.parse(json.body)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ConvertKit
|
2
|
+
class Form
|
3
|
+
|
4
|
+
attr_reader :id, :subscriber_count, :name, :details, :embed, :created_at, :updated_at
|
5
|
+
attr_writer :client
|
6
|
+
|
7
|
+
def load(data, client)
|
8
|
+
@client = client
|
9
|
+
|
10
|
+
@id = data["id"]
|
11
|
+
@subscriber_count = data["subscriber_count"]
|
12
|
+
@name = data["name"]
|
13
|
+
@details = data["details"]
|
14
|
+
@embed = data["embed"]
|
15
|
+
@created_at = data["created_at"]
|
16
|
+
@updated_at = data["updated_at"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(id)
|
20
|
+
@id = id
|
21
|
+
end
|
22
|
+
|
23
|
+
def subscribe(opts)
|
24
|
+
default = {email: nil, fname: nil, course_opted: true}
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
class Client
|
30
|
+
def forms()
|
31
|
+
raw = get_request("/forms")
|
32
|
+
forms = []
|
33
|
+
|
34
|
+
raw.each do |raw_form|
|
35
|
+
form = ConvertKit::Form.new(raw_form["id"])
|
36
|
+
form.load(raw_form, self)
|
37
|
+
|
38
|
+
forms << form
|
39
|
+
end
|
40
|
+
|
41
|
+
forms
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/lib/convertkit.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module ConvertKit
|
4
|
+
describe Client do
|
5
|
+
describe "#initialize" do
|
6
|
+
let(:client) { ConvertKit::Client.new(123) }
|
7
|
+
|
8
|
+
it "returns a new client" do
|
9
|
+
expect(client).to be_a(Object)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "saves the client id" do
|
13
|
+
expect(client.key).to be(123)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "uses version 2" do
|
17
|
+
expect(client.version).to be(2)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "uses the https convertkit endpoint" do
|
21
|
+
expect(client.uri).to eq("https://api.convertkit.com")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "allows you to pass in the uri" do
|
25
|
+
expect(ConvertKit::Client.new(123, "https://api.dummy.com").uri).to eq("https://api.dummy.com")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require "convertkit"
|
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
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
6
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
7
|
+
#
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
13
|
+
# the additional setup, and require it from the spec files that actually need it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
config.filter_run :focus
|
44
|
+
config.run_all_when_everything_filtered = true
|
45
|
+
config.order = :random
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# These two settings work together to allow you to limit a spec run
|
51
|
+
# to individual examples or groups you care about by tagging them with
|
52
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
53
|
+
# get run.
|
54
|
+
config.filter_run :focus
|
55
|
+
config.run_all_when_everything_filtered = true
|
56
|
+
|
57
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
58
|
+
# For more details, see:
|
59
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
60
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
61
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
62
|
+
config.disable_monkey_patching!
|
63
|
+
|
64
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
65
|
+
# be too noisy due to issues in dependencies.
|
66
|
+
config.warnings = true
|
67
|
+
|
68
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
69
|
+
# file, and it's useful to allow more verbose output when running an
|
70
|
+
# individual spec file.
|
71
|
+
if config.files_to_run.one?
|
72
|
+
# Use the documentation formatter for detailed output,
|
73
|
+
# unless a formatter has already been configured
|
74
|
+
# (e.g. via a command-line flag).
|
75
|
+
config.default_formatter = 'doc'
|
76
|
+
end
|
77
|
+
|
78
|
+
# Print the 10 slowest examples and example groups at the
|
79
|
+
# end of the spec run, to help surface which specs are running
|
80
|
+
# particularly slow.
|
81
|
+
config.profile_examples = 10
|
82
|
+
|
83
|
+
# Run specs in random order to surface order dependencies. If you find an
|
84
|
+
# order dependency and want to debug it, you can fix the order by providing
|
85
|
+
# the seed, which is printed after each run.
|
86
|
+
# --seed 1234
|
87
|
+
|
88
|
+
config.order = :random
|
89
|
+
|
90
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
91
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
92
|
+
# test failures related to randomization by passing the same `--seed` value
|
93
|
+
# as the one that triggered the failure.
|
94
|
+
Kernel.srand config.seed
|
95
|
+
=end
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convertkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steve Corona
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.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.13.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.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
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: rspec
|
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
|
+
description: Rubygem for the Convertkit API
|
70
|
+
email:
|
71
|
+
- thestevecorona@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- convertkit.gemspec
|
84
|
+
- lib/convertkit.rb
|
85
|
+
- lib/convertkit/client.rb
|
86
|
+
- lib/convertkit/course.rb
|
87
|
+
- lib/convertkit/form.rb
|
88
|
+
- lib/convertkit/version.rb
|
89
|
+
- spec/convertkit/client_spec.rb
|
90
|
+
- spec/convertkit/form_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
homepage: ''
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.2.2
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Rubygem for the Convertkit API
|
116
|
+
test_files:
|
117
|
+
- spec/convertkit/client_spec.rb
|
118
|
+
- spec/convertkit/form_spec.rb
|
119
|
+
- spec/spec_helper.rb
|