invoiced 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e1807afacc160361d8d7b3014164edb507e3970
4
- data.tar.gz: c806be29c391920e499ed18c941f5d740cfa4b45
3
+ metadata.gz: d9ab812bcc11b135cd567621a8388872e4794d41
4
+ data.tar.gz: ea415b98ad24754e621c1f81a08d15eb6de0c358
5
5
  SHA512:
6
- metadata.gz: 2dd95aa7ee089d9a7da05dd054be8ea58c81be724fb3d6309e8a6b49cf81e35b3abb0151e71462b626cb88e7754c2120429bf2d0bbdc9d182178e0a0c1237f7b
7
- data.tar.gz: a381dffbc857778b616b71c5beb950e6d716106765b4bbd4d235681119435858fca7fe110dbd55fa7961e03ff5293177c537a1215011c1d9488a789cfa56e007
6
+ metadata.gz: 921af214c15490031e38ce6bc4bf505b35f156c2e52fe6baa3f480b8855d010aea4f023e50f4fde4f3871d9b60444c310304544f35f29cda01f45aaa1e184adc
7
+ data.tar.gz: cba482dc00f4be0eae7ba4edb8b8a2d122fcf6cef30e1c63221154104fb1e05101f77073b47d4713d0117e1289dd7416671fc37ab4b7009f2ddbbea0953e6a2c
@@ -4,5 +4,32 @@ module Invoiced
4
4
  include Invoiced::Operations::Create
5
5
  include Invoiced::Operations::Update
6
6
  include Invoiced::Operations::Delete
7
+
8
+ def send_statement(opts={})
9
+ response = @client.request(:post, "#{@endpoint}/emails", opts)
10
+
11
+ # build email objects
12
+ email = Email.new(@client)
13
+ Util.build_objects(email, response[:body])
14
+ end
15
+
16
+ def balance
17
+ response = @client.request(:get, "#{@endpoint}/balance")
18
+
19
+ response[:body]
20
+ end
21
+
22
+ def subscriptions(opts={})
23
+ response = @client.request(:get, "#{@endpoint}/subscriptions", opts)
24
+
25
+ # build objects
26
+ subscription = Subscription.new(@client)
27
+ subscriptions = Util.build_objects(subscription, response[:body])
28
+
29
+ # store the metadata from the list operation
30
+ metadata = Invoiced::List.new(response[:headers][:link], response[:headers][:x_total_count])
31
+
32
+ return subscriptions, metadata
33
+ end
7
34
  end
8
35
  end
@@ -0,0 +1,4 @@
1
+ module Invoiced
2
+ class Email < Object
3
+ end
4
+ end
@@ -4,5 +4,22 @@ module Invoiced
4
4
  include Invoiced::Operations::Create
5
5
  include Invoiced::Operations::Update
6
6
  include Invoiced::Operations::Delete
7
+
8
+ def send(opts={})
9
+ response = @client.request(:post, "#{@endpoint}/emails", opts)
10
+
11
+ # build email objects
12
+ email = Email.new(@client)
13
+ Util.build_objects(email, response[:body])
14
+ end
15
+
16
+ def pay
17
+ response = @client.request(:post, "#{@endpoint}/pay")
18
+
19
+ # update the local values with the response
20
+ @values = response[:body].dup.merge({:id => self.id})
21
+
22
+ return response[:code] == 200
23
+ end
7
24
  end
8
25
  end
@@ -4,5 +4,19 @@ module Invoiced
4
4
  include Invoiced::Operations::Create
5
5
  include Invoiced::Operations::Update
6
6
  include Invoiced::Operations::Delete
7
+
8
+ def send(opts={})
9
+ response = @client.request(:post, "#{@endpoint}/emails", opts)
10
+
11
+ # build email objects
12
+ email = Email.new(@client)
13
+ Util.build_objects(email, response[:body])
14
+ end
15
+
16
+ def refund(opts={})
17
+ response = @client.request(:post, "#{@endpoint}/refunds", opts)
18
+
19
+ Util.convert_to_object(self, response[:body])
20
+ end
7
21
  end
8
22
  end
@@ -1,3 +1,3 @@
1
1
  module Invoiced
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
data/lib/invoiced.rb CHANGED
@@ -17,6 +17,7 @@ require 'invoiced/operations/update'
17
17
 
18
18
  require 'invoiced/object'
19
19
  require 'invoiced/customer'
20
+ require 'invoiced/email'
20
21
  require 'invoiced/invoice'
21
22
  require 'invoiced/transaction'
22
23
  require 'invoiced/plan'
@@ -137,7 +138,7 @@ module Invoiced
137
138
  end
138
139
 
139
140
  def api_error(error, response)
140
- raise ApiError.new("Invoiced API Error #{code} - #{body}", response.code, error)
141
+ raise ApiError.new(error["message"], response.code, error)
141
142
  end
142
143
 
143
144
  def general_api_error(code, body)
@@ -20,6 +20,20 @@ module Invoiced
20
20
  assert_true(customer.save)
21
21
  end
22
22
 
23
+ should "send an account statement" do
24
+ customer = Customer.new(@client, 1234)
25
+ emails = customer.send_statement
26
+ end
27
+
28
+ should "retrieve a customer's balance" do
29
+ customer = Customer.new(@client, 1234)
30
+ balance = customer.balance
31
+ end
32
+
33
+ should "list all of the customer's subscriptions" do
34
+ @client.Customer.subscriptions
35
+ end
36
+
23
37
  should "delete a customer" do
24
38
  customer = Customer.new(@client, 1234)
25
39
  assert_true(customer.delete)
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class InvoiceTest < Test::Unit::TestCase
5
+ should "create an invoice" do
6
+ invoice = @client.Invoice.create({:customer => 123})
7
+ end
8
+
9
+ should "list all invoices" do
10
+ @client.Invoice.list
11
+ end
12
+
13
+ should "retrieve an invoice" do
14
+ invoice = @client.Invoice.retrieve(1234)
15
+ end
16
+
17
+ should "update an invoice" do
18
+ invoice = Invoice.new(@client, 1234)
19
+ invoice.notes = 'Test'
20
+ assert_true(invoice.save)
21
+ end
22
+
23
+ should "send an invoice" do
24
+ invoice = Invoice.new(@client, 1234)
25
+ emails = invoice.send
26
+ end
27
+
28
+ should "pay an invoice" do
29
+ invoice = Invoice.new(@client, 1234)
30
+ assert_true(invoice.pay)
31
+ end
32
+
33
+ should "delete an invoice" do
34
+ invoie = Invoice.new(@client, 1234)
35
+ assert_true(invoice.delete)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class TransactionTest < Test::Unit::TestCase
5
+ should "create a transaction" do
6
+ transaction = @client.Transaction.create({:invoice => 123, :amount => 800})
7
+ end
8
+
9
+ should "list all transactions" do
10
+ @client.Transaction.list
11
+ end
12
+
13
+ should "retrieve a transaction" do
14
+ transaction = @client.Transaction.retrieve(1234)
15
+ end
16
+
17
+ should "update a transaction" do
18
+ transaction = Transaction.new(@client, 1234)
19
+ transaction.notes = 'Update'
20
+ assert_true(transaction.save)
21
+ end
22
+
23
+ should "send a payment receipt" do
24
+ transaction = Transaction.new(@client, 1234)
25
+ emails = transaction.send
26
+ end
27
+
28
+ should "refund a transaction" do
29
+ transaction = Transaction.new(@client, 1234)
30
+ refund = transaction.refund({:amount => 800})
31
+ end
32
+
33
+ should "delete a transaction" do
34
+ transaction = Transaction.new(@client, 1234)
35
+ assert_true(transaction.delete)
36
+ end
37
+ end
38
+ 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: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -123,6 +123,7 @@ files:
123
123
  - invoiced.gemspec
124
124
  - lib/invoiced.rb
125
125
  - lib/invoiced/customer.rb
126
+ - lib/invoiced/email.rb
126
127
  - lib/invoiced/error/api_error.rb
127
128
  - lib/invoiced/error/authentication_error.rb
128
129
  - lib/invoiced/error/error_base.rb
@@ -140,7 +141,9 @@ files:
140
141
  - lib/invoiced/util.rb
141
142
  - lib/invoiced/version.rb
142
143
  - test/invoiced/customer_test.rb
144
+ - test/invoiced/invoice_test.rb
143
145
  - test/invoiced/invoiced_test.rb
146
+ - test/invoiced/transaction_test.rb
144
147
  - test/invoiced/util_test.rb
145
148
  - test/test_helper.rb
146
149
  homepage: https://developers.invoiced.com
@@ -169,7 +172,9 @@ specification_version: 4
169
172
  summary: Ruby client library for the Invoiced API
170
173
  test_files:
171
174
  - test/invoiced/customer_test.rb
175
+ - test/invoiced/invoice_test.rb
172
176
  - test/invoiced/invoiced_test.rb
177
+ - test/invoiced/transaction_test.rb
173
178
  - test/invoiced/util_test.rb
174
179
  - test/test_helper.rb
175
180
  has_rdoc: