netvisor 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +1 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/README.md +16 -2
- data/Rakefile +6 -0
- data/lib/netvisor.rb +20 -2
- data/lib/netvisor/base.rb +24 -0
- data/lib/netvisor/configuration.rb +22 -0
- data/lib/netvisor/request.rb +63 -0
- data/lib/netvisor/root.rb +12 -0
- data/lib/netvisor/sales_invoice.rb +195 -0
- data/lib/netvisor/sales_invoice_line.rb +19 -0
- data/lib/netvisor/sales_invoice_product_line.rb +40 -0
- data/lib/netvisor/vat_percentage.rb +10 -0
- data/lib/netvisor/version.rb +1 -1
- data/netvisor.gemspec +11 -1
- data/spec/netvisor/configuration_spec.rb +19 -0
- data/spec/netvisor_spec.rb +38 -0
- data/spec/spec_helper.rb +95 -0
- metadata +195 -47
- checksums.yaml +0 -7
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.8.7-p375
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Netvisor
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/netvisor.svg)](http://badge.fury.io/rb/netvisor)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/Eficode/netvisor/badge.png)](https://coveralls.io/r/Eficode/netvisor)
|
4
|
+
[![Build Status](https://travis-ci.org/Eficode/netvisor.svg?branch=master)](https://travis-ci.org/Eficode/netvisor)
|
2
5
|
|
3
|
-
|
6
|
+
This gem aims to be a complete implementation of the Netvisor API
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -20,7 +23,18 @@ Or install it yourself as:
|
|
20
23
|
|
21
24
|
## Usage
|
22
25
|
|
23
|
-
|
26
|
+
### Configure
|
27
|
+
|
28
|
+
```
|
29
|
+
Netvisor.configure do |config|
|
30
|
+
config.host = Netvisor environment host
|
31
|
+
config.sender = Name of sender (defautls to: 'Netvisor gem')
|
32
|
+
config.customer_id = Your customer ID
|
33
|
+
config.partner_id = Your partner ID
|
34
|
+
config.language = language for the API
|
35
|
+
config.organisation_id = Your organisation ID
|
36
|
+
config.customer_key = Customer key
|
37
|
+
config.partner_ke = Partner key
|
24
38
|
|
25
39
|
## Contributing
|
26
40
|
|
data/Rakefile
CHANGED
data/lib/netvisor.rb
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
require "netvisor/version"
|
2
|
+
require "netvisor/base"
|
3
|
+
require "netvisor/configuration"
|
2
4
|
|
3
5
|
module Netvisor
|
4
|
-
|
5
|
-
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.new(config)
|
11
|
+
Netvisor::Base.new(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield(configuration)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= Configuration.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.reset
|
23
|
+
@configuration = Configuration.new
|
6
24
|
end
|
7
25
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'netvisor/root'
|
2
|
+
require 'netvisor/request'
|
3
|
+
|
4
|
+
module Netvisor
|
5
|
+
class Base
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
8
|
+
end
|
9
|
+
|
10
|
+
def send_invoice(sales_invoice)
|
11
|
+
request(sales_invoice, 'sales_invoice')
|
12
|
+
end
|
13
|
+
|
14
|
+
def request(data_object, service, method = nil, id = nil)
|
15
|
+
root = Root.new
|
16
|
+
# root.send(service, data_object)
|
17
|
+
# validate root
|
18
|
+
req = Request.new(@config)
|
19
|
+
|
20
|
+
req.send(root.to_xml, service, method, id)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Netvisor
|
2
|
+
Configuration = Struct.new(
|
3
|
+
:host,
|
4
|
+
:sender,
|
5
|
+
:customer_id,
|
6
|
+
:partner_id,
|
7
|
+
:language,
|
8
|
+
:organisation_id,
|
9
|
+
:customer_key,
|
10
|
+
:partner_key) do
|
11
|
+
|
12
|
+
# Initialize override to accept named parameters (Config(:host => 'foo'...))
|
13
|
+
# http://stackoverflow.com/questions/5407940/named-parameters-in-ruby-structs
|
14
|
+
def initialize *args
|
15
|
+
return super unless (args.length == 1 and args.first.instance_of? Hash)
|
16
|
+
args.first.each_pair do |k, v|
|
17
|
+
self[k] = v if members.map {|x| x.intern}.include? k
|
18
|
+
end
|
19
|
+
self.sender ||= 'Netvisor gem'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module Netvisor
|
4
|
+
class Request
|
5
|
+
|
6
|
+
def send(xml, service, method = nil, id = nil)
|
7
|
+
url = build_url(service, method, id)
|
8
|
+
headers = build_headers(url)
|
9
|
+
root = Netvisor::Root.parse(File.read("example_salesinvoice.xml"))
|
10
|
+
xml = root.to_xml
|
11
|
+
p xml
|
12
|
+
|
13
|
+
new_xml = "<!DOCTYPE salesinvoice SYSTEM \"salesinvoice.dtd\" >" + xml
|
14
|
+
# tell the parsing to actually load the DTD which it doesn't do by default
|
15
|
+
# options = Nokogiri::XML::ParseOptions::DEFAULT_XML | Nokogiri::XML::ParseOptions::DTDLOAD
|
16
|
+
doc = Nokogiri::XML::Document.parse(new_xml)#,nil,nil,options)
|
17
|
+
xml.gsub!("<?xml version=\"1.0\"?>", '')
|
18
|
+
p xml
|
19
|
+
|
20
|
+
res = Faraday.post(url) do |req|
|
21
|
+
req.headers.merge!(headers)
|
22
|
+
req.body = xml
|
23
|
+
end
|
24
|
+
p res
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.build_url(service, method, id)
|
28
|
+
url = "#{Netvisor.configuration.host || 'http://integrationdemo.netvisor.fi'}/#{service.gsub(/_/,'')}.nv"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build_headers(url)
|
32
|
+
timestamp = DateTime.parse(Time.now.utc.to_s).strftime("%F %T.%L")
|
33
|
+
transaction_id = ((1000...9999).to_a.choice + Time.now.to_i).to_s
|
34
|
+
return {
|
35
|
+
'X-Netvisor-Authentication-Sender' => Netvisor.configuration.sender || 'Netvisor gem',
|
36
|
+
'X-Netvisor-Authentication-CustomerId' => Netvisor.configuration.customer_id || 'EB_10197_551',
|
37
|
+
'X-Netvisor-Authentication-PartnerId' => Netvisor.configuration.partner_id || 'Efi_249',
|
38
|
+
'X-Netvisor-Authentication-Timestamp' => timestamp,
|
39
|
+
'X-Netvisor-Authentication-MAC' => build_mac(url, timestamp, transaction_id),
|
40
|
+
'X-Netvisor-Authentication-TransactionId' => transaction_id,
|
41
|
+
'X-Netvisor-Interface-Language' => Netvisor.configuration.language || 'FI',
|
42
|
+
'X-Netvisor-Organisation-ID' => Netvisor.configuration.organisation_id || '0111111-7',
|
43
|
+
'X-Netvisor-Authentication-MACHashCalculationAlgorithm' => 'SHA256'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.build_mac(url, timestamp, transaction_id)
|
48
|
+
arr = [
|
49
|
+
url,
|
50
|
+
Netvisor.configuration.sender || 'Netvisor gem',
|
51
|
+
Netvisor.configuration.customer_id || 'EB_10197_551',
|
52
|
+
timestamp,
|
53
|
+
Netvisor.configuration.language || 'FI',
|
54
|
+
Netvisor.configuration.organisation_id || '0111111-7',
|
55
|
+
transaction_id,
|
56
|
+
Netvisor.configuration.customer_key || 'EF1E64BD5D7E0301417B7FE1BF059694',
|
57
|
+
Netvisor.configuration.partner_key || '6F4C9C0DD3C1C263DAC131ED3AF89A7C'
|
58
|
+
]
|
59
|
+
p timestamp, arr.join('&')
|
60
|
+
Digest::SHA2.hexdigest(arr.join('&'))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'netvisor/sales_invoice_line'
|
3
|
+
require 'netvisor/vat_percentage'
|
4
|
+
|
5
|
+
module Netvisor
|
6
|
+
class SalesInvoice
|
7
|
+
include HappyMapper
|
8
|
+
|
9
|
+
tag self.name.split('::').last
|
10
|
+
|
11
|
+
class InvoiceDate
|
12
|
+
include HappyMapper
|
13
|
+
|
14
|
+
attribute :format, String
|
15
|
+
content :date, Date
|
16
|
+
end
|
17
|
+
|
18
|
+
class InvoiceDeliveryDate
|
19
|
+
include HappyMapper
|
20
|
+
|
21
|
+
attribute :format, String
|
22
|
+
content :date, Date
|
23
|
+
end
|
24
|
+
|
25
|
+
class InvoiceAmount
|
26
|
+
include HappyMapper
|
27
|
+
|
28
|
+
attribute :iso4217currencycode, String
|
29
|
+
attribute :currencyrate, Float
|
30
|
+
content :amount, Float
|
31
|
+
end
|
32
|
+
|
33
|
+
class SellerId
|
34
|
+
include HappyMapper
|
35
|
+
|
36
|
+
attribute :type, String
|
37
|
+
content :id, String
|
38
|
+
end
|
39
|
+
|
40
|
+
class InvoiceStatus
|
41
|
+
include HappyMapper
|
42
|
+
|
43
|
+
attribute :type, String
|
44
|
+
content :status, String
|
45
|
+
end
|
46
|
+
|
47
|
+
class CustomerId
|
48
|
+
include HappyMapper
|
49
|
+
|
50
|
+
attribute :type, String
|
51
|
+
content :id, String
|
52
|
+
end
|
53
|
+
|
54
|
+
class CountryCode
|
55
|
+
include HappyMapper
|
56
|
+
|
57
|
+
attribute :type, String
|
58
|
+
content :country_code, String
|
59
|
+
end
|
60
|
+
|
61
|
+
class CashDiscount
|
62
|
+
include HappyMapper
|
63
|
+
|
64
|
+
attribute :type, String
|
65
|
+
content :discount, Integer
|
66
|
+
end
|
67
|
+
|
68
|
+
class DirectDebitLink
|
69
|
+
include HappyMapper
|
70
|
+
|
71
|
+
attribute :mode, String
|
72
|
+
content :link, Integer
|
73
|
+
end
|
74
|
+
|
75
|
+
class InvoiceVoucherLines
|
76
|
+
include HappyMapper
|
77
|
+
|
78
|
+
class VoucherLine
|
79
|
+
include HappyMapper
|
80
|
+
|
81
|
+
tag 'VoucherLine'
|
82
|
+
|
83
|
+
class LineSum
|
84
|
+
include HappyMapper
|
85
|
+
|
86
|
+
attribute :type, String
|
87
|
+
content :sum, Float
|
88
|
+
end
|
89
|
+
|
90
|
+
element :line_sum, LineSum, :tag => 'LineSum'
|
91
|
+
element :description, String, :tag => 'Description'
|
92
|
+
element :account_number, String, :tag => 'AccountNumber'
|
93
|
+
element :vat_percentage, VatPercentage, :tag => 'VatPercent'
|
94
|
+
end
|
95
|
+
|
96
|
+
has_many :lines, VoucherLine, :tag => 'VoucherLine'
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
class SalesInvoiceAttachments
|
101
|
+
include HappyMapper
|
102
|
+
|
103
|
+
class InvoiceAttachment
|
104
|
+
include HappyMapper
|
105
|
+
|
106
|
+
tag self.name.split('::').last
|
107
|
+
|
108
|
+
element :mime_type, String, :tag => 'MimeType'
|
109
|
+
element :description, String, :tag => 'AttachmentDescription'
|
110
|
+
element :filename, String, :tag => 'FileName'
|
111
|
+
element :document_data, String, :tag => 'DocumentData'
|
112
|
+
end
|
113
|
+
|
114
|
+
has_many :attachments, InvoiceAttachment, :tag => 'SalesInvoiceAttachment'
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
class CustomTags
|
119
|
+
include HappyMapper
|
120
|
+
|
121
|
+
|
122
|
+
class CustomTag
|
123
|
+
include HappyMapper
|
124
|
+
|
125
|
+
class TagValue
|
126
|
+
include HappyMapper
|
127
|
+
|
128
|
+
attribute :datatype, String
|
129
|
+
content :value, String
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
element :name, String, :tag => 'TagName'
|
135
|
+
element :value, TagValue, :tag => 'TagValue'
|
136
|
+
end
|
137
|
+
|
138
|
+
has_many :tags, CustomTag, :tag => 'Tag'
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
class SalesInvoiceLines
|
143
|
+
include HappyMapper
|
144
|
+
|
145
|
+
has_many :invoice_lines, SalesInvoiceLine, :tag => 'InvoiceLine'
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
element :invoice_number, String, :tag => 'SalesInvoiceNumber'
|
150
|
+
element :invoice_date, InvoiceDate, :tag => 'SalesInvoiceDate'
|
151
|
+
element :invoice_delivery_date, InvoiceDeliveryDate, :tag => 'SalesInvoiceDeliveryDate'
|
152
|
+
element :reference_number, String, :tag => 'SalesInvoiceReferenceNumber'
|
153
|
+
element :invoice_amount, InvoiceAmount, :tag => 'SalesInvoiceAmount'
|
154
|
+
element :seller_id, SellerId, :tag => 'SellerIdentifier'
|
155
|
+
element :seller_name, String, :tag => 'SellerName'
|
156
|
+
element :type, String, :tag => 'InvoiceType'
|
157
|
+
element :text_before_lines, String, :tag => 'SalesInvoiceFreeTextBeforeLines'
|
158
|
+
element :text_after_lines, String, :tag => 'SalesInvoiceFreeTextAfterLines'
|
159
|
+
element :our_reference, String, :tag => 'SalesInvoiceOurReference'
|
160
|
+
element :your_reference, String, :tag => 'SalesInvoiceYourReference'
|
161
|
+
element :comment, String, :tag => 'SalesInvoicePrivateComment'
|
162
|
+
element :status, InvoiceStatus, :tag => 'SalesInvoiceStatus'
|
163
|
+
|
164
|
+
element :customer_id, CustomerId, :tag => 'InvoicingCustomerIdentifier'
|
165
|
+
element :customer_firstname, String, :tag => 'InvoicingCustomerName'
|
166
|
+
element :customer_lastname, String, :tag => 'InvoicingCustomerNameExtension'
|
167
|
+
element :customer_address, String, :tag => 'InvoicingCustomerAddressLine'
|
168
|
+
element :customer_postal_code, String, :tag => 'InvoicingCustomerPostNumber'
|
169
|
+
element :customer_city, String, :tag => 'InvoicingCustomerTown'
|
170
|
+
element :customer_country, CountryCode, :tag => 'InvoicingCustomerCountryCode'
|
171
|
+
|
172
|
+
element :delivery_method, String, :tag => 'DeliveryMethod'
|
173
|
+
element :delivery_term, String, :tag => 'DeliveryTerm'
|
174
|
+
element :delivery_address_name, String, :tag => 'DeliveryAddressName'
|
175
|
+
element :delivery_address_name_extension, String, :tag => 'DeliveryAddressNameExtension'
|
176
|
+
element :delivery_address_line, String, :tag => 'DeliveryAddressLine'
|
177
|
+
element :delivery_address_postal_code, String, :tag => 'DeliveryAddressPostNumber'
|
178
|
+
element :delivery_address_city, String, :tag => 'DeliveryAddressTown'
|
179
|
+
element :delivery_address_countrey, CountryCode, :tag => 'DeliveryAddressCountryCode'
|
180
|
+
|
181
|
+
element :tax_handling_type, String, :tag => 'SalesInvoiceTaxHandlingType'
|
182
|
+
element :payment_net_days, Integer, :tag => 'PaymentTermNetDays'
|
183
|
+
element :cash_discount_days, Integer, :tag => 'PaymentTermCashDiscountDays'
|
184
|
+
element :cash_discount, CashDiscount, :tag => 'PaymentTermCashDiscount'
|
185
|
+
element :partial_payments, Integer, :tag => 'ExpectPartialPayments'
|
186
|
+
element :direct_debit_link, DirectDebitLink, :tag => 'TryDirectDebitLink'
|
187
|
+
element :overrise_account_number, Integer, :tag => 'OverrideVoucherSalesReceivablesAccountNumber'
|
188
|
+
element :subject_type, String, :tag => 'InvoiceSubjectType'
|
189
|
+
|
190
|
+
has_many :invoice_lines, SalesInvoiceLines, :tag => 'InvoiceLines'
|
191
|
+
has_many :voucher_lines, InvoiceVoucherLines, :tag => 'InvoiceVoucherLines'
|
192
|
+
has_many :attachments, SalesInvoiceAttachments, :tag => 'SalesInvoiceAttachments'
|
193
|
+
has_many :custom_tags, CustomTags, :tag => 'CustomTags'
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'netvisor/sales_invoice_product_line'
|
3
|
+
|
4
|
+
module Netvisor
|
5
|
+
class SalesInvoiceLine
|
6
|
+
include HappyMapper
|
7
|
+
|
8
|
+
tag 'InvoiceLine'
|
9
|
+
|
10
|
+
class SalesInvoiceCommentLine
|
11
|
+
include HappyMapper
|
12
|
+
|
13
|
+
tag self.name.split('::').last
|
14
|
+
has_one :comment, String, :tag => 'Comment'
|
15
|
+
end
|
16
|
+
has_one :product_line, SalesInvoiceProductLine
|
17
|
+
has_one :comment_line, SalesInvoiceCommentLine
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'netvisor/vat_percentage'
|
3
|
+
|
4
|
+
module Netvisor
|
5
|
+
class SalesInvoiceProductLine
|
6
|
+
include HappyMapper
|
7
|
+
|
8
|
+
class ProductId
|
9
|
+
include HappyMapper
|
10
|
+
|
11
|
+
attribute :type, String
|
12
|
+
content :id, String
|
13
|
+
end
|
14
|
+
class UnitPrice
|
15
|
+
include HappyMapper
|
16
|
+
|
17
|
+
attribute :type, String
|
18
|
+
content :price, String
|
19
|
+
end
|
20
|
+
|
21
|
+
class Dimension
|
22
|
+
include HappyMapper
|
23
|
+
|
24
|
+
element :name, String, :tag => 'DimensionName'
|
25
|
+
element :item, String, :tag => 'DimensionItem'
|
26
|
+
end
|
27
|
+
|
28
|
+
tag self.name.split('::').last
|
29
|
+
|
30
|
+
element :product_id, ProductId, :tag => 'ProductIdentifier'
|
31
|
+
element :name, String, :tag => 'ProductName'
|
32
|
+
element :unit_price, UnitPrice, :tag => 'ProductUnitPrice'
|
33
|
+
element :vat_percentage, VatPercentage, :tag => 'ProductVatPercentage'
|
34
|
+
element :quantity, Integer, :tag => 'SalesInvoiceProductLineQuantity'
|
35
|
+
element :accounting_suggestion, Integer, :tag => 'AccountingAccountSuggestion'
|
36
|
+
element :AccountingAccountSuggestion, Integer, :tag => 'ProductUnitPurchasePrice'
|
37
|
+
element :discount_percentage, Integer, :tag => 'SalesInvoiceProductLineDiscountPercentage'
|
38
|
+
has_many :dimensions, Dimension, :tag => 'Dimension'
|
39
|
+
end
|
40
|
+
end
|
data/lib/netvisor/version.rb
CHANGED
data/netvisor.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = <<-EOF
|
13
13
|
This gem is a ruby implementation of the Netvisor invoicing API
|
14
14
|
EOF
|
15
|
-
spec.homepage = "
|
15
|
+
spec.homepage = "https://github.com/Eficode/netvisor"
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -20,6 +20,16 @@ EOF
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
+
spec.required_ruby_version = '1.8.7'
|
24
|
+
|
23
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "pry", "~> 0.9.12"
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
29
|
+
spec.add_development_dependency 'coveralls'
|
30
|
+
spec.add_development_dependency 'rest-client', '~> 1.6.8'
|
31
|
+
|
32
|
+
spec.add_runtime_dependency "faraday", "~> 0.9"
|
33
|
+
spec.add_runtime_dependency "nokogiri-happymapper", "~> 0.5.9"
|
34
|
+
spec.add_runtime_dependency "nokogiri", "~> 1.5.11"
|
25
35
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Netvisor
|
4
|
+
describe Configuration do
|
5
|
+
describe "#host" do
|
6
|
+
it "default value is nil" do
|
7
|
+
Configuration.new.host = 'http://foo.bar'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#host=" do
|
12
|
+
it "can set value" do
|
13
|
+
config = Configuration.new
|
14
|
+
config.host = 'http://foo.bar'
|
15
|
+
expect(config.host).to eq('http://foo.bar')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Netvisor do
|
4
|
+
describe "#configure" do
|
5
|
+
before do
|
6
|
+
Netvisor.configure do |config|
|
7
|
+
config.host = 'http://foo.bar'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns a url for foo.bar" do
|
12
|
+
url = Netvisor::Request.build_url('baz', nil, nil)
|
13
|
+
|
14
|
+
expect(url).to be_a(String)
|
15
|
+
expect(url).to eq('http://foo.bar/baz.nv')
|
16
|
+
end
|
17
|
+
|
18
|
+
after :each do
|
19
|
+
Netvisor.reset
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".reset" do
|
24
|
+
before :each do
|
25
|
+
Netvisor.configure do |config|
|
26
|
+
config.host = 'http://foo.bar'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "resets the configuration" do
|
31
|
+
Netvisor.reset
|
32
|
+
|
33
|
+
config = Netvisor.configuration
|
34
|
+
|
35
|
+
expect(config.host).to eq(nil)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
|
5
|
+
require 'netvisor'
|
6
|
+
|
7
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
8
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
9
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
10
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
11
|
+
#
|
12
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
13
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
14
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
15
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
16
|
+
# a separate helper file that requires the additional dependencies and performs
|
17
|
+
# the additional setup, and require it from the spec files that actually need it.
|
18
|
+
#
|
19
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
20
|
+
# users commonly want.
|
21
|
+
#
|
22
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# rspec-expectations config goes here. You can use an alternate
|
25
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
26
|
+
# assertions if you prefer.
|
27
|
+
config.expect_with :rspec do |expectations|
|
28
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
29
|
+
# and `failure_message` of custom matchers include text for helper methods
|
30
|
+
# defined using `chain`, e.g.:
|
31
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
32
|
+
# # => "be bigger than 2 and smaller than 4"
|
33
|
+
# ...rather than:
|
34
|
+
# # => "be bigger than 2"
|
35
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
36
|
+
end
|
37
|
+
|
38
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
39
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
40
|
+
config.mock_with :rspec do |mocks|
|
41
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
42
|
+
# a real object. This is generally recommended, and will default to
|
43
|
+
# `true` in RSpec 4.
|
44
|
+
mocks.verify_partial_doubles = true
|
45
|
+
end
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# These two settings work together to allow you to limit a spec run
|
51
|
+
# to individual examples or groups you care about by tagging them with
|
52
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
53
|
+
# get run.
|
54
|
+
config.filter_run :focus
|
55
|
+
config.run_all_when_everything_filtered = true
|
56
|
+
|
57
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
58
|
+
# For more details, see:
|
59
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
60
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
61
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
62
|
+
config.disable_monkey_patching!
|
63
|
+
|
64
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
65
|
+
# be too noisy due to issues in dependencies.
|
66
|
+
config.warnings = true
|
67
|
+
|
68
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
69
|
+
# file, and it's useful to allow more verbose output when running an
|
70
|
+
# individual spec file.
|
71
|
+
if config.files_to_run.one?
|
72
|
+
# Use the documentation formatter for detailed output,
|
73
|
+
# unless a formatter has already been configured
|
74
|
+
# (e.g. via a command-line flag).
|
75
|
+
config.default_formatter = 'doc'
|
76
|
+
end
|
77
|
+
|
78
|
+
# Print the 10 slowest examples and example groups at the
|
79
|
+
# end of the spec run, to help surface which specs are running
|
80
|
+
# particularly slow.
|
81
|
+
config.profile_examples = 10
|
82
|
+
=end
|
83
|
+
|
84
|
+
# Run specs in random order to surface order dependencies. If you find an
|
85
|
+
# order dependency and want to debug it, you can fix the order by providing
|
86
|
+
# the seed, which is printed after each run.
|
87
|
+
# --seed 1234
|
88
|
+
config.order = :random
|
89
|
+
|
90
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
91
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
92
|
+
# test failures related to randomization by passing the same `--seed` value
|
93
|
+
# as the one that triggered the failure.
|
94
|
+
Kernel.srand config.seed
|
95
|
+
end
|
metadata
CHANGED
@@ -1,82 +1,230 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: netvisor
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Timo Sand
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-09-08 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 1
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 7
|
30
|
+
version: "1.7"
|
31
|
+
prerelease: false
|
32
|
+
requirement: *id001
|
33
|
+
type: :development
|
14
34
|
name: bundler
|
15
|
-
|
16
|
-
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
17
39
|
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 35
|
42
|
+
segments:
|
43
|
+
- 10
|
44
|
+
- 0
|
45
|
+
version: "10.0"
|
46
|
+
prerelease: false
|
47
|
+
requirement: *id002
|
20
48
|
type: :development
|
49
|
+
name: rake
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 35
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 9
|
60
|
+
- 12
|
61
|
+
version: 0.9.12
|
21
62
|
prerelease: false
|
22
|
-
|
23
|
-
|
63
|
+
requirement: *id003
|
64
|
+
type: :development
|
65
|
+
name: pry
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
24
70
|
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 3
|
75
|
+
- 1
|
76
|
+
- 0
|
77
|
+
version: 3.1.0
|
78
|
+
prerelease: false
|
79
|
+
requirement: *id004
|
80
|
+
type: :development
|
81
|
+
name: rspec
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
prerelease: false
|
93
|
+
requirement: *id005
|
94
|
+
type: :development
|
95
|
+
name: coveralls
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
31
100
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 31
|
103
|
+
segments:
|
104
|
+
- 1
|
105
|
+
- 6
|
106
|
+
- 8
|
107
|
+
version: 1.6.8
|
108
|
+
prerelease: false
|
109
|
+
requirement: *id006
|
34
110
|
type: :development
|
111
|
+
name: rest-client
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
hash: 25
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
- 9
|
122
|
+
version: "0.9"
|
123
|
+
prerelease: false
|
124
|
+
requirement: *id007
|
125
|
+
type: :runtime
|
126
|
+
name: faraday
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 25
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
- 5
|
137
|
+
- 9
|
138
|
+
version: 0.5.9
|
35
139
|
prerelease: false
|
36
|
-
|
37
|
-
|
140
|
+
requirement: *id008
|
141
|
+
type: :runtime
|
142
|
+
name: nokogiri-happymapper
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
38
147
|
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 21
|
150
|
+
segments:
|
151
|
+
- 1
|
152
|
+
- 5
|
153
|
+
- 11
|
154
|
+
version: 1.5.11
|
155
|
+
prerelease: false
|
156
|
+
requirement: *id009
|
157
|
+
type: :runtime
|
158
|
+
name: nokogiri
|
159
|
+
description: " This gem is a ruby implementation of the Netvisor invoicing API\n"
|
160
|
+
email:
|
44
161
|
- timo.j.sand@gmail.com
|
45
162
|
executables: []
|
163
|
+
|
46
164
|
extensions: []
|
165
|
+
|
47
166
|
extra_rdoc_files: []
|
48
|
-
|
167
|
+
|
168
|
+
files:
|
169
|
+
- .coveralls.yml
|
49
170
|
- .gitignore
|
171
|
+
- .rspec
|
172
|
+
- .ruby-version
|
173
|
+
- .travis.yml
|
50
174
|
- Gemfile
|
51
175
|
- LICENSE.txt
|
52
176
|
- README.md
|
53
177
|
- Rakefile
|
54
178
|
- lib/netvisor.rb
|
179
|
+
- lib/netvisor/base.rb
|
180
|
+
- lib/netvisor/configuration.rb
|
181
|
+
- lib/netvisor/request.rb
|
182
|
+
- lib/netvisor/root.rb
|
183
|
+
- lib/netvisor/sales_invoice.rb
|
184
|
+
- lib/netvisor/sales_invoice_line.rb
|
185
|
+
- lib/netvisor/sales_invoice_product_line.rb
|
186
|
+
- lib/netvisor/vat_percentage.rb
|
55
187
|
- lib/netvisor/version.rb
|
56
188
|
- netvisor.gemspec
|
57
|
-
|
58
|
-
|
189
|
+
- spec/netvisor/configuration_spec.rb
|
190
|
+
- spec/netvisor_spec.rb
|
191
|
+
- spec/spec_helper.rb
|
192
|
+
homepage: https://github.com/Eficode/netvisor
|
193
|
+
licenses:
|
59
194
|
- MIT
|
60
|
-
metadata: {}
|
61
195
|
post_install_message:
|
62
196
|
rdoc_options: []
|
63
|
-
|
197
|
+
|
198
|
+
require_paths:
|
64
199
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - "="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
hash: 57
|
206
|
+
segments:
|
207
|
+
- 1
|
208
|
+
- 8
|
209
|
+
- 7
|
210
|
+
version: 1.8.7
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
none: false
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
hash: 3
|
217
|
+
segments:
|
218
|
+
- 0
|
219
|
+
version: "0"
|
75
220
|
requirements: []
|
221
|
+
|
76
222
|
rubyforge_project:
|
77
|
-
rubygems_version:
|
223
|
+
rubygems_version: 1.8.25
|
78
224
|
signing_key:
|
79
|
-
specification_version:
|
225
|
+
specification_version: 3
|
80
226
|
summary: WIP Implementation of Netvisor API in Ruby
|
81
|
-
test_files:
|
82
|
-
|
227
|
+
test_files:
|
228
|
+
- spec/netvisor/configuration_spec.rb
|
229
|
+
- spec/netvisor_spec.rb
|
230
|
+
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: a597e9a3bee83ff51631c20a230fb231795dff56
|
4
|
-
data.tar.gz: 54b1429467b5a7f735e5892c33b5455692e4718d
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 6acbc4f6de4f30ae809e6c8ec301a3f4607ee006be94147cd76574363f49a7b5c89273c4e3a6eefc3bd72b784fd88407b4a813a25020d3005b88fabf5af148de
|
7
|
-
data.tar.gz: 127bc82c65f2208701df6446a2791d9ec5ef6c5773f6f0674fc7f93f652dd1b5a28de8c16293cea9bcb68e1e81a6625999c0c546f02b99789539afb2c4b9b82a
|