Skip to content
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/spec/reports/
/tmp/
*.gem
.ruby-version
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: ruby
rvm:
- 2.0.0
- 2.1.6
- 2.2.2
- 2.2.7
- 2.3.4
- 2.4.1
3 changes: 3 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
==== Version 0.1.5
* Allow setting of PageSize and Page

==== Version 0.1.4
Features:
* Saasu::User.reset_password – Allows a user to request that a password reset email be generated and sent to them.
Expand Down
2 changes: 1 addition & 1 deletion lib/saasu/account.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Saasu::Account < Saasu::Base
allowed_methods :show, :index, :destroy, :update, :create
filter_by %W(IsActive IsBankAccount AccountType IncludeBuiltIn PageSize Page)
filter_by %W(IsActive IsBankAccount AccountType IncludeBuiltIn HeaderAccountId AccountLevel PageSize Page)
end
2 changes: 1 addition & 1 deletion lib/saasu/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def to_s
end

def id
@attributes['Id']
@attributes.has_key?('Id') ? @attributes['Id'] : @attributes['TransactionId']
end

protected
Expand Down
2 changes: 1 addition & 1 deletion lib/saasu/company.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Saasu::Company < Saasu::Base
allowed_methods :show, :index, :destroy, :update, :create
filter_by %W(LastModifiedFromDate LastModifiedToDate CompanyName=)
filter_by %W(LastModifiedFromDate LastModifiedToDate CompanyName PageSize Page)
end
2 changes: 1 addition & 1 deletion lib/saasu/contact.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Saasu::Contact < Saasu::Base
allowed_methods :show, :index, :destroy, :update, :create
filter_by %W(LastModifiedFromDate LastModifiedToDate GivenName FamilyName IsActive IsCustomer IsSupplier IsContractor IsPartner Tags TagSelection Email ContactId)
filter_by %W(LastModifiedFromDate LastModifiedToDate GivenName FamilyName CompanyName CompanyId IsActive IsCustomer IsSupplier IsContractor IsPartner Tags TagSelection Email ContactId PageSize Page)
end
20 changes: 19 additions & 1 deletion lib/saasu/invoice.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Saasu::Invoice < Saasu::Base
allowed_methods :show, :index, :destroy, :update, :create
filter_by %W(InvoiceNumber LastModifiedFromDate LastModifiedToDate TransactionType Tags TagSelection InvoiceFromDate InvoiceToDate InvoiceStatus PaymentStatus ContactId)
filter_by %W(InvoiceNumber PurchaseOrderNumber LastModifiedFromDate LastModifiedToDate TransactionType Tags TagSelection InvoiceFromDate InvoiceToDate InvoiceStatus PaymentStatus BillingContactId PageSize Page)

def email(email_address = nil)
if email_address.present?
Expand All @@ -13,4 +13,22 @@ def email(email_address = nil)

Saasu::Client.request(:post, url, params)
end

# Returns the pdf file as raw binary data in a String object
#
# if there is problem getting the PDF you will get a runtime error
# e.g RuntimeError (Server did not return a valid response. URL: Invoice/9999/generate-pdf?FileId=9999. Response status: 400. Response body: Unable to perform the request.):
#
# this can happen if the tempate_id is invalid
def generate_pdf(template_id = nil)
if template_id.present?
url = ['Invoice', id, 'generate-pdf'].join('/')
params = { TemplateId: template_id }
else
url = ['Invoice', id, 'generate-pdf'].join('/')
params = {}
end

Saasu::Client.request(:get, url, params)
end
end
2 changes: 1 addition & 1 deletion lib/saasu/item.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Saasu::Item < Saasu::Base
allowed_methods :show, :index, :destroy, :update, :create
filter_by %W(ItemType SearchMethod SearchText)
filter_by %W(LastModifiedFromDate LastModifiedToDate IsActive ItemType SearchMethod PageSize)
end
2 changes: 1 addition & 1 deletion lib/saasu/payment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Saasu::Payment < Saasu::Base
allowed_methods :show, :index, :destroy, :update, :create
filter_by %W(LastModifiedFromDate LastModifiedToDate ForInvoiceId ClearedFromDate ClearedToDate TransactionType PaymentFromDate PaymentToDate PaymentAccountId)
filter_by %W(LastModifiedFromDate LastModifiedToDate ForInvoiceId ClearedFromDate ClearedToDate TransactionType PaymentFromDate PaymentToDate PaymentAccountId PageSize Page)
end
2 changes: 1 addition & 1 deletion lib/saasu/tax_code.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Saasu::TaxCode < Saasu::Base
allowed_methods :show, :index
filter_by %W(IsActive)
filter_by %W(IsActive Page PageSize)
end
6 changes: 3 additions & 3 deletions spec/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
expect(query.perform).to eq({ contacts: 9, invoices: 8, items: 7 })
expect(a_request(:get, "https://api.saasu.com/search?FileId=777&IncludeSearchTermHighlights=false&Keywords=Customer&Scope=All&TransactionType=Transactions.Sale"))
.to have_been_made
end
end
end

private
Expand All @@ -33,11 +33,11 @@ def mock_api_requests
to_return(status: 200, body: { access_token: '12345', refresh_token: '67890', expires_in: 1000 }.to_json, headers: {'Content-Type'=>'application/json'})

stub_request(:get, "https://api.saasu.com/search?FileId=777&IncludeSearchTermHighlights=false&Keywords=Customer&Scope=All").
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer 12345', 'User-Agent'=>'Faraday v0.9.1', 'X-Api-Version'=>'1.0'}).
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer 12345', 'X-Api-Version'=>'1.0'}).
to_return(:status => 200, body: search_results.to_json, :headers => {'Content-Type'=>'application/json'})

stub_request(:get, "https://api.saasu.com/search?FileId=777&IncludeSearchTermHighlights=false&Keywords=Customer&Scope=All&TransactionType=Transactions.Sale").
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer 12345', 'User-Agent'=>'Faraday v0.9.1', 'X-Api-Version'=>'1.0'}).
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer 12345', 'X-Api-Version'=>'1.0'}).
to_return(:status => 200, body: search_results_with_transaction_type.to_json, :headers => {'Content-Type'=>'application/json'})
end

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
end

config.mock_with :rspec
config.treat_symbols_as_metadata_keys_with_true_values = true
config.color = :enabled
config.order = :random
end

RSpec::Expectations.configuration.on_potential_false_positives = :nothing

Dir[File.dirname(__FILE__) + '*.rb'].each { |file| require_relative file }
5 changes: 3 additions & 2 deletions spec/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def mock_api_requests
to_return(status: 200, body: { access_token: '12345', refresh_token: '67890', expires_in: 1000 }.to_json, headers: {'Content-Type'=>'application/json'})

stub_request(:post, "https://api.saasu.com/User/reset-password?FileId=777").
with(:body => "{\"Username\":\"user@saasu.com\"}", :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer 12345', 'User-Agent'=>'Faraday v0.9.1', 'X-Api-Version'=>'1.0'}).
to_return(:status => 200, body: {}.to_json, :headers => {'Content-Type'=>'application/json'})
with(:body => "{\"Username\":\"user@saasu.com\"}",
headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer 12345', 'Content-Type'=>'application/json', 'X-Api-Version'=>'1.0'})
.to_return(:status => 200, body: {}.to_json, :headers => {'Content-Type'=>'application/json'})
end
end