debitoor-client 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/debitoor-client.gemspec +2 -2
- data/lib/debitoor/client.rb +40 -7
- data/lib/debitoor/version.rb +3 -0
- metadata +3 -3
- data/lib/debitoor/client/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a351bea09fc141ba0ba7e2b4c92db5050af326a
|
4
|
+
data.tar.gz: 2c2a3d59f1f64a2561fdb2368dc2e8ac9476f7c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66ca2e90c7de61ac2cfc2f1c9cd9d35488032b8b9430c2a21cf38855d94758c2ad9e296f8fad4f7864f7445c14991af40c8c850e60e33f72aa45eedba7f4baa1
|
7
|
+
data.tar.gz: f0f4ce1f7cc1f4bc7f5eaa4795e7f3d7eb725e76f918c3f844f29dbea868bf3a2745853e1c49994f60f3d6eb4a003689da50ad2976c35d8110b7b420d9a0d388
|
data/debitoor-client.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'debitoor/
|
4
|
+
require 'debitoor/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "debitoor-client"
|
8
|
-
spec.version = Debitoor::
|
8
|
+
spec.version = Debitoor::VERSION
|
9
9
|
spec.authors = ["Alessio Santo"]
|
10
10
|
spec.email = ["alessio.santocs@gmail.com"]
|
11
11
|
|
data/lib/debitoor/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require "debitoor/
|
1
|
+
require "debitoor/version"
|
2
|
+
require "httparty"
|
2
3
|
|
3
4
|
module Debitoor
|
4
5
|
class Client
|
@@ -7,7 +8,10 @@ module Debitoor
|
|
7
8
|
|
8
9
|
def initialize(token)
|
9
10
|
@token = token
|
10
|
-
@options = { headers: {
|
11
|
+
@options = { headers: {
|
12
|
+
"x-token" => token,
|
13
|
+
"Content-Type" => 'application/json'
|
14
|
+
} }
|
11
15
|
end
|
12
16
|
|
13
17
|
# Public: Creates a draft invoice and accepts a body containing
|
@@ -27,6 +31,39 @@ module Debitoor
|
|
27
31
|
}.merge!(@options)
|
28
32
|
|
29
33
|
response = nil
|
34
|
+
id = invoice_id(id_or_response_invoice)
|
35
|
+
|
36
|
+
response = self.class.post("/api/sales/draftinvoices/#{id}/book/v3", options) if id.present?
|
37
|
+
respond_with!(response)
|
38
|
+
end
|
39
|
+
|
40
|
+
def share_invoice(id_or_response_invoice, email, subject="Here's your receipt")
|
41
|
+
options = {
|
42
|
+
body: {recipient: email, subject: subject}.to_json
|
43
|
+
}.merge!(@options)
|
44
|
+
|
45
|
+
response = nil
|
46
|
+
id = invoice_id(id_or_response_invoice)
|
47
|
+
|
48
|
+
response = self.class.post("/api/sales/invoices/#{id}/share/v1", options) if id.present?
|
49
|
+
respond_with!(response)
|
50
|
+
end
|
51
|
+
|
52
|
+
def email_invoice(id_or_response_invoice, email, subject="Here's your receipt", message="")
|
53
|
+
options = {
|
54
|
+
body: {recipient: email, subject: subject, message: message}.to_json
|
55
|
+
}.merge!(@options)
|
56
|
+
|
57
|
+
response = nil
|
58
|
+
id = invoice_id(id_or_response_invoice)
|
59
|
+
|
60
|
+
response = self.class.post("/api/sales/invoices/#{id}/email/v2", options) if id.present?
|
61
|
+
respond_with!(response)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def invoice_id(id_or_response_invoice)
|
30
67
|
id = nil
|
31
68
|
id = id_or_response_invoice if id_or_response_invoice.kind_of?(String)
|
32
69
|
|
@@ -34,13 +71,9 @@ module Debitoor
|
|
34
71
|
id = id_or_response_invoice.parsed_response["id"]
|
35
72
|
end
|
36
73
|
|
37
|
-
|
38
|
-
response = self.class.post("/api/sales/draftinvoices/#{id}/book/v3", options) if id.present?
|
39
|
-
respond_with!(response)
|
74
|
+
return id
|
40
75
|
end
|
41
76
|
|
42
|
-
private
|
43
|
-
|
44
77
|
def respond_with!(response)
|
45
78
|
raise(response.inspect) unless response.code.to_s.start_with?("2")
|
46
79
|
return response
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debitoor-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessio Santo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- bin/setup
|
86
86
|
- debitoor-client.gemspec
|
87
87
|
- lib/debitoor/client.rb
|
88
|
-
- lib/debitoor/
|
88
|
+
- lib/debitoor/version.rb
|
89
89
|
homepage: https://github.com/milanmaison/debitoor-client
|
90
90
|
licenses:
|
91
91
|
- MIT
|