invoiced 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/invoiced.rb +3 -3
- data/lib/invoiced/{catalog_item.rb → item.rb} +2 -2
- data/lib/invoiced/version.rb +1 -1
- data/test/invoiced/{catalog_item_test.rb → item_test.rb} +30 -30
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96fee7c8ec29ed8496d56e2ad01040962c4e793e03d8746cd1bb33dc9d455310
|
4
|
+
data.tar.gz: 24c4ac4cf3671312b13da58e7ffb0798041ff50572d06e49ccbab047f2fe7130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a1fbde18532af461b0051de5a9a35beeefa4e6b9826cbbc65d8ce4ac73b91ce6d40d81c7b3d3fd6d68a989c74441cd0ee45d9cd1f8d9f1c7e50095a4666cd1
|
7
|
+
data.tar.gz: 79c75b2a9c9654ecf61a520aaa1e1bc3c2802d189b540238dd4556108c00255e0d88155f2d96200c11a8ddb870b4ee16be2e8fb0cd1b34e6e80597b7661b357d
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ invoiced-ruby
|
|
3
3
|
|
4
4
|
This repository contains the Ruby client library for the [Invoiced](https://invoiced.com) API.
|
5
5
|
|
6
|
-
[![Build Status](https://travis-ci.
|
6
|
+
[![Build Status](https://travis-ci.com/Invoiced/invoiced-ruby.svg?branch=master)](https://travis-ci.com/Invoiced/invoiced-ruby)
|
7
7
|
[![Coverage Status](https://coveralls.io/repos/Invoiced/invoiced-ruby/badge.svg?branch=master&service=github)](https://coveralls.io/github/Invoiced/invoiced-ruby?branch=master)
|
8
8
|
[![Gem Version](https://badge.fury.io/rb/invoiced.svg)](https://badge.fury.io/rb/invoiced)
|
9
9
|
|
@@ -45,10 +45,16 @@ Then, API calls can be made like this:
|
|
45
45
|
invoice = invoiced.Invoice.retrieve("{INVOICE_ID}")
|
46
46
|
|
47
47
|
# mark as paid
|
48
|
-
|
49
|
-
:invoice => invoice.id,
|
48
|
+
payment = invoiced.Payment.create(
|
50
49
|
:amount => invoice.balance,
|
51
|
-
:method => "check"
|
50
|
+
:method => "check",
|
51
|
+
:applied_to => [
|
52
|
+
{
|
53
|
+
:type => "invoice",
|
54
|
+
:invoice => invoice.id,
|
55
|
+
:amount => invoice.balance
|
56
|
+
}
|
57
|
+
])
|
52
58
|
```
|
53
59
|
|
54
60
|
If you want to use the sandbox API instead then you must set the second argument on the client to `true` like this:
|
data/lib/invoiced.rb
CHANGED
@@ -22,7 +22,7 @@ require 'invoiced/payment_source_object'
|
|
22
22
|
require 'invoiced/attachment'
|
23
23
|
require 'invoiced/bank_account'
|
24
24
|
require 'invoiced/card'
|
25
|
-
require 'invoiced/
|
25
|
+
require 'invoiced/item'
|
26
26
|
require 'invoiced/charge'
|
27
27
|
require 'invoiced/contact'
|
28
28
|
require 'invoiced/coupon'
|
@@ -56,7 +56,7 @@ module Invoiced
|
|
56
56
|
ReadTimeout = 80
|
57
57
|
|
58
58
|
attr_reader :api_key, :api_url, :sandbox, :sso_key
|
59
|
-
attr_reader :
|
59
|
+
attr_reader :Item, :Charge, :Coupon, :CreditNote, :Customer, :Estimate, :Event, :File, :Invoice, :Note, :Payment, :Plan, :Refund, :Subscription, :Task, :TaxRate, :Transaction
|
60
60
|
|
61
61
|
def initialize(api_key, sandbox=false, sso_key=false)
|
62
62
|
@api_key = api_key
|
@@ -65,7 +65,7 @@ module Invoiced
|
|
65
65
|
@sso_key = sso_key
|
66
66
|
|
67
67
|
# Object endpoints
|
68
|
-
@
|
68
|
+
@Item = Invoiced::Item.new(self)
|
69
69
|
@Charge = Invoiced::Charge.new(self)
|
70
70
|
@Coupon = Invoiced::Coupon.new(self)
|
71
71
|
@CreditNote = Invoiced::CreditNote.new(self)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Invoiced
|
2
|
-
class
|
2
|
+
class Item < Object
|
3
3
|
include Invoiced::Operations::List
|
4
4
|
include Invoiced::Operations::Create
|
5
5
|
include Invoiced::Operations::Update
|
6
6
|
include Invoiced::Operations::Delete
|
7
7
|
|
8
|
-
OBJECT_NAME = '
|
8
|
+
OBJECT_NAME = 'item'
|
9
9
|
end
|
10
10
|
end
|
data/lib/invoiced/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.expand_path('../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Invoiced
|
4
|
-
class
|
4
|
+
class ItemTest < Test::Unit::TestCase
|
5
5
|
should "return the api endpoint" do
|
6
|
-
|
7
|
-
assert_equal('/
|
6
|
+
item = Item.new(@client, "test")
|
7
|
+
assert_equal('/items/test', item.endpoint())
|
8
8
|
end
|
9
9
|
|
10
|
-
should "create
|
10
|
+
should "create an item" do
|
11
11
|
mockResponse = mock('RestClient::Response')
|
12
12
|
mockResponse.stubs(:code).returns(201)
|
13
13
|
mockResponse.stubs(:body).returns('{"id":"test","name":"Test Item"}')
|
@@ -15,14 +15,14 @@ module Invoiced
|
|
15
15
|
|
16
16
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
17
|
|
18
|
-
|
18
|
+
item = @client.Item.create({:name => "Test Item"})
|
19
19
|
|
20
|
-
assert_instance_of(Invoiced::
|
21
|
-
assert_equal("test",
|
22
|
-
assert_equal('Test Item',
|
20
|
+
assert_instance_of(Invoiced::Item, item)
|
21
|
+
assert_equal("test", item.id)
|
22
|
+
assert_equal('Test Item', item.name)
|
23
23
|
end
|
24
24
|
|
25
|
-
should "retrieve
|
25
|
+
should "retrieve an item" do
|
26
26
|
mockResponse = mock('RestClient::Response')
|
27
27
|
mockResponse.stubs(:code).returns(200)
|
28
28
|
mockResponse.stubs(:body).returns('{"id":"test","name":"Test Item"}')
|
@@ -30,19 +30,19 @@ module Invoiced
|
|
30
30
|
|
31
31
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
32
|
|
33
|
-
|
33
|
+
item = @client.Item.retrieve("test")
|
34
34
|
|
35
|
-
assert_instance_of(Invoiced::
|
36
|
-
assert_equal("test",
|
37
|
-
assert_equal('Test Item',
|
35
|
+
assert_instance_of(Invoiced::Item, item)
|
36
|
+
assert_equal("test", item.id)
|
37
|
+
assert_equal('Test Item', item.name)
|
38
38
|
end
|
39
39
|
|
40
|
-
should "not update
|
41
|
-
|
42
|
-
assert_false(
|
40
|
+
should "not update an item when no params" do
|
41
|
+
item = Item.new(@client, "test")
|
42
|
+
assert_false(item.save)
|
43
43
|
end
|
44
44
|
|
45
|
-
should "update
|
45
|
+
should "update an item" do
|
46
46
|
mockResponse = mock('RestClient::Response')
|
47
47
|
mockResponse.stubs(:code).returns(200)
|
48
48
|
mockResponse.stubs(:body).returns('{"id":"test","closed":true}')
|
@@ -50,32 +50,32 @@ module Invoiced
|
|
50
50
|
|
51
51
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
assert_true(
|
53
|
+
item = Item.new(@client, "test")
|
54
|
+
item.closed = true
|
55
|
+
assert_true(item.save)
|
56
56
|
|
57
|
-
assert_true(
|
57
|
+
assert_true(item.closed)
|
58
58
|
end
|
59
59
|
|
60
|
-
should "list all
|
60
|
+
should "list all items" do
|
61
61
|
mockResponse = mock('RestClient::Response')
|
62
62
|
mockResponse.stubs(:code).returns(200)
|
63
63
|
mockResponse.stubs(:body).returns('[{"id":"test","name":"Test Item"}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/
|
64
|
+
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/items?per_page=25&page=1>; rel="self", <https://api.invoiced.com/items?per_page=25&page=1>; rel="first", <https://api.invoiced.com/items?per_page=25&page=1>; rel="last"')
|
65
65
|
|
66
66
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
67
|
|
68
|
-
|
68
|
+
items, metadata = @client.Item.list
|
69
69
|
|
70
|
-
assert_instance_of(Array,
|
71
|
-
assert_equal(1,
|
72
|
-
assert_equal("test",
|
70
|
+
assert_instance_of(Array, items)
|
71
|
+
assert_equal(1, items.length)
|
72
|
+
assert_equal("test", items[0].id)
|
73
73
|
|
74
74
|
assert_instance_of(Invoiced::List, metadata)
|
75
75
|
assert_equal(15, metadata.total_count)
|
76
76
|
end
|
77
77
|
|
78
|
-
should "delete
|
78
|
+
should "delete an item" do
|
79
79
|
mockResponse = mock('RestClient::Response')
|
80
80
|
mockResponse.stubs(:code).returns(204)
|
81
81
|
mockResponse.stubs(:body).returns('')
|
@@ -83,8 +83,8 @@ module Invoiced
|
|
83
83
|
|
84
84
|
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
85
85
|
|
86
|
-
|
87
|
-
assert_true(
|
86
|
+
item = Item.new(@client, "test")
|
87
|
+
assert_true(item.delete)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
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: 1.
|
4
|
+
version: 1.3.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: 2020-12-
|
11
|
+
date: 2020-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- lib/invoiced/attachment.rb
|
56
56
|
- lib/invoiced/bank_account.rb
|
57
57
|
- lib/invoiced/card.rb
|
58
|
-
- lib/invoiced/catalog_item.rb
|
59
58
|
- lib/invoiced/charge.rb
|
60
59
|
- lib/invoiced/contact.rb
|
61
60
|
- lib/invoiced/coupon.rb
|
@@ -72,6 +71,7 @@ files:
|
|
72
71
|
- lib/invoiced/event.rb
|
73
72
|
- lib/invoiced/file.rb
|
74
73
|
- lib/invoiced/invoice.rb
|
74
|
+
- lib/invoiced/item.rb
|
75
75
|
- lib/invoiced/letter.rb
|
76
76
|
- lib/invoiced/line_item.rb
|
77
77
|
- lib/invoiced/list.rb
|
@@ -94,7 +94,6 @@ files:
|
|
94
94
|
- lib/invoiced/transaction.rb
|
95
95
|
- lib/invoiced/util.rb
|
96
96
|
- lib/invoiced/version.rb
|
97
|
-
- test/invoiced/catalog_item_test.rb
|
98
97
|
- test/invoiced/charge_test.rb
|
99
98
|
- test/invoiced/contact_test.rb
|
100
99
|
- test/invoiced/coupon_test.rb
|
@@ -106,6 +105,7 @@ files:
|
|
106
105
|
- test/invoiced/file_test.rb
|
107
106
|
- test/invoiced/invoice_test.rb
|
108
107
|
- test/invoiced/invoiced_test.rb
|
108
|
+
- test/invoiced/item_test.rb
|
109
109
|
- test/invoiced/line_item_test.rb
|
110
110
|
- test/invoiced/note_test.rb
|
111
111
|
- test/invoiced/object_test.rb
|
@@ -144,7 +144,6 @@ signing_key:
|
|
144
144
|
specification_version: 4
|
145
145
|
summary: Ruby client library for the Invoiced API
|
146
146
|
test_files:
|
147
|
-
- test/invoiced/catalog_item_test.rb
|
148
147
|
- test/invoiced/charge_test.rb
|
149
148
|
- test/invoiced/contact_test.rb
|
150
149
|
- test/invoiced/coupon_test.rb
|
@@ -156,6 +155,7 @@ test_files:
|
|
156
155
|
- test/invoiced/file_test.rb
|
157
156
|
- test/invoiced/invoice_test.rb
|
158
157
|
- test/invoiced/invoiced_test.rb
|
158
|
+
- test/invoiced/item_test.rb
|
159
159
|
- test/invoiced/line_item_test.rb
|
160
160
|
- test/invoiced/note_test.rb
|
161
161
|
- test/invoiced/object_test.rb
|