invoiced 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/invoiced.rb +5 -3
- data/lib/invoiced/event.rb +5 -0
- data/lib/invoiced/object.rb +1 -1
- data/lib/invoiced/version.rb +1 -1
- data/test/invoiced/event_test.rb +29 -0
- data/test/invoiced/invoiced_test.rb +20 -20
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35c409ed2ae535f3c067050c264aeff63a853721
|
4
|
+
data.tar.gz: 3aba150984f9a4f676ff6a64db1165ed0b1a5c7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a6ed8b5a0082fedbbdb8fa7997b6fbe9d00b5f0d66f34f83de38a5733ad5792134a95ea3f57cb842de79773b1a94c7bc1d360ee5c7a3bc81a2bf38396a8a3a5
|
7
|
+
data.tar.gz: 8b4400f97f936d70f815bae2d79baf6692bf5916ee06481f3587847448ca2e7684a023b506852a4bd679ff6e0224eadf4e85d9b50da893b1870d476c47499291
|
data/lib/invoiced.rb
CHANGED
@@ -21,11 +21,12 @@ require 'invoiced/attachment'
|
|
21
21
|
require 'invoiced/contact'
|
22
22
|
require 'invoiced/customer'
|
23
23
|
require 'invoiced/email'
|
24
|
+
require 'invoiced/event'
|
24
25
|
require 'invoiced/file'
|
25
26
|
require 'invoiced/invoice'
|
26
27
|
require 'invoiced/line_item'
|
27
|
-
require 'invoiced/transaction'
|
28
28
|
require 'invoiced/subscription'
|
29
|
+
require 'invoiced/transaction'
|
29
30
|
|
30
31
|
module Invoiced
|
31
32
|
class Client
|
@@ -33,7 +34,7 @@ module Invoiced
|
|
33
34
|
ApiBaseSandbox = 'https://api.sandbox.invoiced.com'
|
34
35
|
|
35
36
|
attr_reader :api_key, :api_url, :sandbox
|
36
|
-
attr_reader :Customer, :File, :Invoice, :
|
37
|
+
attr_reader :Customer, :Event, :File, :Invoice, :Subscription, :Transaction
|
37
38
|
|
38
39
|
def initialize(api_key, sandbox=false)
|
39
40
|
@api_key = api_key
|
@@ -42,10 +43,11 @@ module Invoiced
|
|
42
43
|
|
43
44
|
# Object endpoints
|
44
45
|
@Customer = Invoiced::Customer.new(self)
|
46
|
+
@Event = Invoiced::Event.new(self)
|
45
47
|
@File = Invoiced::File.new(self)
|
46
48
|
@Invoice = Invoiced::Invoice.new(self)
|
47
|
-
@Transaction = Invoiced::Transaction.new(self)
|
48
49
|
@Subscription = Invoiced::Subscription.new(self)
|
50
|
+
@Transaction = Invoiced::Transaction.new(self)
|
49
51
|
end
|
50
52
|
|
51
53
|
def request(method, endpoint, params={})
|
data/lib/invoiced/object.rb
CHANGED
data/lib/invoiced/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class EventTest < Test::Unit::TestCase
|
5
|
+
should "return the api endpoint" do
|
6
|
+
event = Event.new(@client, 123)
|
7
|
+
assert_equal('/events/123', event.endpoint())
|
8
|
+
end
|
9
|
+
|
10
|
+
should "list all events" do
|
11
|
+
mockResponse = mock('RestClient::Response')
|
12
|
+
mockResponse.stubs(:code).returns(200)
|
13
|
+
mockResponse.stubs(:body).returns('[{"id":123,"type":"customer.created"}]')
|
14
|
+
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/events?per_page=25&page=1>; rel="self", <https://api.invoiced.com/events?per_page=25&page=1>; rel="first", <https://api.invoiced.com/events?per_page=25&page=1>; rel="last"')
|
15
|
+
|
16
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
+
|
18
|
+
events, metadata = @client.Event.list
|
19
|
+
|
20
|
+
assert_instance_of(Array, events)
|
21
|
+
assert_equal(1, events.length)
|
22
|
+
assert_instance_of(Invoiced::Event, events[0])
|
23
|
+
assert_equal(123, events[0].id)
|
24
|
+
|
25
|
+
assert_instance_of(Invoiced::List, metadata)
|
26
|
+
assert_equal(15, metadata.total_count)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -24,16 +24,16 @@ module Invoiced
|
|
24
24
|
mockResponse.stubs(:headers).returns(:Header => "test")
|
25
25
|
|
26
26
|
# not used
|
27
|
-
expectedParameters = {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
27
|
+
# expectedParameters = {
|
28
|
+
# :method => "GET",
|
29
|
+
# :url => "https://api.invoiced.com/invoices?test=property&filter[levels]=work",
|
30
|
+
# :headers => {
|
31
|
+
# :authorization => "Basic dGVzdDo=",
|
32
|
+
# :content_type => "application/json",
|
33
|
+
# :user_agent => "Invoiced Ruby/#{Invoiced::VERSION}"
|
34
|
+
# },
|
35
|
+
# :payload => nil
|
36
|
+
# }
|
37
37
|
|
38
38
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
39
39
|
|
@@ -64,16 +64,16 @@ module Invoiced
|
|
64
64
|
mockResponse.stubs(:headers).returns(:Header => "test")
|
65
65
|
|
66
66
|
# not used
|
67
|
-
expectedParameters = {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
67
|
+
# expectedParameters = {
|
68
|
+
# :method => "POST",
|
69
|
+
# :url => "https://api.invoiced.com/invoices?test=property&filter[levels]=work",
|
70
|
+
# :headers => {
|
71
|
+
# :authorization => "Basic dGVzdDo=",
|
72
|
+
# :content_type => "application/json",
|
73
|
+
# :user_agent => "Invoiced Ruby/#{Invoiced::VERSION}"
|
74
|
+
# },
|
75
|
+
# :payload => '{"test":"property"}'
|
76
|
+
# }
|
77
77
|
|
78
78
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
79
79
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoiced
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared King
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/invoiced/error/authentication_error.rb
|
132
132
|
- lib/invoiced/error/error_base.rb
|
133
133
|
- lib/invoiced/error/invalid_request.rb
|
134
|
+
- lib/invoiced/event.rb
|
134
135
|
- lib/invoiced/file.rb
|
135
136
|
- lib/invoiced/invoice.rb
|
136
137
|
- lib/invoiced/line_item.rb
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- test/invoiced/contact_test.rb
|
148
149
|
- test/invoiced/customer_test.rb
|
149
150
|
- test/invoiced/error_test.rb
|
151
|
+
- test/invoiced/event_test.rb
|
150
152
|
- test/invoiced/file_test.rb
|
151
153
|
- test/invoiced/invoice_test.rb
|
152
154
|
- test/invoiced/invoiced_test.rb
|
@@ -184,6 +186,7 @@ test_files:
|
|
184
186
|
- test/invoiced/contact_test.rb
|
185
187
|
- test/invoiced/customer_test.rb
|
186
188
|
- test/invoiced/error_test.rb
|
189
|
+
- test/invoiced/event_test.rb
|
187
190
|
- test/invoiced/file_test.rb
|
188
191
|
- test/invoiced/invoice_test.rb
|
189
192
|
- test/invoiced/invoiced_test.rb
|