Skip to content

Commit

Permalink
Add Account API endpoint [ch28502] (#101)
Browse files Browse the repository at this point in the history
* updated ruby library to include the account api endpoint

* adjusted testing to use vcr cassette

* set vcr to output one single cassette
  • Loading branch information
MariaBraganca authored Mar 4, 2021
1 parent b585cc8 commit becc95b
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.

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

1 change: 1 addition & 0 deletions lib/chartmogul.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
require 'chartmogul/plan'
require 'chartmogul/plan_group'
require 'chartmogul/plan_groups/plans'
require 'chartmogul/account'

require 'chartmogul/metrics/arpa'
require 'chartmogul/metrics/arr'
Expand Down
19 changes: 19 additions & 0 deletions lib/chartmogul/account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module ChartMogul
class Account < APIResource
set_resource_name 'Account'
set_resource_path '/v1/account'

readonly_attr :name
readonly_attr :currency
readonly_attr :time_zone
readonly_attr :week_start_on

include API::Actions::Custom

def self.retrieve
custom!(:get, '/v1/account')
end
end
end
2 changes: 1 addition & 1 deletion lib/chartmogul/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ChartMogul
VERSION = '1.6.9'
VERSION = '1.7.0'
end
29 changes: 29 additions & 0 deletions spec/chartmogul/account_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'spec_helper'

describe ChartMogul::Account, uses_api: true do
describe 'API interactions' do
around(:all) do |example|
VCR.use_cassette('ChartMogul_Account/returns_details_of_current_account', &example)
end

let(:account) { ChartMogul::Account.retrieve }

it 'returns the name of current account', uses_api: true do
expect(account.name).to eq('Example Test Company')
end

it 'returns the currency of current account', uses_api: true do
expect(account.currency).to eq('EUR')
end

it 'returns the time zone of current account', uses_api: true do
expect(account.time_zone).to eq('Europe/Berlin')
end

it 'returns the week_start_on of current account', uses_api: true do
expect(account.week_start_on).to eq('sunday')
end
end
end

0 comments on commit becc95b

Please sign in to comment.