Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in convertkit_v4-ruby.gemspec
# Specify your gem's dependencies in convertkit-ruby.gemspec
gemspec

gem 'dotenv', '~> 2.1', '>= 2.1.1'
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Convertkit V4 Ruby Client
# Convertkit Ruby Client

A Ruby toolkit for [ConvertkitV4](https://convertkit.com/) API.
A Ruby toolkit for [Convertkit](https://convertkit.com/) API.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'convertkit_v4-ruby', require: 'convertkit_v4'
gem 'convertkit-ruby', require: 'convertkit'
```

And then execute:
Expand All @@ -16,29 +16,29 @@ And then execute:

Or install it yourself as:

$ gem install convertkit_v4-ruby
$ gem install convertkit-ruby

## Authentication

For private integrations, use your personal ``API_KEY`` and ``API_SECRET`` found in [your account settings.](https://app.ConvertkitV4.com/account/edit)
For private integrations, use your personal ``API_KEY`` and ``API_SECRET`` found in [your account settings.](https://app.convertkit.com/account/edit)

```ruby
require "dotenv"
Dotenv.load(".env.local")

ConvertkitV4.configure do |config|
Convertkit.configure do |config|
config.api_secret = ENV["API_SECRET"]
config.api_key = ENV["API_KEY"]
end

client = ConvertkitV4::Client.new
client = Convertkit::Client.new
```

## Usage

Calls for ConvertkitV4 API v3 are relative to the url [developers.convertkit.com](developers.convertkit.com).
Calls for Convertkit API v3 are relative to the url [http://api.convertkit.com/v3](http://api.convertkit.com/v3).

API actions are available as methods on the client object. Currently, the ConvertkitV4 client has the following methods:
API actions are available as methods on the client object. Currently, the Convertkit client has the following methods:


| Action | Method |
Expand All @@ -61,9 +61,9 @@ API actions are available as methods on the client object. Currently, the Conver

## Use Cases

Here are some common use cases for the ConvertkitV4 v4 API client.
Here are some common use cases for the Convertkit v3 API client.

First configure the ``convertkit_v4-ruby`` gem with your ``API_KEY`` and ``API_SECRET``, and initialize a new client. After that, you can fetch data from your account.
First configure the ``convertkit-ruby`` gem with your ``API_KEY`` and ``API_SECRET``, and initialize a new client. After that, you can fetch data from your account.

### List subscribers

Expand Down Expand Up @@ -99,9 +99,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/SparkLoop/convertkit-ruby-v4. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
Bug reports and pull requests are welcome on GitHub at https://github.com/Atomoworks/convertkit-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

1. Fork it ( https://github.com/SparkLoop/convertkit-ruby-v4/fork )
1. Fork it ( https://github.com/Atomoworks/convertkit-ruby/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
Expand Down
9 changes: 4 additions & 5 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "convertkit_v4"
require "convertkit"
require "dotenv"

Dotenv.load(".env.local")

ConvertkitV4.configure do |config|
config.client_id = ENV["CONVERTKIT_CLIENT_ID"]
config.client_secret = ENV["CONVERTKIT_CLIENT_SECRET"]
config.redirect_uri = ENV["CONVERTKIT_REDIRECT_URI"]
Convertkit.configure do |config|
config.api_secret = ENV["API_SECRET"]
config.api_key = ENV["API_KEY"]
end

# You can add fixtures and/or initialization code here to make experimenting
Expand Down
14 changes: 7 additions & 7 deletions convertkit_v4-ruby.gemspec → convertkit-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'convertkit_v4/version'
require 'convertkit/version'

Gem::Specification.new do |spec|
spec.name = "convertkit_v4-ruby"
spec.version = ConvertkitV4::VERSION
spec.authors = ["Manuel Frigerio", "Petar Risteski"]
spec.email = ["manuel.frigerio@gmail.com", "risteskipetar3@gmail.com"]
spec.name = "convertkit-ruby"
spec.version = Convertkit::VERSION
spec.authors = ["Manuel Frigerio"]
spec.email = ["manuel.frigerio@gmail.com"]

spec.summary = %q{A Ruby gem for interacting with the Convertkit API v4}
spec.description = %q{A simple wrapper for the Convertkit V4 API}
spec.summary = %q{A Ruby gem for interacting with the ConvertKit API v3}
spec.description = %q{A simple wrapper for the ConvertKit API}
spec.homepage = "https://manuel.friger.io"
spec.license = "MIT"

Expand Down
4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/account.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/add_subscriber_to_form.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/delete_custom_field.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/forms.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/get_custom_fields.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/new_custom_field.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/update_custom_field.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/convertkit_v4.rb → lib/convertkit.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "convertkit_v4/version"
require "convertkit_v4/configuration"
require "convertkit_v4/client"
require "convertkit/version"
require "convertkit/configuration"
require "convertkit/client"

module ConvertkitV4
module Convertkit
class << self
attr_accessor :configuration
end
Expand Down
31 changes: 31 additions & 0 deletions lib/convertkit/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require "convertkit/client/account"
require "convertkit/client/custom_fields"
require "convertkit/client/forms"
require "convertkit/client/sequences"
require "convertkit/client/subscribers"
require "convertkit/client/webhooks"
require "convertkit/client/tags"
require "convertkit/connection"

module Convertkit
class Client
include Account
include CustomFields
include Forms
include Sequences
include Subscribers
include Webhooks
include Tags

attr_accessor :api_secret, :api_key

def initialize( api_key=nil, api_secret=nil )
@api_secret = api_secret || Convertkit.configuration.api_secret
@api_key = api_key || Convertkit.configuration.api_key
end

def connection
@connection ||= Connection.new(api_key: api_key, api_secret: api_secret)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ConvertkitV4
module Convertkit
class Client
module Account
def account
Expand Down
27 changes: 27 additions & 0 deletions lib/convertkit/client/custom_fields.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Convertkit
class Client
module CustomFields

def custom_fields
connection.get("custom_fields").body["custom_fields"]
end

def add_custom_field(options = {})
connection.post("custom_fields") do |f|
f.params['label'] = options[:label]
end
end

def delete_custom_field(custom_field_id)
connection.delete("custom_fields/#{custom_field_id}")
end

def update_custom_field(custom_field_id, options = {})
connection.put("custom_fields/#{custom_field_id}") do |f|
f.params['label'] = options[:label]
end
end

end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ConvertkitV4
module Convertkit
class Client
module Forms
def forms
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module ConvertkitV4
module Convertkit
class Client
module Sequences
def sequences
connection.get("sequences").body["sequences"]
connection.get("sequences")
end

def add_subscriber_to_sequence(sequence_id, email, options = {})
Expand Down
36 changes: 36 additions & 0 deletions lib/convertkit/client/subscribers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module Convertkit
class Client
module Subscribers
def subscribers(options = {})
connection.get("subscribers", options)
end

def subscriber(subscriber_id)
connection.get("subscribers/#{subscriber_id}")
end

def subscriber_tags(subscriber_id)
connection.get("subscribers/#{subscriber_id}/tags")
end

def update_subscriber(subscriber_id, options = {})
response = connection.put("subscribers/#{subscriber_id}") do |f|
f.params["email_address"] = options[:email_address] if options[:email_address]
f.params["fields"] = options[:fields] if options[:fields]
f.params["first_name"] = options[:first_name] if options[:first_name]
end
response.body
end

def unsubscribe(email)
connection.put("unsubscribe") do |f|
f.params['email'] = email
end
end

def remove_tag_from_subscriber(subscriber_id, tag_id)
connection.delete("subscribers/#{subscriber_id}/tags/#{tag_id}")
end
end
end
end
Loading