saasu 0.0.1 → 0.0.2
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.
- data/README.md +3 -1
- data/VERSION +1 -1
- data/lib/saasu.rb +1 -0
- data/lib/saasu/base.rb +16 -10
- data/lib/saasu/invoice.rb +1 -0
- data/saasu.gemspec +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -19,9 +19,11 @@ To fetch all invoices
|
|
19
19
|
|
20
20
|
invoices = Saasu::Invoice.all
|
21
21
|
|
22
|
+
By default all sales purchases are retrieved as this field is required.
|
23
|
+
|
22
24
|
You can pass in any conditions as a hash. The keys should be in snake case.
|
23
25
|
|
24
|
-
invoices = Saasu::Invoice.all(:transaction_type => "
|
26
|
+
invoices = Saasu::Invoice.all(:transaction_type => "p", :paid_status => "Unpaid")
|
25
27
|
|
26
28
|
For a complete list of supported options see the [Saasu API Reference](http://help.saasu.com/api/http-get/)
|
27
29
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/saasu.rb
CHANGED
data/lib/saasu/base.rb
CHANGED
@@ -6,6 +6,7 @@ module Saasu
|
|
6
6
|
|
7
7
|
def initialize(xml)
|
8
8
|
klass = self.class.name.split("::")[1].downcase
|
9
|
+
|
9
10
|
xml.children.each do |child|
|
10
11
|
if !child.text?
|
11
12
|
child.attributes.each do |attr|
|
@@ -70,8 +71,13 @@ module Saasu
|
|
70
71
|
# Generally the class name will be suitable and options will not need to be provided
|
71
72
|
# @param [Hash] options to override the default settings
|
72
73
|
#
|
73
|
-
def defaults(options =
|
74
|
-
default_options
|
74
|
+
def defaults(options = nil)
|
75
|
+
@defaults ||= default_options
|
76
|
+
if options
|
77
|
+
@defaults = default_options.merge!(options)
|
78
|
+
else
|
79
|
+
@defaults
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
protected
|
@@ -79,10 +85,11 @@ module Saasu
|
|
79
85
|
# Default options for the class
|
80
86
|
#
|
81
87
|
def default_options
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
88
|
+
options = {}
|
89
|
+
options[:query_options] ||= {}
|
90
|
+
options[:resource_name] = name.split("::").last.downcase
|
91
|
+
options[:collection_name] = name.split("::").last.downcase + "ListItem"
|
92
|
+
options
|
86
93
|
end
|
87
94
|
|
88
95
|
# Defines the fields for a resource and any transformations
|
@@ -95,7 +102,7 @@ module Saasu
|
|
95
102
|
end
|
96
103
|
|
97
104
|
def define_accessor(field, type)
|
98
|
-
m = field.sub(
|
105
|
+
m = field.sub(/^#{defaults[:resource_name]}_/, "")
|
99
106
|
case type
|
100
107
|
when :decimal
|
101
108
|
class_eval <<-END
|
@@ -148,17 +155,16 @@ module Saasu
|
|
148
155
|
#
|
149
156
|
def get(options = {}, all = true)
|
150
157
|
uri = URI.parse(request_path(options, all))
|
151
|
-
puts request_path(options, all)
|
152
158
|
http = Net::HTTP.new(uri.host, uri.port)
|
153
159
|
http.use_ssl = true
|
154
160
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
155
161
|
response = http.request(Net::HTTP::Get.new(uri.request_uri))
|
156
|
-
puts response.body
|
157
162
|
(options[:format] && options[:format] == "pdf") ? response.body : response.body
|
158
163
|
end
|
159
164
|
|
160
165
|
def query_string(options = {})
|
161
|
-
options =
|
166
|
+
options = defaults[:query_options].merge(options)
|
167
|
+
options = { :wsaccesskey => api_key, :fileuid => file_uid }.merge(options)
|
162
168
|
options.map { |k,v| "#{k.to_s.gsub(/_/, "")}=#{v}"}.join("&")
|
163
169
|
end
|
164
170
|
|
data/lib/saasu/invoice.rb
CHANGED
data/saasu.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saasu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kieran Johnson
|