rubill 0.1.6 → 0.1.7
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 +4 -4
- data/lib/rubill.rb +3 -13
- data/lib/rubill/base.rb +8 -1
- data/lib/rubill/entities/actg_class.rb +3 -0
- data/lib/rubill/{attachment.rb → entities/attachment.rb} +1 -4
- data/lib/rubill/{bill.rb → entities/bill.rb} +0 -4
- data/lib/rubill/{bill_payment.rb → entities/bill_payment.rb} +0 -4
- data/lib/rubill/entities/customer.rb +7 -0
- data/lib/rubill/{customer_contact.rb → entities/customer_contact.rb} +0 -4
- data/lib/rubill/{invoice.rb → entities/invoice.rb} +0 -4
- data/lib/rubill/entities/item.rb +3 -0
- data/lib/rubill/entities/location.rb +3 -0
- data/lib/rubill/{received_payment.rb → entities/received_payment.rb} +0 -0
- data/lib/rubill/{sent_bill_payment.rb → entities/sent_bill_payment.rb} +0 -0
- data/lib/rubill/{sent_payment.rb → entities/sent_payment.rb} +0 -0
- data/lib/rubill/{vendor.rb → entities/vendor.rb} +0 -4
- data/lib/rubill/query.rb +8 -0
- data/lib/rubill/session.rb +31 -23
- metadata +16 -13
- data/lib/rubill/customer.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f96a5cd060d28c4392edf23dc9c628a63d1d860c
|
4
|
+
data.tar.gz: 23030225af499e6ef66a6697f5e63d38a99dba9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8c0601f8b9b4e832e79fe751a0f7dd6028b295931242722f36b8be839da2c9ead9bf14cfb4799fb633778cd79f612706251320b63e9756c30077785a876446
|
7
|
+
data.tar.gz: 6313e9208df792a06532ce0fd718d0722151d21a529a377d1cbfcc39797e2c19b93ada6eceb6c8137e618dbf4fc196573b05e17b227e57c8294bda3313b3b6c7
|
data/lib/rubill.rb
CHANGED
@@ -43,18 +43,8 @@ module Rubill
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
require "rubill/session"
|
47
|
-
require "rubill/query"
|
48
46
|
require "rubill/base"
|
49
|
-
require "rubill/
|
50
|
-
require "rubill/
|
51
|
-
require "rubill/invoice"
|
52
|
-
require "rubill/attachment"
|
53
|
-
require "rubill/sent_payment"
|
54
|
-
require "rubill/sent_bill_payment"
|
55
|
-
require "rubill/received_payment"
|
56
|
-
require "rubill/vendor"
|
57
|
-
require "rubill/customer"
|
58
|
-
require "rubill/customer_contact"
|
59
|
-
require "rubill/attachment"
|
47
|
+
require "rubill/query"
|
48
|
+
require "rubill/session"
|
60
49
|
|
50
|
+
Dir["#{File.dirname(__FILE__)}/rubill/entities/*.rb"].each { |f| require f }
|
data/lib/rubill/base.rb
CHANGED
@@ -48,6 +48,12 @@ module Rubill
|
|
48
48
|
Query.delete(remote_class_name, id)
|
49
49
|
end
|
50
50
|
|
51
|
+
def self.find_by_name(name)
|
52
|
+
raw_result = Query.list(remote_class_name, 0, 1, [Query::Filter.new("name", "=", name)])
|
53
|
+
|
54
|
+
new(raw_result.first)
|
55
|
+
end
|
56
|
+
|
51
57
|
def self.where(filters=[])
|
52
58
|
raise ArgumentError unless filters.is_a?(Enumerable)
|
53
59
|
raise ArgumentError if !filters.is_a?(Hash) && !filters.all? { |f| f.is_a?(Query::Filter) }
|
@@ -84,7 +90,8 @@ module Rubill
|
|
84
90
|
private
|
85
91
|
|
86
92
|
def self.remote_class_name
|
87
|
-
|
93
|
+
# Assume remote class name is the same as the class name
|
94
|
+
self.name.sub('Rubill::', '')
|
88
95
|
end
|
89
96
|
end
|
90
97
|
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/rubill/query.rb
CHANGED
@@ -61,6 +61,14 @@ module Rubill
|
|
61
61
|
execute("/SendVendorInvite.json", vendorId: vendorId, email: email)
|
62
62
|
end
|
63
63
|
|
64
|
+
def self.get_disbursement_data(id)
|
65
|
+
execute("/GetDisbursementData.json", sentPayId: id)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.get_check_image_data(id)
|
69
|
+
execute("/GetCheckImageData.json", sentPayId: id)
|
70
|
+
end
|
71
|
+
|
64
72
|
def execute
|
65
73
|
Session.instance.execute(self)
|
66
74
|
end
|
data/lib/rubill/session.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
require "
|
1
|
+
require "rest-client"
|
2
2
|
require "json"
|
3
3
|
require "singleton"
|
4
|
+
require "tempfile"
|
5
|
+
|
4
6
|
|
5
7
|
module Rubill
|
6
8
|
class APIError < StandardError; end
|
7
9
|
|
8
10
|
class Session
|
9
|
-
include HTTParty
|
10
11
|
include Singleton
|
11
12
|
|
12
|
-
attr_accessor :id
|
13
|
-
|
14
|
-
base_uri "https://api.bill.com/api/v2"
|
13
|
+
attr_accessor :id, :base_uri
|
15
14
|
|
16
15
|
def initialize
|
17
16
|
config = self.class.configuration
|
@@ -20,7 +19,9 @@ module Rubill
|
|
20
19
|
end
|
21
20
|
|
22
21
|
if config.sandbox
|
23
|
-
self.
|
22
|
+
self.base_uri = "https://api-stage.bill.com/api/v2"
|
23
|
+
else
|
24
|
+
self.base_uri = "https://api.bill.com/api/v2"
|
24
25
|
end
|
25
26
|
|
26
27
|
login
|
@@ -31,21 +32,23 @@ module Rubill
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def login
|
34
|
-
self.id = self.class.login
|
35
|
+
self.id = self.class.login(self.base_uri)
|
35
36
|
end
|
36
37
|
|
37
|
-
def self.login
|
38
|
+
def self.login(base_uri)
|
38
39
|
login_options = {
|
39
40
|
password: configuration.password,
|
40
41
|
userName: configuration.user_name,
|
41
42
|
devKey: configuration.dev_key,
|
42
43
|
orgId: configuration.org_id,
|
43
44
|
}
|
44
|
-
login = _post("/Login.json", login_options)
|
45
|
+
login = _post(base_uri + "/Login.json", login_options)
|
45
46
|
login[:sessionId]
|
46
47
|
end
|
47
48
|
|
48
49
|
def options(data={})
|
50
|
+
data = data.dup
|
51
|
+
data.delete(:content)
|
49
52
|
{
|
50
53
|
sessionId: id,
|
51
54
|
devKey: self.class.configuration.dev_key,
|
@@ -53,13 +56,22 @@ module Rubill
|
|
53
56
|
}
|
54
57
|
end
|
55
58
|
|
56
|
-
def
|
57
|
-
|
59
|
+
def file_from_data(data = {})
|
60
|
+
if data && data.is_a?(Hash) && data.key?(:fileName)
|
61
|
+
file = Tempfile.new(data[:fileName])
|
62
|
+
file.write data[:content]
|
63
|
+
file.rewind
|
64
|
+
end
|
65
|
+
|
66
|
+
file
|
58
67
|
end
|
59
68
|
|
60
69
|
def _post(url, data, retries=0)
|
61
70
|
begin
|
62
|
-
|
71
|
+
file = file_from_data(data)
|
72
|
+
response_data = self.class._post(self.base_uri + url, options(data), file)
|
73
|
+
file.close if file
|
74
|
+
response_data
|
63
75
|
rescue APIError => e
|
64
76
|
if e.message =~ /Session is invalid/ && retries < 3
|
65
77
|
login
|
@@ -70,23 +82,19 @@ module Rubill
|
|
70
82
|
end
|
71
83
|
end
|
72
84
|
|
73
|
-
def self._post(url, options)
|
74
|
-
|
75
|
-
file = StringIO.new(options.delete(:content))
|
76
|
-
end
|
77
|
-
|
78
|
-
post_options = {
|
79
|
-
body: options,
|
80
|
-
headers: default_headers,
|
81
|
-
}
|
85
|
+
def self._post(url, options, file = nil)
|
86
|
+
post_options = options
|
82
87
|
|
83
|
-
|
88
|
+
if file
|
89
|
+
post_options[:file] = file
|
90
|
+
post_options[:multipart] = true
|
91
|
+
end
|
84
92
|
|
85
93
|
if self.configuration.debug
|
86
94
|
post_options[:debug_output] = $stdout
|
87
95
|
end
|
88
96
|
|
89
|
-
response = post(url, post_options)
|
97
|
+
response = RestClient.post(url, post_options)
|
90
98
|
result = JSON.parse(response.body, symbolize_names: true)
|
91
99
|
|
92
100
|
unless result[:response_status] == 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Taber
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2014-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -73,19 +73,22 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- lib/rubill.rb
|
76
|
-
- lib/rubill/attachment.rb
|
77
76
|
- lib/rubill/base.rb
|
78
|
-
- lib/rubill/
|
79
|
-
- lib/rubill/
|
80
|
-
- lib/rubill/
|
81
|
-
- lib/rubill/
|
82
|
-
- lib/rubill/
|
77
|
+
- lib/rubill/entities/actg_class.rb
|
78
|
+
- lib/rubill/entities/attachment.rb
|
79
|
+
- lib/rubill/entities/bill.rb
|
80
|
+
- lib/rubill/entities/bill_payment.rb
|
81
|
+
- lib/rubill/entities/customer.rb
|
82
|
+
- lib/rubill/entities/customer_contact.rb
|
83
|
+
- lib/rubill/entities/invoice.rb
|
84
|
+
- lib/rubill/entities/item.rb
|
85
|
+
- lib/rubill/entities/location.rb
|
86
|
+
- lib/rubill/entities/received_payment.rb
|
87
|
+
- lib/rubill/entities/sent_bill_payment.rb
|
88
|
+
- lib/rubill/entities/sent_payment.rb
|
89
|
+
- lib/rubill/entities/vendor.rb
|
83
90
|
- lib/rubill/query.rb
|
84
|
-
- lib/rubill/received_payment.rb
|
85
|
-
- lib/rubill/sent_bill_payment.rb
|
86
|
-
- lib/rubill/sent_payment.rb
|
87
91
|
- lib/rubill/session.rb
|
88
|
-
- lib/rubill/vendor.rb
|
89
92
|
homepage: http://rubygems.org/gems/rubill
|
90
93
|
licenses:
|
91
94
|
- MIT
|
@@ -106,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
109
|
version: '0'
|
107
110
|
requirements: []
|
108
111
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.1
|
110
113
|
signing_key:
|
111
114
|
specification_version: 4
|
112
115
|
summary: Interface with Bill.com
|
data/lib/rubill/customer.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Rubill
|
2
|
-
class Customer < Base
|
3
|
-
def self.find_by_name(name)
|
4
|
-
where([Query::Filter.new("name", "=", name)]).first
|
5
|
-
end
|
6
|
-
|
7
|
-
def contacts
|
8
|
-
CustomerContact.active_by_customer(id)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.remote_class_name
|
12
|
-
"Customer"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|