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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00d34d8d6d01b5a1ba07efb6a978829a6ca8e78f
4
- data.tar.gz: 8864f8c57abb79e676cfc465e85f571e17f15c9c
3
+ metadata.gz: 04c42e83273f4aaa849e084a3f85fe1d9ca19774
4
+ data.tar.gz: d73f74df0a87b3a0b463b1067f065dd912b6435f
5
5
  SHA512:
6
- metadata.gz: e9289d659a6c7f098d3b1a85c3f81483b2fa699af3adce974b377d8ee899f94fa6ff850107aaffb7a82178fb2cf0c86474204e751c4f0e41f8f5b9a3cd2648e8
7
- data.tar.gz: 87af3716b0aabaa9db71677d66322bf6100f293c7507fdc7e7e010e8986bba9fe25b244442741dd546f27a9d4a3b2c5c945532f911127cfe96030f00280c0cc3
6
+ metadata.gz: 2d18a43735d99b4b4a5b818065d6d272079b5d35fdabfa6ad641d02d5d42a9411c5ed7001a2967c57bca36d279a3586ed582ee4f0325aa9f830493d25f79da47
7
+ data.tar.gz: a158fd956c0e7e482db051cd3d4cc876757045df7662050a6c604ae51da79e9a253118d7765c187a6aa4a6f6736cf504e2999a8bb9317bc04823b470d3379150
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,4 @@
1
+ ==== Version 0.1.2
2
+ Features:
3
+ * Add support #create, #update, #destroy methods for /Items API
4
+ * Add support for /Search endpoint
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
@@ -1,4 +1,4 @@
1
1
  class Saasu::Item < Saasu::Base
2
- allowed_methods :show, :index
2
+ allowed_methods :show, :index, :destroy, :update, :create
3
3
  filter_by %W(ItemType SearchMethod SearchText)
4
4
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Saasu
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/saasu.rb CHANGED
@@ -11,6 +11,7 @@ require "saasu/account"
11
11
  require "saasu/tax_code"
12
12
  require "saasu/config"
13
13
  require "saasu/auth"
14
+ require "saasu/search"
14
15
 
15
16
  module Saasu
16
17
  end
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.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-07-30 00:00:00.000000000 Z
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