invoiced 0.1.0 → 0.2.0

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: 739b78cad11f23a94d816a162764b1cc7f4a07e6
4
- data.tar.gz: b81de1a3b758d0552a846dc7f8086446c11d851d
3
+ metadata.gz: 0f8a46e7387b20f707e7e5635d73f98e82c854c8
4
+ data.tar.gz: ad3d8c0b95ac5161bd2b3685b53046983080c67f
5
5
  SHA512:
6
- metadata.gz: d68a8bf4387dbe7afbd8d48c6dc97f298361aa33ef6b06506bb0d601b322efb18f78e54dc95301191dab6efbbfdc1e1573ebaff31086c41abfd60b63d2f8c208
7
- data.tar.gz: 30321d8b70d9b69aca97bd4db4f4745ec2b428781ca19b6eb7325e079329e3858dcb52ceda91b1b0bb75c0b413a48af1938d2233099157f89425c61b74ed9215
6
+ metadata.gz: 1a9e191a39b17b162d6dff0e2b1b0377c2f4fe93070e07415cdd734384f5b98199bfd36311f7a78c41a51202714fd09e97c9be4851f37d7b002de0bd058b2e61
7
+ data.tar.gz: 9ff6981193c43fe25e3550f737b19e782fba9e1dd18ee77c078091d0603e4785ff90bc161816de3525c3970a399426f4a9a44d8f99c26fed5664f1b96aabc4a8
data/README.md CHANGED
@@ -49,6 +49,14 @@ transaction = invoiced.Transaction.create(
49
49
  :method => "check")
50
50
  ```
51
51
 
52
+ If you want to use the sandbox API instead then you must set the second argument on the client to `true` like this:
53
+
54
+ ```ruby
55
+ require 'invoiced'
56
+
57
+ invoiced = Invoiced::Client.new("{API_KEY}", true)
58
+ ```
59
+
52
60
  ## Developing
53
61
 
54
62
  The gem can be built with:
@@ -1,3 +1,3 @@
1
1
  module Invoiced
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/invoiced.rb CHANGED
@@ -26,12 +26,15 @@ require 'invoiced/subscription'
26
26
  module Invoiced
27
27
  class Client
28
28
  ApiBase = 'https://api.invoiced.com'
29
+ ApiBaseSandbox = 'https://api.sandbox.invoiced.com'
29
30
 
30
- attr_reader :api_key
31
+ attr_reader :api_key, :api_url, :sandbox
31
32
  attr_reader :Customer, :Invoice, :Transaction, :Subscription
32
33
 
33
- def initialize(api_key)
34
+ def initialize(api_key, sandbox=false)
34
35
  @api_key = api_key
36
+ @sandbox = sandbox
37
+ @api_url = sandbox ? ApiBaseSandbox : ApiBase
35
38
  @Customer = Invoiced::Customer.new(self)
36
39
  @Invoice = Invoiced::Invoice.new(self)
37
40
  @Transaction = Invoiced::Transaction.new(self)
@@ -39,7 +42,7 @@ module Invoiced
39
42
  end
40
43
 
41
44
  def request(method, endpoint, params={})
42
- url = ApiBase + endpoint
45
+ url = @api_url + endpoint
43
46
 
44
47
  case method.to_s.downcase.to_sym
45
48
  # These methods don't have a request body
@@ -8,8 +8,15 @@ module Invoiced
8
8
  should "create new client" do
9
9
  client = Invoiced::Client.new('api_key')
10
10
  assert_equal('api_key', client.api_key)
11
+ assert_equal('https://api.invoiced.com', client.api_url)
11
12
  end
12
13
 
14
+ should "create new sandbox client" do
15
+ client = Invoiced::Client.new('api_key', true)
16
+ assert_equal('api_key', client.api_key)
17
+ assert_equal('https://api.sandbox.invoiced.com', client.api_url)
18
+ end
19
+
13
20
  should "perform a get request" do
14
21
  mockResponse = mock('RestClient::Response')
15
22
  mockResponse.stubs(:code).returns(200)
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.1.0
4
+ version: 0.2.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: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client