saasu2 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +4 -0
- data/README.md +10 -1
- data/lib/saasu/item.rb +1 -1
- data/lib/saasu/search.rb +55 -0
- data/lib/saasu/version.rb +1 -1
- data/lib/saasu.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04c42e83273f4aaa849e084a3f85fe1d9ca19774
|
4
|
+
data.tar.gz: d73f74df0a87b3a0b463b1067f065dd912b6435f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d18a43735d99b4b4a5b818065d6d272079b5d35fdabfa6ad641d02d5d42a9411c5ed7001a2967c57bca36d279a3586ed582ee4f0325aa9f830493d25f79da47
|
7
|
+
data.tar.gz: a158fd956c0e7e482db051cd3d4cc876757045df7662050a6c604ae51da79e9a253118d7765c187a6aa4a6f6736cf504e2999a8bb9317bc04823b470d3379150
|
data/CHANGELOG.rdoc
ADDED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ require 'saasu'
|
|
24
24
|
Saasu::Config.configure do |c|
|
25
25
|
c.username = 'username@email.com'
|
26
26
|
c.password = 'password'
|
27
|
-
c.file_id = 1234 # Your Saasu FileId can be found at
|
27
|
+
c.file_id = 1234 # Your Saasu FileId can be found at https://secure.saasu.com/a/net/webservicessettings.aspx
|
28
28
|
end
|
29
29
|
```
|
30
30
|
|
@@ -41,6 +41,7 @@ You can access the following objects:
|
|
41
41
|
- Saasu::Item
|
42
42
|
- Saasu::Payment
|
43
43
|
- Saasu::TaxCode
|
44
|
+
- Saasu::Search
|
44
45
|
|
45
46
|
Usage examples:
|
46
47
|
|
@@ -74,6 +75,14 @@ contact['GivenName'] = 'John'
|
|
74
75
|
|
75
76
|
# get all attributes
|
76
77
|
contact.attributes
|
78
|
+
|
79
|
+
# Search. Available scopes: All, Transactions, Contacts, InventoryItems.
|
80
|
+
query = Saasu::Search.new(keywords: 'Book', scope: 'All')
|
81
|
+
query.perform
|
82
|
+
|
83
|
+
query.contacts
|
84
|
+
query.items
|
85
|
+
query.invoices
|
77
86
|
```
|
78
87
|
|
79
88
|
Note - Saasu uses .NET naming convention for fields and filters eg. GivenName, LastModifiedDate
|
data/lib/saasu/item.rb
CHANGED
data/lib/saasu/search.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Saasu
|
2
|
+
class Search
|
3
|
+
VALID_SCOPES = %W(All Transactions Contacts InventoryItems)
|
4
|
+
attr_accessor :scope, :keywords
|
5
|
+
|
6
|
+
def initialize(scope: nil, keywords:)
|
7
|
+
@scope = scope
|
8
|
+
@keywords = keywords
|
9
|
+
|
10
|
+
validate_scope!
|
11
|
+
end
|
12
|
+
|
13
|
+
def perform
|
14
|
+
perform_search!
|
15
|
+
{ contacts: search_results['TotalContactsFound'], invoices: search_results['TotalTransactionsFound'], items: search_results['TotalInventoryItemsFound'] }
|
16
|
+
end
|
17
|
+
|
18
|
+
def contacts
|
19
|
+
search_results["Contacts"].map do |contact|
|
20
|
+
Saasu::Contact.new(contact)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def invoices
|
25
|
+
search_results["Transactions"].map do |contact|
|
26
|
+
Saasu::Invoice.new(contact)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def items
|
31
|
+
search_results["InventoryItems"].map do |contact|
|
32
|
+
Saasu::Item.new(contact)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def perform_search!
|
38
|
+
@search_results = Saasu::Client.request(:get, 'search', { Scope: scope, Keywords: @keywords, IncludeSearchTermHighlights: false })
|
39
|
+
end
|
40
|
+
|
41
|
+
def scope
|
42
|
+
@scope ||= 'All'
|
43
|
+
end
|
44
|
+
|
45
|
+
def search_results
|
46
|
+
@search_results ||= perform_search!
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate_scope!
|
50
|
+
unless scope.in? VALID_SCOPES
|
51
|
+
raise "Invalid scope argument. Valid values are: #{VALID_SCOPES.join(', ')}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/saasu/version.rb
CHANGED
data/lib/saasu.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saasu2
|
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
|
- Nick Sinenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- ".rspec"
|
162
162
|
- ".ruby-version"
|
163
163
|
- ".travis.yml"
|
164
|
+
- CHANGELOG.rdoc
|
164
165
|
- CODE_OF_CONDUCT.md
|
165
166
|
- Gemfile
|
166
167
|
- LICENSE.txt
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- lib/saasu/invoice_attachment.rb
|
181
182
|
- lib/saasu/item.rb
|
182
183
|
- lib/saasu/payment.rb
|
184
|
+
- lib/saasu/search.rb
|
183
185
|
- lib/saasu/tax_code.rb
|
184
186
|
- lib/saasu/version.rb
|
185
187
|
- saasu2.gemspec
|