fortnox-api 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +18 -0
- data/.gitignore +6 -1
- data/.rubocop.yml +1107 -0
- data/.travis.yml +9 -3
- data/CONTRIBUTE.md +26 -0
- data/Gemfile +0 -0
- data/Guardfile +2 -2
- data/LICENSE.txt +0 -0
- data/README.md +109 -88
- data/Rakefile +0 -0
- data/docs/account.rb +59 -0
- data/docs/extraction_script.js +23 -0
- data/docs/generation_script.rb +43 -0
- data/docs/json/account.json +77 -0
- data/fortnox-api.gemspec +4 -1
- data/lib/fortnox/api.rb +14 -3
- data/lib/fortnox/api/base.rb +25 -36
- data/lib/fortnox/api/class_methods.rb +13 -45
- data/lib/fortnox/api/environment_validation.rb +33 -0
- data/lib/fortnox/api/models.rb +1 -0
- data/lib/fortnox/api/models/attributes/country_code.rb +17 -0
- data/lib/fortnox/api/models/attributes/currency.rb +17 -0
- data/lib/fortnox/api/models/base.rb +67 -0
- data/lib/fortnox/api/{customer/entity.rb → models/customer.rb} +31 -12
- data/lib/fortnox/api/models/edi_information.rb +28 -0
- data/lib/fortnox/api/models/email_information.rb +25 -0
- data/lib/fortnox/api/models/invoice.rb +253 -0
- data/lib/fortnox/api/models/row.rb +82 -0
- data/lib/fortnox/api/repositories.rb +1 -0
- data/lib/fortnox/api/repositories/base.rb +34 -0
- data/lib/fortnox/api/{repository → repositories/base}/json_convertion.rb +18 -5
- data/lib/fortnox/api/{repository → repositories/base}/loaders.rb +16 -8
- data/lib/fortnox/api/repositories/base/options.rb +33 -0
- data/lib/fortnox/api/repositories/base/savers.rb +39 -0
- data/lib/fortnox/api/repositories/customer.rb +38 -0
- data/lib/fortnox/api/repositories/invoice.rb +35 -0
- data/lib/fortnox/api/request_handling.rb +35 -0
- data/lib/fortnox/api/validators.rb +1 -0
- data/lib/fortnox/api/validators/attributes/country_code.rb +42 -0
- data/lib/fortnox/api/validators/attributes/currency.rb +38 -0
- data/lib/fortnox/api/validators/base.rb +70 -0
- data/lib/fortnox/api/validators/constant.rb +21 -0
- data/lib/fortnox/api/validators/customer.rb +29 -0
- data/lib/fortnox/api/validators/edi_information.rb +11 -0
- data/lib/fortnox/api/validators/email_information.rb +19 -0
- data/lib/fortnox/api/validators/invoice.rb +33 -0
- data/lib/fortnox/api/validators/row.rb +22 -0
- data/lib/fortnox/api/version.rb +1 -1
- data/spec/fortnox/api/base_spec.rb +65 -62
- data/spec/fortnox/api/models/attributes/country_code_spec.rb +23 -0
- data/spec/fortnox/api/models/attributes/currency_spec.rb +23 -0
- data/spec/fortnox/api/models/attributes/dummy_model_context.rb +9 -0
- data/spec/fortnox/api/models/base_spec.rb +76 -0
- data/spec/fortnox/api/models/invoice_spec.rb +36 -0
- data/spec/fortnox/api/models/row_spec.rb +13 -0
- data/spec/fortnox/api/repositories/context.rb +10 -0
- data/spec/fortnox/api/repositories/customer_spec.rb +85 -0
- data/spec/fortnox/api/repositories/examples.rb +16 -0
- data/spec/fortnox/api/repositories/invoice_spec.rb +10 -0
- data/spec/fortnox/api/validators/attributes/country_code_spec.rb +9 -0
- data/spec/fortnox/api/validators/attributes/currency_spec.rb +9 -0
- data/spec/fortnox/api/validators/attributes/examples_for_validate.rb +29 -0
- data/spec/fortnox/api/validators/base_spec.rb +61 -0
- data/spec/fortnox/api/validators/constant_spec.rb +12 -0
- data/spec/fortnox/api/validators/context.rb +102 -0
- data/spec/fortnox/api/validators/customer_spec.rb +31 -0
- data/spec/fortnox/api/validators/edi_information_spec.rb +18 -0
- data/spec/fortnox/api/validators/email_information_spec.rb +26 -0
- data/spec/fortnox/api/validators/invoice_spec.rb +36 -0
- data/spec/fortnox/api/validators/row_spec.rb +27 -0
- data/spec/fortnox/api/validators/validator_examples.rb +20 -0
- data/spec/fortnox/api_spec.rb +36 -0
- data/spec/spec_helper.rb +16 -4
- data/spec/support/helpers.rb +1 -0
- data/spec/support/helpers/dummy_class_helper.rb +20 -0
- data/spec/support/matchers.rb +1 -0
- data/spec/support/matchers/models.rb +27 -0
- data/spec/support/matchers/validators.rb +36 -0
- data/spec/support/vcr_setup.rb +6 -0
- data/spec/vcr_cassettes/customers/all.yml +47 -0
- data/spec/vcr_cassettes/customers/find_id_1.yml +47 -0
- data/spec/vcr_cassettes/customers/save_new.yml +47 -0
- data/spec/vcr_cassettes/customers/save_old.yml +49 -0
- metadata +133 -21
- data/.ruby-version +0 -1
- data/Gemfile.lock +0 -127
- data/lib/fortnox/api/customer.rb +0 -15
- data/lib/fortnox/api/customer/repository.rb +0 -28
- data/lib/fortnox/api/customer/validator.rb +0 -26
- data/lib/fortnox/api/entity.rb +0 -45
- data/lib/fortnox/api/repository/base.rb +0 -27
- data/lib/fortnox/api/repository/savers.rb +0 -15
- data/lib/fortnox/api/validator.rb +0 -32
- data/spec/fortnox/api/customer/repository_spec.rb +0 -0
- data/spec/fortnox/api/customer/validator_spec.rb +0 -32
- data/spec/fortnox/api/entity_spec.rb +0 -62
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fortnox/api/validators/context'
|
3
|
+
require 'fortnox/api/validators/row'
|
4
|
+
require 'fortnox/api/models/row'
|
5
|
+
|
6
|
+
describe Fortnox::API::Validator::Row do
|
7
|
+
subject{ described_class.new }
|
8
|
+
|
9
|
+
include_context 'validator context' do
|
10
|
+
let( :valid_model ){ Fortnox::API::Model::Row.new }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.validate Row' do
|
14
|
+
context 'with required attributes' do
|
15
|
+
it{ is_expected.to be_valid( valid_model ) }
|
16
|
+
end
|
17
|
+
|
18
|
+
include_examples 'validates length of string', :article_number, 50
|
19
|
+
include_examples 'validates length of string', :description, 50
|
20
|
+
|
21
|
+
include_examples 'validates inclusion of number', :account_number, 0, 9999
|
22
|
+
include_examples 'validates inclusion of number', :delivered_quantity, 0, 9_999_999_999_999.0
|
23
|
+
include_examples 'validates inclusion of number', :discount, 0, 99_999_999_999.0
|
24
|
+
include_examples 'validates inclusion of number', :house_work_hours_to_report, 0, 99_999
|
25
|
+
include_examples 'validates inclusion of number', :price, 0, 99_999_999_999.0
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
shared_examples_for 'validators' do
|
2
|
+
|
3
|
+
it{ is_expected.to respond_to( :validate ) }
|
4
|
+
it{ is_expected.to respond_to( :violations ) }
|
5
|
+
it{ is_expected.to respond_to( :instance ) }
|
6
|
+
|
7
|
+
context 'when validator present' do
|
8
|
+
specify '#violations returns an empty Set when no violations present' do
|
9
|
+
expect(subject.violations).to eq(Set.new)
|
10
|
+
end
|
11
|
+
|
12
|
+
specify '#validate returns true when model valid' do
|
13
|
+
expect(subject.validate( valid_model )).to be true
|
14
|
+
end
|
15
|
+
|
16
|
+
specify '#instance returns self' do
|
17
|
+
expect(subject.instance).to be subject
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fortnox/api'
|
3
|
+
|
4
|
+
describe Fortnox::API do
|
5
|
+
|
6
|
+
context 'get access token' do
|
7
|
+
before do
|
8
|
+
ENV['FORTNOX_API_BASE_URL'] = 'http://api.fortnox.se/3/'
|
9
|
+
ENV['FORTNOX_API_CLIENT_SECRET'] = 'P5K5vE3Kun'
|
10
|
+
ENV['FORTNOX_API_ACCESS_TOKEN'] = '3f08d038-f380-4893-94a0-a08f6e60e67a'
|
11
|
+
ENV['FORTNOX_API_AUTHORIZATION_CODE'] = 'ea3862b0-189c-464b-8e23-1b9702365ea1'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'works' do
|
15
|
+
stub_request(
|
16
|
+
:get,
|
17
|
+
'http://api.fortnox.se/3/',
|
18
|
+
).with(
|
19
|
+
headers: {
|
20
|
+
'Authorization-Code' => 'ea3862b0-189c-464b-8e23-1b9702365ea1',
|
21
|
+
'Client-Secret' => 'P5K5vE3Kun',
|
22
|
+
'Accept' => 'application/json',
|
23
|
+
}
|
24
|
+
).to_return(
|
25
|
+
status: 200,
|
26
|
+
body: { 'Authorisation' => { 'AccessToken' => '3f08d038-f380-4893-94a0-a08f6e60e67a' } }.to_json,
|
27
|
+
headers: { 'Content-Type' => 'application/json' },
|
28
|
+
)
|
29
|
+
|
30
|
+
response = Fortnox::API.get_access_token
|
31
|
+
|
32
|
+
expect( response).to eql( "3f08d038-f380-4893-94a0-a08f6e60e67a" )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,19 +1,31 @@
|
|
1
1
|
ENV['RUBY_ENV'] = 'test'
|
2
2
|
|
3
|
-
require 'fortnox/api'
|
4
3
|
require 'webmock/rspec'
|
5
4
|
require 'pry'
|
5
|
+
require "codeclimate-test-reporter"
|
6
|
+
require 'support/matchers'
|
7
|
+
require 'support/helpers'
|
8
|
+
require 'support/vcr_setup'
|
9
|
+
|
10
|
+
CodeClimate::TestReporter.start
|
6
11
|
|
7
12
|
RSpec.configure do |config|
|
8
13
|
config.run_all_when_everything_filtered = true
|
9
14
|
config.filter_run :focus
|
10
15
|
|
16
|
+
config.extend Helpers
|
17
|
+
|
11
18
|
# Run specs in random order to surface order dependencies. If you find an
|
12
19
|
# order dependency and want to debug it, you can fix the order by providing
|
13
20
|
# the seed, which is printed after each run.
|
14
21
|
# --seed 1234
|
15
22
|
config.order = 'random'
|
16
|
-
end
|
17
23
|
|
18
|
-
|
19
|
-
|
24
|
+
WebMock.disable_net_connect!( allow: 'codeclimate.com' )
|
25
|
+
|
26
|
+
config.after( :each ) do
|
27
|
+
ENV['FORTNOX_API_BASE_URL'] = nil
|
28
|
+
ENV['FORTNOX_API_CLIENT_SECRET'] = nil
|
29
|
+
ENV['FORTNOX_API_ACCESS_TOKEN'] = nil
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.expand_path('spec/support/helpers/*.rb')].each{ |file| require file }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Helpers
|
2
|
+
def using_test_classes
|
3
|
+
around( :all ) do |example|
|
4
|
+
classes_before_examples = Object.constants
|
5
|
+
|
6
|
+
yield
|
7
|
+
|
8
|
+
classes_after_examples = Object.constants
|
9
|
+
classes_created_by_block = classes_after_examples - classes_before_examples
|
10
|
+
|
11
|
+
example.run
|
12
|
+
|
13
|
+
classes_created_by_block.each do |klass|
|
14
|
+
Object.send(:remove_const, klass)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias_method :using_test_class, :using_test_classes
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.expand_path('spec/support/matchers/*.rb')].each{ |file| require file }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
RSpec::Matchers.define :upcase_lower_case_for do |attribute, value|
|
2
|
+
match do
|
3
|
+
subject = new_model( attribute, value )
|
4
|
+
expect( subject.send( attribute ) ).to eql( value.upcase )
|
5
|
+
end
|
6
|
+
|
7
|
+
failure_message do
|
8
|
+
"expected #{subject.class} to upcase #{value} case for :#{attribute}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Matchers.define :return_nil_for_invalid_types do |attribute, value|
|
13
|
+
match do
|
14
|
+
subject = new_model( attribute, value )
|
15
|
+
expect( subject.send( attribute ) ).to eql( nil )
|
16
|
+
end
|
17
|
+
|
18
|
+
failure_message do
|
19
|
+
"expected #{subject.class} to return nil when :#{attribute} is set to #{value}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def new_model( attribute, value )
|
26
|
+
described_class.new( attribute => value )
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
RSpec::Matchers.define :be_valid do |model|
|
2
|
+
expect_validate( model, true )
|
3
|
+
end
|
4
|
+
|
5
|
+
RSpec::Matchers.define :be_invalid do |model|
|
6
|
+
expect_validate( model, false )
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec::Matchers.define :include_error_for do |model, attribute, error_type|
|
10
|
+
match do
|
11
|
+
subject.validate( model )
|
12
|
+
error_included = false
|
13
|
+
subject.violations.any? do |v|
|
14
|
+
if v.rule.attribute_name == attribute && v.rule.type == error_type
|
15
|
+
error_included = true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
expect( error_included ).to eql( true )
|
19
|
+
end
|
20
|
+
|
21
|
+
description{ "include error for #{attribute}" }
|
22
|
+
|
23
|
+
failure_message do
|
24
|
+
"expected \"#{subject.violations.inspect}\" to include #{error_type} error for \"#{attribute}\""
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def expect_validate( model, expected )
|
31
|
+
match{ expect( subject.validate( model ) ).to eq( expected ) }
|
32
|
+
|
33
|
+
description{ "validate #{expected}" }
|
34
|
+
|
35
|
+
failure_message{ "expected validator to validate #{expected}" }
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.fortnox.se/3/customers/
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Client-Secret:
|
15
|
+
- 9aBA8ZgsvR
|
16
|
+
Access-Token:
|
17
|
+
- ccaef817-d5d8-4b1c-a316-54f3e55c5c54
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Wed, 09 Mar 2016 07:17:36 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
- Accept-Encoding
|
34
|
+
X-Rack-Responsetime:
|
35
|
+
- '22'
|
36
|
+
X-Uid:
|
37
|
+
- b31309da
|
38
|
+
X-Build:
|
39
|
+
- 305b6e2193
|
40
|
+
X-Powered-By:
|
41
|
+
- Rack 1.1
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: '{"MetaInformation":{"@TotalResources":1,"@TotalPages":1,"@CurrentPage":1},"Customers":[{"@url":"https:\/\/api.fortnox.se\/3\/customers\/1","Address1":"","Address2":"","City":"","CustomerNumber":"1","Email":"","Name":"Test","OrganisationNumber":"","Phone":"","ZipCode":""}]}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Wed, 09 Mar 2016 07:17:36 GMT
|
47
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.fortnox.se/3/customers/1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Client-Secret:
|
15
|
+
- 9aBA8ZgsvR
|
16
|
+
Access-Token:
|
17
|
+
- ccaef817-d5d8-4b1c-a316-54f3e55c5c54
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Wed, 09 Mar 2016 07:20:16 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
- Accept-Encoding
|
34
|
+
X-Rack-Responsetime:
|
35
|
+
- '81'
|
36
|
+
X-Uid:
|
37
|
+
- 063c54d1
|
38
|
+
X-Build:
|
39
|
+
- 305b6e2193
|
40
|
+
X-Powered-By:
|
41
|
+
- Rack 1.1
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: '{"Customer":{"@url":"https:\/\/api.fortnox.se\/3\/customers\/1","Address1":null,"Address2":null,"City":null,"Country":null,"Comments":null,"Currency":"SEK","CostCenter":null,"CountryCode":null,"CustomerNumber":"1","DefaultDeliveryTypes":{"Invoice":"PRINT","Order":"PRINT","Offer":"PRINT"},"DefaultTemplates":{"Order":"DEFAULTTEMPLATE","Offer":"DEFAULTTEMPLATE","Invoice":"DEFAULTTEMPLATE","CashInvoice":"DEFAULTTEMPLATE"},"DeliveryAddress1":null,"DeliveryAddress2":null,"DeliveryCity":null,"DeliveryCountry":null,"DeliveryCountryCode":null,"DeliveryFax":null,"DeliveryName":null,"DeliveryPhone1":null,"DeliveryPhone2":null,"DeliveryZipCode":null,"Email":"","EmailInvoice":"","EmailInvoiceBCC":"","EmailInvoiceCC":"","EmailOffer":"","EmailOfferBCC":"","EmailOfferCC":"","EmailOrder":"","EmailOrderBCC":"","EmailOrderCC":"","Fax":null,"InvoiceAdministrationFee":null,"InvoiceDiscount":null,"InvoiceFreight":null,"InvoiceRemark":"","Name":"Test","OrganisationNumber":"","OurReference":"","Phone1":null,"Phone2":null,"PriceList":"A","Project":"","SalesAccount":null,"ShowPriceVATIncluded":false,"TermsOfDelivery":"","TermsOfPayment":"","Type":"COMPANY","VATNumber":"","VATType":"SEVAT","VisitingAddress":null,"VisitingCity":null,"VisitingCountry":null,"VisitingCountryCode":null,"VisitingZipCode":null,"WayOfDelivery":"","WWW":"","YourReference":"","ZipCode":null}}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Wed, 09 Mar 2016 07:20:16 GMT
|
47
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.fortnox.se/3/customers/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"Customer":{"Name":"A customer"}}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Client-Secret:
|
15
|
+
- 9aBA8ZgsvR
|
16
|
+
Access-Token:
|
17
|
+
- ccaef817-d5d8-4b1c-a316-54f3e55c5c54
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 201
|
21
|
+
message: Created
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Wed, 09 Mar 2016 08:47:46 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
Location:
|
32
|
+
- customers
|
33
|
+
X-Rack-Responsetime:
|
34
|
+
- '4409'
|
35
|
+
X-Uid:
|
36
|
+
- 8ac129cd
|
37
|
+
X-Build:
|
38
|
+
- 305b6e2193
|
39
|
+
X-Powered-By:
|
40
|
+
- Rack 1.1
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"Customer":{"@url":"https:\/\/api.fortnox.se\/3\/customers\/2","Address1":null,"Address2":null,"City":null,"Country":null,"Comments":null,"Currency":"SEK","CostCenter":null,"CountryCode":null,"CustomerNumber":"2","DefaultDeliveryTypes":{"Invoice":"PRINT","Order":"PRINT","Offer":"PRINT"},"DefaultTemplates":{"Order":"DEFAULTTEMPLATE","Offer":"DEFAULTTEMPLATE","Invoice":"DEFAULTTEMPLATE","CashInvoice":"DEFAULTTEMPLATE"},"DeliveryAddress1":null,"DeliveryAddress2":null,"DeliveryCity":null,"DeliveryCountry":null,"DeliveryCountryCode":null,"DeliveryFax":null,"DeliveryName":null,"DeliveryPhone1":null,"DeliveryPhone2":null,"DeliveryZipCode":null,"Email":"","EmailInvoice":"","EmailInvoiceBCC":"","EmailInvoiceCC":"","EmailOffer":"","EmailOfferBCC":"","EmailOfferCC":"","EmailOrder":"","EmailOrderBCC":"","EmailOrderCC":"","Fax":null,"InvoiceAdministrationFee":null,"InvoiceDiscount":null,"InvoiceFreight":null,"InvoiceRemark":"","Name":"A
|
44
|
+
customer","OrganisationNumber":"","OurReference":"","Phone1":null,"Phone2":null,"PriceList":"A","Project":"","SalesAccount":null,"ShowPriceVATIncluded":false,"TermsOfDelivery":"","TermsOfPayment":"","Type":"COMPANY","VATNumber":"","VATType":"SEVAT","VisitingAddress":null,"VisitingCity":null,"VisitingCountry":null,"VisitingCountryCode":null,"VisitingZipCode":null,"WayOfDelivery":"","WWW":"","YourReference":"","ZipCode":null}}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Wed, 09 Mar 2016 08:47:46 GMT
|
47
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: http://api.fortnox.se/3/customers/1
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"Customer":{"Currency":"SEK","Email":"","EmailInvoice":"","EmailInvoiceBCC":"","EmailInvoiceCC":"","EmailOffer":"","EmailOfferBCC":"","EmailOfferCC":"","EmailOrder":"","EmailOrderBCC":"","EmailOrderCC":"","InvoiceRemark":"","Name":"Updated
|
9
|
+
customer","OrganisationNumber":"","OurReference":"","PriceList":"A","Project":"","ShowPriceVATIncluded":false,"TermsOfDelivery":"","TermsOfPayment":"","Type":"COMPANY","VATNumber":"","VATType":"SEVAT","WayOfDelivery":"","YourReference":""}}'
|
10
|
+
headers:
|
11
|
+
Content-Type:
|
12
|
+
- application/json
|
13
|
+
Accept:
|
14
|
+
- application/json
|
15
|
+
Client-Secret:
|
16
|
+
- 9aBA8ZgsvR
|
17
|
+
Access-Token:
|
18
|
+
- ccaef817-d5d8-4b1c-a316-54f3e55c5c54
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 200
|
22
|
+
message: OK
|
23
|
+
headers:
|
24
|
+
Server:
|
25
|
+
- nginx
|
26
|
+
Date:
|
27
|
+
- Tue, 15 Mar 2016 06:00:34 GMT
|
28
|
+
Content-Type:
|
29
|
+
- application/json
|
30
|
+
Connection:
|
31
|
+
- close
|
32
|
+
Vary:
|
33
|
+
- Accept-Encoding
|
34
|
+
- Accept-Encoding
|
35
|
+
X-Rack-Responsetime:
|
36
|
+
- '687'
|
37
|
+
X-Uid:
|
38
|
+
- 5374e40c
|
39
|
+
X-Build:
|
40
|
+
- 954341dc68
|
41
|
+
X-Powered-By:
|
42
|
+
- Rack 1.1
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"Customer":{"@url":"https:\/\/api.fortnox.se\/3\/customers\/1","Address1":null,"Address2":null,"City":null,"Country":null,"Comments":null,"Currency":"SEK","CostCenter":null,"CountryCode":null,"CustomerNumber":"1","DefaultDeliveryTypes":{"Invoice":"PRINT","Order":"PRINT","Offer":"PRINT"},"DefaultTemplates":{"Order":"DEFAULTTEMPLATE","Offer":"DEFAULTTEMPLATE","Invoice":"DEFAULTTEMPLATE","CashInvoice":"DEFAULTTEMPLATE"},"DeliveryAddress1":null,"DeliveryAddress2":null,"DeliveryCity":null,"DeliveryCountry":null,"DeliveryCountryCode":null,"DeliveryFax":null,"DeliveryName":null,"DeliveryPhone1":null,"DeliveryPhone2":null,"DeliveryZipCode":null,"Email":"","EmailInvoice":"","EmailInvoiceBCC":"","EmailInvoiceCC":"","EmailOffer":"","EmailOfferBCC":"","EmailOfferCC":"","EmailOrder":"","EmailOrderBCC":"","EmailOrderCC":"","Fax":null,"InvoiceAdministrationFee":null,"InvoiceDiscount":null,"InvoiceFreight":null,"InvoiceRemark":"","Name":"Updated
|
46
|
+
customer","OrganisationNumber":"","OurReference":"","Phone1":null,"Phone2":null,"PriceList":"A","Project":"","SalesAccount":null,"ShowPriceVATIncluded":false,"TermsOfDelivery":"","TermsOfPayment":"","Type":"COMPANY","VATNumber":"","VATType":"SEVAT","VisitingAddress":null,"VisitingCity":null,"VisitingCountry":null,"VisitingCountryCode":null,"VisitingZipCode":null,"WayOfDelivery":"","WWW":"","YourReference":"","ZipCode":null}}'
|
47
|
+
http_version:
|
48
|
+
recorded_at: Tue, 15 Mar 2016 06:00:34 GMT
|
49
|
+
recorded_with: VCR 3.0.1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortnox-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Schubert Erlandsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '1.21'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: vcr
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: pry
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +178,20 @@ dependencies:
|
|
164
178
|
- - ">="
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: codeclimate-test-reporter
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
167
195
|
description: This gem uses the HTTParty library to abstract away the REST calls. It
|
168
196
|
gives you access to a number of objects that behave a lot like ActiveRecord instances,
|
169
197
|
giving you access to methods like `all`, `find`, `find_by_...` and so on. And each
|
@@ -175,36 +203,90 @@ executables: []
|
|
175
203
|
extensions: []
|
176
204
|
extra_rdoc_files: []
|
177
205
|
files:
|
206
|
+
- ".codeclimate.yml"
|
178
207
|
- ".gitignore"
|
179
208
|
- ".rspec"
|
180
|
-
- ".
|
209
|
+
- ".rubocop.yml"
|
181
210
|
- ".travis.yml"
|
211
|
+
- CONTRIBUTE.md
|
182
212
|
- Gemfile
|
183
|
-
- Gemfile.lock
|
184
213
|
- Guardfile
|
185
214
|
- LICENSE.txt
|
186
215
|
- README.md
|
187
216
|
- Rakefile
|
217
|
+
- docs/account.rb
|
218
|
+
- docs/extraction_script.js
|
219
|
+
- docs/generation_script.rb
|
220
|
+
- docs/json/account.json
|
188
221
|
- fortnox-api.gemspec
|
189
222
|
- lib/fortnox/api.rb
|
190
223
|
- lib/fortnox/api/base.rb
|
191
224
|
- lib/fortnox/api/class_methods.rb
|
192
|
-
- lib/fortnox/api/
|
193
|
-
- lib/fortnox/api/
|
194
|
-
- lib/fortnox/api/
|
195
|
-
- lib/fortnox/api/
|
196
|
-
- lib/fortnox/api/
|
197
|
-
- lib/fortnox/api/
|
198
|
-
- lib/fortnox/api/
|
199
|
-
- lib/fortnox/api/
|
200
|
-
- lib/fortnox/api/
|
201
|
-
- lib/fortnox/api/
|
225
|
+
- lib/fortnox/api/environment_validation.rb
|
226
|
+
- lib/fortnox/api/models.rb
|
227
|
+
- lib/fortnox/api/models/attributes/country_code.rb
|
228
|
+
- lib/fortnox/api/models/attributes/currency.rb
|
229
|
+
- lib/fortnox/api/models/base.rb
|
230
|
+
- lib/fortnox/api/models/customer.rb
|
231
|
+
- lib/fortnox/api/models/edi_information.rb
|
232
|
+
- lib/fortnox/api/models/email_information.rb
|
233
|
+
- lib/fortnox/api/models/invoice.rb
|
234
|
+
- lib/fortnox/api/models/row.rb
|
235
|
+
- lib/fortnox/api/repositories.rb
|
236
|
+
- lib/fortnox/api/repositories/base.rb
|
237
|
+
- lib/fortnox/api/repositories/base/json_convertion.rb
|
238
|
+
- lib/fortnox/api/repositories/base/loaders.rb
|
239
|
+
- lib/fortnox/api/repositories/base/options.rb
|
240
|
+
- lib/fortnox/api/repositories/base/savers.rb
|
241
|
+
- lib/fortnox/api/repositories/customer.rb
|
242
|
+
- lib/fortnox/api/repositories/invoice.rb
|
243
|
+
- lib/fortnox/api/request_handling.rb
|
244
|
+
- lib/fortnox/api/validators.rb
|
245
|
+
- lib/fortnox/api/validators/attributes/country_code.rb
|
246
|
+
- lib/fortnox/api/validators/attributes/currency.rb
|
247
|
+
- lib/fortnox/api/validators/base.rb
|
248
|
+
- lib/fortnox/api/validators/constant.rb
|
249
|
+
- lib/fortnox/api/validators/customer.rb
|
250
|
+
- lib/fortnox/api/validators/edi_information.rb
|
251
|
+
- lib/fortnox/api/validators/email_information.rb
|
252
|
+
- lib/fortnox/api/validators/invoice.rb
|
253
|
+
- lib/fortnox/api/validators/row.rb
|
202
254
|
- lib/fortnox/api/version.rb
|
203
255
|
- spec/fortnox/api/base_spec.rb
|
204
|
-
- spec/fortnox/api/
|
205
|
-
- spec/fortnox/api/
|
206
|
-
- spec/fortnox/api/
|
256
|
+
- spec/fortnox/api/models/attributes/country_code_spec.rb
|
257
|
+
- spec/fortnox/api/models/attributes/currency_spec.rb
|
258
|
+
- spec/fortnox/api/models/attributes/dummy_model_context.rb
|
259
|
+
- spec/fortnox/api/models/base_spec.rb
|
260
|
+
- spec/fortnox/api/models/invoice_spec.rb
|
261
|
+
- spec/fortnox/api/models/row_spec.rb
|
262
|
+
- spec/fortnox/api/repositories/context.rb
|
263
|
+
- spec/fortnox/api/repositories/customer_spec.rb
|
264
|
+
- spec/fortnox/api/repositories/examples.rb
|
265
|
+
- spec/fortnox/api/repositories/invoice_spec.rb
|
266
|
+
- spec/fortnox/api/validators/attributes/country_code_spec.rb
|
267
|
+
- spec/fortnox/api/validators/attributes/currency_spec.rb
|
268
|
+
- spec/fortnox/api/validators/attributes/examples_for_validate.rb
|
269
|
+
- spec/fortnox/api/validators/base_spec.rb
|
270
|
+
- spec/fortnox/api/validators/constant_spec.rb
|
271
|
+
- spec/fortnox/api/validators/context.rb
|
272
|
+
- spec/fortnox/api/validators/customer_spec.rb
|
273
|
+
- spec/fortnox/api/validators/edi_information_spec.rb
|
274
|
+
- spec/fortnox/api/validators/email_information_spec.rb
|
275
|
+
- spec/fortnox/api/validators/invoice_spec.rb
|
276
|
+
- spec/fortnox/api/validators/row_spec.rb
|
277
|
+
- spec/fortnox/api/validators/validator_examples.rb
|
278
|
+
- spec/fortnox/api_spec.rb
|
207
279
|
- spec/spec_helper.rb
|
280
|
+
- spec/support/helpers.rb
|
281
|
+
- spec/support/helpers/dummy_class_helper.rb
|
282
|
+
- spec/support/matchers.rb
|
283
|
+
- spec/support/matchers/models.rb
|
284
|
+
- spec/support/matchers/validators.rb
|
285
|
+
- spec/support/vcr_setup.rb
|
286
|
+
- spec/vcr_cassettes/customers/all.yml
|
287
|
+
- spec/vcr_cassettes/customers/find_id_1.yml
|
288
|
+
- spec/vcr_cassettes/customers/save_new.yml
|
289
|
+
- spec/vcr_cassettes/customers/save_old.yml
|
208
290
|
homepage: http://github.com/my-codeworks/fortnox-api
|
209
291
|
licenses:
|
210
292
|
- MIT
|
@@ -225,13 +307,43 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
307
|
version: '0'
|
226
308
|
requirements: []
|
227
309
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.
|
310
|
+
rubygems_version: 2.4.5
|
229
311
|
signing_key:
|
230
312
|
specification_version: 4
|
231
313
|
summary: Gem to use Fortnox REST API in Ruby.
|
232
314
|
test_files:
|
233
315
|
- spec/fortnox/api/base_spec.rb
|
234
|
-
- spec/fortnox/api/
|
235
|
-
- spec/fortnox/api/
|
236
|
-
- spec/fortnox/api/
|
316
|
+
- spec/fortnox/api/models/attributes/country_code_spec.rb
|
317
|
+
- spec/fortnox/api/models/attributes/currency_spec.rb
|
318
|
+
- spec/fortnox/api/models/attributes/dummy_model_context.rb
|
319
|
+
- spec/fortnox/api/models/base_spec.rb
|
320
|
+
- spec/fortnox/api/models/invoice_spec.rb
|
321
|
+
- spec/fortnox/api/models/row_spec.rb
|
322
|
+
- spec/fortnox/api/repositories/context.rb
|
323
|
+
- spec/fortnox/api/repositories/customer_spec.rb
|
324
|
+
- spec/fortnox/api/repositories/examples.rb
|
325
|
+
- spec/fortnox/api/repositories/invoice_spec.rb
|
326
|
+
- spec/fortnox/api/validators/attributes/country_code_spec.rb
|
327
|
+
- spec/fortnox/api/validators/attributes/currency_spec.rb
|
328
|
+
- spec/fortnox/api/validators/attributes/examples_for_validate.rb
|
329
|
+
- spec/fortnox/api/validators/base_spec.rb
|
330
|
+
- spec/fortnox/api/validators/constant_spec.rb
|
331
|
+
- spec/fortnox/api/validators/context.rb
|
332
|
+
- spec/fortnox/api/validators/customer_spec.rb
|
333
|
+
- spec/fortnox/api/validators/edi_information_spec.rb
|
334
|
+
- spec/fortnox/api/validators/email_information_spec.rb
|
335
|
+
- spec/fortnox/api/validators/invoice_spec.rb
|
336
|
+
- spec/fortnox/api/validators/row_spec.rb
|
337
|
+
- spec/fortnox/api/validators/validator_examples.rb
|
338
|
+
- spec/fortnox/api_spec.rb
|
237
339
|
- spec/spec_helper.rb
|
340
|
+
- spec/support/helpers.rb
|
341
|
+
- spec/support/helpers/dummy_class_helper.rb
|
342
|
+
- spec/support/matchers.rb
|
343
|
+
- spec/support/matchers/models.rb
|
344
|
+
- spec/support/matchers/validators.rb
|
345
|
+
- spec/support/vcr_setup.rb
|
346
|
+
- spec/vcr_cassettes/customers/all.yml
|
347
|
+
- spec/vcr_cassettes/customers/find_id_1.yml
|
348
|
+
- spec/vcr_cassettes/customers/save_new.yml
|
349
|
+
- spec/vcr_cassettes/customers/save_old.yml
|