Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
- name: Set up Ruby 2.6.7
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.x
ruby-version: 2.6.7
- name: Build and test with Rake
run: |
gem install bundler
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ source 'https://rubygems.org'
gemspec

gem 'dotenv', '~> 2.1', '>= 2.1.1'
gem 'webmock', '~> 2.1'
gem 'webmock', '~> 3.5'
gem 'vcr', '~> 3.0', '>= 3.0.3'
7 changes: 4 additions & 3 deletions lib/convertkit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ class Client
include Webhooks
include Tags

attr_accessor :api_secret, :api_key
attr_accessor :api_secret, :api_key, :integration_key

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

def connection
@connection ||= Connection.new(api_key: api_key, api_secret: api_secret)
@connection ||= Connection.new(api_key: api_key, api_secret: api_secret, integration_key: integration_key)
end
end
end
2 changes: 1 addition & 1 deletion lib/convertkit/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Convertkit
class Configuration
attr_accessor :api_secret, :api_key
attr_accessor :api_secret, :api_key, :integration_key
attr_accessor :timeout, :open_timeout

def initialize
Expand Down
7 changes: 4 additions & 3 deletions lib/convertkit/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Convertkit
class Connection
attr_reader :http_connection

def initialize(api_key: nil, api_secret: nil)
@http_connection = faraday_connection(api_key, api_secret)
def initialize(api_key: nil, api_secret: nil, integration_key: nil)
@http_connection = faraday_connection(api_key, api_secret, integration_key)
end

def content_type
Expand All @@ -33,7 +33,7 @@ def delete(*args, &blk)

private

def faraday_connection(api_key, api_secret)
def faraday_connection(api_key, api_secret, integration_key)
Faraday.new do |f|
f.url_prefix = "https://api.convertkit.com/v3/"
f.adapter :net_http
Expand All @@ -47,6 +47,7 @@ def faraday_connection(api_key, api_secret)

f.params['api_secret'] = api_secret if api_secret
f.params['api_key'] = api_key if api_key
f.params['integration_key'] = integration_key if integration_key

f.response :json, content_type: /\bjson$/
end
Expand Down
8 changes: 8 additions & 0 deletions spec/convertkit/convertkit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
expect(Convertkit.configuration.api_key).to eql("new_key")
end

it "sets the integration_key value" do
Convertkit.configure do |config|
config.integration_key = "new_key"
end

expect(Convertkit.configuration.integration_key).to eql("new_key")
end

it "sets the timeout value" do
Convertkit.configure do |config|
config.timeout = 10
Expand Down