sendregning 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -21
- data/README.md +47 -0
- data/lib/sendregning.rb +2 -1
- data/lib/sendregning/client.rb +103 -103
- data/lib/sendregning/invoice.rb +133 -133
- data/lib/sendregning/line.rb +51 -51
- data/lib/sendregning/version.rb +5 -0
- data/sendregning.gemspec +20 -57
- metadata +63 -97
- data/.document +0 -5
- data/README.rdoc +0 -47
- data/Rakefile +0 -56
- data/VERSION +0 -1
- data/test/helper.rb +0 -10
- data/test/test_sendregning.rb +0 -7
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c1f7147849c41ef8793153b66a1f58da22c94f1
|
4
|
+
data.tar.gz: d57d452f433f69185e4358b7b2b37919b51e60ba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60e9a23fa2e5494d5238938aa0e631e19729a74cedfbbbb2aa865ae8f12f98a8a6bac61ec1b9540db764c68aa122c2f29d8cd79ac69f87a11e852793c6caa26e
|
7
|
+
data.tar.gz: b21f77225dd948ad1514af54317e737586a2c420e6a49682f196fc4015c1c72cc321984f7beb8e39f61bb1feb34acdd79f14e3634cfb08aa0bdb17999b34321c
|
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Sendregning
|
2
|
+
|
3
|
+
Ruby client for the SendRegning Web Service.
|
4
|
+
|
5
|
+
## Getting started
|
6
|
+
|
7
|
+
Install with RubyGems:
|
8
|
+
|
9
|
+
gem install sendregning
|
10
|
+
|
11
|
+
Now start sending invoices:
|
12
|
+
|
13
|
+
# Create a new client
|
14
|
+
client = Sendregning::Client.new('my@email.com', 'myawesomepassword')
|
15
|
+
|
16
|
+
# Start a new email invoice
|
17
|
+
invoice = client.new_invoice(
|
18
|
+
name: 'My Client',
|
19
|
+
zip: '0123',
|
20
|
+
city: 'Oslo',
|
21
|
+
shipment: :email,
|
22
|
+
emailaddresses: 'my@email.com'
|
23
|
+
)
|
24
|
+
|
25
|
+
# Add an item
|
26
|
+
invoice.add_line qty: 1, desc: 'Bananaphone', unitPrice: '500,00'
|
27
|
+
|
28
|
+
# Send it away!
|
29
|
+
invoice.send!
|
30
|
+
|
31
|
+
# Get the invoice number for future reference
|
32
|
+
id = invoice.invoiceNo
|
33
|
+
|
34
|
+
Let's check how we're doing!
|
35
|
+
|
36
|
+
invoice = client.find_invoice(id)
|
37
|
+
invoice.paid? # => true
|
38
|
+
|
39
|
+
Pass `test: true` to the constructor to use the test API
|
40
|
+
|
41
|
+
# Create a new client
|
42
|
+
client = Sendregning::Client.new('my@email.com', 'myawesomepassword', test: true)
|
43
|
+
|
44
|
+
|
45
|
+
## Copyright
|
46
|
+
|
47
|
+
Copyright (c) 2010 Inge Jørgensen. See LICENSE for details.
|
data/lib/sendregning.rb
CHANGED
data/lib/sendregning/client.rb
CHANGED
@@ -2,117 +2,117 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Sendregning
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
# Client for the SendRegning Web Services.
|
6
|
+
#
|
7
|
+
# Usage example:
|
8
|
+
#
|
9
|
+
# client = SendRegning::Client.new(my_username, my_password)
|
10
|
+
|
11
|
+
class Client
|
12
|
+
include HTTParty
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
base_uri 'https://www.sendregning.no'
|
15
|
+
format :xml
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def initialize(username, password, options={})
|
18
|
+
@auth = {:username => username, :password => password}
|
19
|
+
@test = true if options[:test]
|
20
|
+
end
|
21
|
+
|
22
|
+
public
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
# Performs a GET request
|
25
|
+
def get(query={})
|
26
|
+
self.class.get('/ws/butler.do', query_options(query))
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
29
|
+
# Performs a POST request
|
30
|
+
def post(query=nil)
|
31
|
+
self.class.post('/ws/butler.do', query_options(query))
|
32
|
+
end
|
33
|
+
|
34
|
+
# Performs a POST request with an XML payload
|
35
|
+
def post_xml(xml, body={})
|
36
|
+
# Prepare the request
|
37
|
+
url = URI.parse("#{self.class.base_uri}/ws/butler.do")
|
38
|
+
body[:xml] = UploadIO.new(StringIO.new(xml), 'text/xml', 'request.xml')
|
39
|
+
body[:test] = true if @test
|
40
|
+
request = Net::HTTP::Post::Multipart.new(url.path, body)
|
41
|
+
request.basic_auth @auth[:username], @auth[:password]
|
42
|
+
|
43
|
+
# Perform request
|
44
|
+
http = Net::HTTP.new(url.host, url.port)
|
45
|
+
http.use_ssl = true
|
46
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
47
|
+
res = http.start{|http| http.request(request)}
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
49
|
+
# Parse the response
|
50
|
+
response = Response.new(res, self.class.parser.call(res.body, :xml))
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns a list of recipients
|
54
|
+
def recipients
|
55
|
+
response = get(:action => 'select', :type => 'recipient')
|
56
|
+
response['recipients']['recipient']
|
57
|
+
end
|
58
|
+
|
59
|
+
# Instances a new invoice
|
60
|
+
def new_invoice(attributes={})
|
61
|
+
Sendregning::Invoice.new(attributes.merge({:client => self}))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Sends an invoice
|
65
|
+
def send_invoice(invoice)
|
66
|
+
response = post_xml(invoice.to_xml, {:action => 'send', :type => 'invoice'})
|
67
|
+
parse_invoice(response['invoices']['invoice'], invoice)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Finds an invoice by invoice number
|
71
|
+
def find_invoice(invoice_id)
|
72
|
+
builder = Builder::XmlMarkup.new(:indent=>2)
|
73
|
+
builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
74
|
+
request_xml = builder.select do |select|
|
75
|
+
select.invoiceNumbers do |numbers|
|
76
|
+
numbers.invoiceNumber invoice_id
|
77
|
+
end
|
78
|
+
end
|
79
|
+
response = post_xml(request_xml, {:action => 'select', :type => 'invoice'})
|
80
|
+
parse_invoice(response['invoices']['invoice']) rescue nil
|
81
|
+
end
|
82
|
+
|
83
83
|
|
84
|
-
|
84
|
+
protected
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
86
|
+
def flatten_xml_hash(hash)
|
87
|
+
new_hash = {}
|
88
|
+
hash.each do |key, value|
|
89
|
+
new_hash[key] = "#{value}"
|
90
|
+
end
|
91
|
+
new_hash
|
92
|
+
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
94
|
+
def parse_invoice(response, invoice=Sendregning::Invoice.new)
|
95
|
+
attributes = response.dup
|
96
|
+
if attributes['optional']
|
97
|
+
attributes = attributes.merge(attributes['optional'])
|
98
|
+
attributes.delete('optional')
|
99
|
+
end
|
100
|
+
if attributes['shipment']
|
101
|
+
attributes = attributes.merge(attributes['shipment'])
|
102
|
+
attributes.delete('shipment')
|
103
|
+
end
|
104
|
+
lines = attributes['lines']['line']; attributes.delete('lines')
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
invoice.update(flatten_xml_hash(attributes))
|
107
|
+
invoice.lines = lines.map{|l| Sendregning::Line.new(flatten_xml_hash(l))}
|
108
|
+
invoice
|
109
|
+
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
# Prepares options for a request
|
112
|
+
def query_options(query={})
|
113
|
+
query[:test] = 'true' if @test
|
114
|
+
{:basic_auth => @auth, :query => query}
|
115
|
+
end
|
116
116
|
|
117
|
-
|
118
|
-
end
|
117
|
+
end
|
118
|
+
end
|
data/lib/sendregning/invoice.rb
CHANGED
@@ -1,147 +1,147 @@
|
|
1
1
|
module Sendregning
|
2
2
|
|
3
|
-
|
3
|
+
class Invoice
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
OPTIONAL_ATTRIBUTES = [
|
6
|
+
# Request
|
7
|
+
:invoiceType, :creditedId, :orderNo, :invoiceDate, :orderNo,
|
8
|
+
:invoiceDate, :dueDate, :orderDate, :recipientNo, :address1, :address2,
|
9
|
+
:country, :email, :ourRef, :yourRef, :comment, :invoiceText, :printDunningInfo,
|
10
|
+
:itemTaxInclude,
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# Response
|
13
|
+
:tax, :dueDate, :dunningFee, :invoiceNo, :total, :accountNo, :orgNrSuffix, :kid, :orgNo, :interestRate, :state
|
14
|
+
]
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
SHIPMENT_ATTRIBUTES = [
|
17
|
+
:shipment, :emailaddresses, :copyaddresses
|
18
|
+
]
|
19
|
+
|
20
|
+
SHIPMENT_MODES = {
|
21
|
+
:paper => 'PAPER',
|
22
|
+
:email => 'EMAIL',
|
23
|
+
:paper_and_email => 'PAPER_AND_EMAIL'
|
24
|
+
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
attr_accessor :client
|
27
|
+
attr_accessor :name, :zip, :city
|
28
|
+
attr_accessor :optional, :shipment
|
29
|
+
attr_accessor :lines
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
def initialize(attributes={})
|
32
|
+
self.update(attributes)
|
33
|
+
@lines = []
|
34
|
+
end
|
35
|
+
|
36
|
+
def update(attributes={})
|
37
|
+
@client = attributes[:client] if attributes[:client]
|
38
|
+
@name = attributes[:name] if attributes[:name]
|
39
|
+
@zip = attributes[:zip] if attributes[:zip]
|
40
|
+
@city = attributes[:city] if attributes[:city]
|
41
|
+
self.optional = attributes
|
42
|
+
self.shipment = attributes
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
45
|
+
def add_line(line)
|
46
|
+
line = Sendregning::Line.new(line) unless line.kind_of?(Sendregning::Line)
|
47
|
+
@lines << line
|
48
|
+
line
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sends an invoice
|
52
|
+
def send!
|
53
|
+
self.client.send_invoice(self)
|
54
|
+
end
|
55
|
+
|
56
|
+
def paid?
|
57
|
+
state == 'paid'
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
60
|
+
# Renders invoice to XML
|
61
|
+
def to_xml(options={})
|
62
|
+
if options[:builder]
|
63
|
+
xml = options[:builder]
|
64
|
+
else
|
65
|
+
xml = Builder::XmlMarkup.new(:indent=>2)
|
66
|
+
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
67
|
+
end
|
68
|
+
xml.invoices do |invoices|
|
69
|
+
invoices.invoice do |invoice|
|
70
|
+
invoice.name @name
|
71
|
+
invoice.zip @zip
|
72
|
+
invoice.city @city
|
73
|
+
|
74
|
+
# Lines
|
75
|
+
if @lines.length > 0
|
76
|
+
invoice.lines do |line_builder|
|
77
|
+
@lines.each{|l| l.to_xml(:builder => line_builder)}
|
78
|
+
end
|
79
|
+
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
81
|
+
# Optional attributes
|
82
|
+
if @optional.length > 0
|
83
|
+
invoice.optional do |optional|
|
84
|
+
@optional.each do |key, value|
|
85
|
+
key = key.to_sym
|
86
|
+
if value.kind_of?(Date) || value.kind_of?(Time)
|
87
|
+
value = value.strftime("%d.%m.%y")
|
88
|
+
end
|
89
|
+
optional.tag! key, value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
# Shipment attributes
|
95
|
+
if @shipment.length > 0
|
96
|
+
invoice.shipment do |shipment|
|
97
|
+
shipment_mode = (@shipment[:shipment] || :paper).to_sym
|
98
|
+
raise 'Invalid shipment mode!' unless SHIPMENT_MODES.keys.include?(shipment_mode)
|
99
|
+
shipment_mode = SHIPMENT_MODES[shipment_mode]
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
101
|
+
shipment.text! shipment_mode
|
102
|
+
@shipment.each do |key, values|
|
103
|
+
key = key.to_sym
|
104
|
+
unless key == :shipment
|
105
|
+
values = [values] unless values.kind_of?(Enumerable)
|
106
|
+
shipment.tag! key do |emails|
|
107
|
+
values.each{|v| emails.email v}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
117
|
+
protected
|
118
|
+
|
119
|
+
def optional=(attributes)
|
120
|
+
@optional ||= {}
|
121
|
+
attributes.each do |key, value|
|
122
|
+
@optional[key.to_sym] = value if OPTIONAL_ATTRIBUTES.include?(key.to_sym)
|
123
|
+
end
|
124
|
+
@optional
|
125
|
+
end
|
126
|
+
|
127
|
+
def shipment=(attributes)
|
128
|
+
@shipment ||= {}
|
129
|
+
attributes.each do |key, value|
|
130
|
+
@shipment[key.to_sym] = value if SHIPMENT_ATTRIBUTES.include?(key.to_sym)
|
131
|
+
end
|
132
|
+
@shipment
|
133
|
+
end
|
134
|
+
|
135
|
+
def method_missing(method, *args)
|
136
|
+
if OPTIONAL_ATTRIBUTES.include?(method)
|
137
|
+
@optional[method]
|
138
|
+
elsif SHIPPING_ATTRIBUTES.include?(method)
|
139
|
+
@shipping[method]
|
140
|
+
else
|
141
|
+
super
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
146
|
|
147
|
-
end
|
147
|
+
end
|
data/lib/sendregning/line.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
module Sendregning
|
2
2
|
|
3
|
-
|
3
|
+
class Line
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
# Quantity, as decimal. Example: '7,5'
|
6
|
+
attr_accessor :qty
|
7
|
+
|
8
|
+
# Product code. String, max length: 9
|
9
|
+
attr_accessor :prodCode
|
10
|
+
|
11
|
+
# Description. String, max length: 75
|
12
|
+
attr_accessor :desc
|
13
|
+
|
14
|
+
# Price per unit in decimal. Example: '250,00'
|
15
|
+
attr_accessor :unitPrice
|
16
|
+
|
17
|
+
# Discount in percentage as decimal. Optional, defaults to 0
|
18
|
+
attr_accessor :discount
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
# Tax rate. Valid rates are: '0', '8', '13' and '25'. Default: '25'
|
21
|
+
attr_accessor :tax
|
22
|
+
|
23
|
+
attr_accessor :itemNo, :lineTaxAmount, :lineTotal
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
25
|
+
def initialize(new_attributes={})
|
26
|
+
self.attributes = new_attributes
|
27
|
+
end
|
28
|
+
|
29
|
+
# Renders line to XML
|
30
|
+
def to_xml(options={})
|
31
|
+
if options[:builder]
|
32
|
+
xml = options[:builder]
|
33
|
+
else
|
34
|
+
xml = Builder::XmlMarkup.new(:indent=>2)
|
35
|
+
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
36
|
+
end
|
37
|
+
xml.line do |line|
|
38
|
+
line.qty self.qty if @qty
|
39
|
+
line.prodCode self.prodCode if @prodCode
|
40
|
+
line.desc self.desc if @desc
|
41
|
+
line.unitPrice self.unitPrice if @unitPrice
|
42
|
+
line.discount self.discount if @discount
|
43
|
+
line.tax self.tax if @tax
|
44
|
+
end
|
45
|
+
end
|
46
46
|
|
47
|
-
|
47
|
+
protected
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
def attributes=(attributes={})
|
50
|
+
attributes.each do |key, value|
|
51
|
+
set_method = "#{key.to_s}=".to_sym
|
52
|
+
self.send(set_method, value) if self.respond_to?(set_method)
|
53
|
+
end
|
54
|
+
attributes
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/sendregning.gemspec
CHANGED
@@ -1,63 +1,26 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "sendregning/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
7
|
+
s.name = 'sendregning'
|
8
|
+
s.version = Sendregning::VERSION
|
9
|
+
s.date = '2014-03-05'
|
10
|
+
s.summary = "Ruby client for the SendRegning Web Service"
|
11
|
+
s.description = "Ruby client for the SendRegning Web Service"
|
12
|
+
s.authors = ["Inge Jørgensen"]
|
13
|
+
s.email = 'inge@manualdesign.no'
|
14
|
+
s.homepage = 'http://github.com/elektronaut/sendregning'
|
15
|
+
s.license = 'MIT'
|
16
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
9
17
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.description = %q{Ruby client for the SendRegning Web Service}
|
14
|
-
s.email = %q{inge@manualdesign.no}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/sendregning.rb",
|
27
|
-
"lib/sendregning/client.rb",
|
28
|
-
"lib/sendregning/invoice.rb",
|
29
|
-
"lib/sendregning/line.rb",
|
30
|
-
"sendregning.gemspec",
|
31
|
-
"test/helper.rb",
|
32
|
-
"test/test_sendregning.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/elektronaut/sendregning}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
36
21
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.7}
|
38
|
-
s.summary = %q{Ruby client for the SendRegning Web Service}
|
39
|
-
s.test_files = [
|
40
|
-
"test/helper.rb",
|
41
|
-
"test/test_sendregning.rb"
|
42
|
-
]
|
43
|
-
|
44
|
-
if s.respond_to? :specification_version then
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
47
22
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
s.add_runtime_dependency(%q<multipart-post>, [">= 1.0.1"])
|
52
|
-
else
|
53
|
-
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
54
|
-
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
55
|
-
s.add_dependency(%q<multipart-post>, [">= 1.0.1"])
|
56
|
-
end
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
59
|
-
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
60
|
-
s.add_dependency(%q<multipart-post>, [">= 1.0.1"])
|
61
|
-
end
|
23
|
+
s.add_runtime_dependency 'httparty', '0.6.1'
|
24
|
+
s.add_runtime_dependency 'builder', '~> 2.1'
|
25
|
+
s.add_runtime_dependency 'multipart-post', '~> 1.0'
|
62
26
|
end
|
63
|
-
|
metadata
CHANGED
@@ -1,128 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendregning
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 2
|
10
|
-
version: 0.1.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Inge Jørgensen
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: httparty
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 6
|
33
|
-
- 1
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
34
19
|
version: 0.6.1
|
35
20
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: builder
|
39
21
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: builder
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
51
34
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: multipart-post
|
55
35
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multipart-post
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
67
48
|
type: :runtime
|
68
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
69
55
|
description: Ruby client for the SendRegning Web Service
|
70
56
|
email: inge@manualdesign.no
|
71
57
|
executables: []
|
72
|
-
|
73
58
|
extensions: []
|
74
|
-
|
75
|
-
|
76
|
-
-
|
77
|
-
- README.rdoc
|
78
|
-
files:
|
79
|
-
- .document
|
80
|
-
- .gitignore
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
81
62
|
- LICENSE
|
82
|
-
- README.
|
83
|
-
- Rakefile
|
84
|
-
- VERSION
|
63
|
+
- README.md
|
85
64
|
- lib/sendregning.rb
|
86
65
|
- lib/sendregning/client.rb
|
87
66
|
- lib/sendregning/invoice.rb
|
88
67
|
- lib/sendregning/line.rb
|
68
|
+
- lib/sendregning/version.rb
|
89
69
|
- sendregning.gemspec
|
90
|
-
- test/helper.rb
|
91
|
-
- test/test_sendregning.rb
|
92
|
-
has_rdoc: true
|
93
70
|
homepage: http://github.com/elektronaut/sendregning
|
94
|
-
licenses:
|
95
|
-
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
96
74
|
post_install_message:
|
97
|
-
rdoc_options:
|
98
|
-
|
99
|
-
require_paths:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
100
77
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
|
103
|
-
requirements:
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
104
80
|
- - ">="
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
version: "0"
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
|
-
requirements:
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.7
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
113
85
|
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
119
88
|
requirements: []
|
120
|
-
|
121
89
|
rubyforge_project:
|
122
|
-
rubygems_version:
|
90
|
+
rubygems_version: 2.2.0
|
123
91
|
signing_key:
|
124
|
-
specification_version:
|
92
|
+
specification_version: 4
|
125
93
|
summary: Ruby client for the SendRegning Web Service
|
126
|
-
test_files:
|
127
|
-
- test/helper.rb
|
128
|
-
- test/test_sendregning.rb
|
94
|
+
test_files: []
|
data/.document
DELETED
data/README.rdoc
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
= Sendregning
|
2
|
-
|
3
|
-
Ruby client for the SendRegning Web Service.
|
4
|
-
|
5
|
-
== Getting started
|
6
|
-
|
7
|
-
Install with RubyGems:
|
8
|
-
|
9
|
-
$ gem install sendregning
|
10
|
-
|
11
|
-
Now start sending invoices:
|
12
|
-
|
13
|
-
# Create a new client
|
14
|
-
client = Sendregning::Client.new('my@email.com', 'myawesomepassword')
|
15
|
-
|
16
|
-
# Start a new email invoice
|
17
|
-
invoice = client.new_invoice(
|
18
|
-
:name => 'My Client',
|
19
|
-
:zip => '0123',
|
20
|
-
:city => 'Oslo',
|
21
|
-
:shipment => :email,
|
22
|
-
:emailaddresses => 'my@email.com'
|
23
|
-
)
|
24
|
-
|
25
|
-
# Add an item
|
26
|
-
invoice.add_line :qty => 1, :desc => 'Bananaphone', :unitPrice => '500,00'
|
27
|
-
|
28
|
-
# Send it away!
|
29
|
-
invoice.send!
|
30
|
-
|
31
|
-
# Get the invoice number for future reference
|
32
|
-
id = invoice.invoiceNo
|
33
|
-
|
34
|
-
Let's check how we're doing!
|
35
|
-
|
36
|
-
invoice = client.find_invoice(id)
|
37
|
-
invoice.paid? # => true
|
38
|
-
|
39
|
-
Pass :test => true to the constructor to use the test API
|
40
|
-
|
41
|
-
# Create a new client
|
42
|
-
client = Sendregning::Client.new('my@email.com', 'myawesomepassword', :test => true)
|
43
|
-
|
44
|
-
|
45
|
-
== Copyright
|
46
|
-
|
47
|
-
Copyright (c) 2010 Inge Jørgensen. See LICENSE for details.
|
data/Rakefile
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "sendregning"
|
8
|
-
gem.summary = "Ruby client for the SendRegning Web Service"
|
9
|
-
gem.description = "Ruby client for the SendRegning Web Service"
|
10
|
-
gem.email = "inge@manualdesign.no"
|
11
|
-
gem.homepage = "http://github.com/elektronaut/sendregning"
|
12
|
-
gem.authors = ["Inge Jørgensen"]
|
13
|
-
gem.add_dependency "httparty", ">= 0.6.1"
|
14
|
-
gem.add_dependency "builder", ">= 2.1.2"
|
15
|
-
gem.add_dependency "multipart-post", ">= 1.0.1"
|
16
|
-
#gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'rake/testtask'
|
25
|
-
Rake::TestTask.new(:test) do |test|
|
26
|
-
test.libs << 'lib' << 'test'
|
27
|
-
test.pattern = 'test/**/test_*.rb'
|
28
|
-
test.verbose = true
|
29
|
-
end
|
30
|
-
|
31
|
-
begin
|
32
|
-
require 'rcov/rcovtask'
|
33
|
-
Rcov::RcovTask.new do |test|
|
34
|
-
test.libs << 'test'
|
35
|
-
test.pattern = 'test/**/test_*.rb'
|
36
|
-
test.verbose = true
|
37
|
-
end
|
38
|
-
rescue LoadError
|
39
|
-
task :rcov do
|
40
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
task :test => :check_dependencies
|
45
|
-
|
46
|
-
task :default => :test
|
47
|
-
|
48
|
-
require 'rake/rdoctask'
|
49
|
-
Rake::RDocTask.new do |rdoc|
|
50
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
|
-
|
52
|
-
rdoc.rdoc_dir = 'rdoc'
|
53
|
-
rdoc.title = "sendregning #{version}"
|
54
|
-
rdoc.rdoc_files.include('README*')
|
55
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|
data/test/helper.rb
DELETED