Skip to content

Commit

Permalink
Add possibility to get account information
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhead committed Jan 17, 2018
1 parent be293fd commit f642ac6
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ API actions are available as methods on the client object. Currently, the Conver

| Action | Method |
|:------------------------|:-----------------------------|
| Get account information | `#account` |
| List subscribers | `#subscribers(options = {})` |
| Fetch a subscriber | `#subscriber(subscriber_id)` |
| List sequences/courses | `#sequences` |
Expand Down
65 changes: 65 additions & 0 deletions fixtures/vcr_cassettes/account.yml

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

12 changes: 7 additions & 5 deletions lib/convertkit/client.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
require "convertkit/client/account"
require "convertkit/client/custom_fields"
require "convertkit/client/forms"
require "convertkit/client/sequences"
require "convertkit/client/subscribers"
require "convertkit/client/tags"
require "convertkit/client/forms"
require "convertkit/client/custom_fields"
require "faraday"
require "faraday_middleware"
require "json"

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

attr_accessor :api_secret, :api_key

Expand Down
9 changes: 9 additions & 0 deletions lib/convertkit/client/account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Convertkit
class Client
module Account
def account
connection.get("account").body
end
end
end
end
21 changes: 21 additions & 0 deletions spec/convertkit/client/account_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "spec_helper"

module Convertkit
class Client
describe Account do
before do
@client = Convertkit::Client.new
end

describe "#account" do
it "fetches account information" do
VCR.use_cassette "account" do
@account = @client.account

expect(@account["primary_email_address"]).to be_truthy
end
end
end
end
end
end

0 comments on commit f642ac6

Please sign in to comment.