Class: Harvest::Base
- Inherits:
-
Object
- Object
- Harvest::Base
- Defined in:
- lib/harvest/base.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#clients ⇒ Object
Clients.
-
#contacts ⇒ Object
Contacts.
-
#expense_categories ⇒ Object
Expense categories.
-
#expenses ⇒ Object
Expenses.
-
#initialize(options = {}) ⇒ Base
constructor
Requires a sub_domain, email, and password.
-
#invoice_messages ⇒ Object
Invoice Messages.
-
#invoices ⇒ Object
Invoices.
-
#people ⇒ Object
People.
-
#projects ⇒ Object
Projects.
-
#tasks ⇒ Object
Tasks.
Constructor Details
#initialize(options = {}) ⇒ Base
Requires a sub_domain, email, and password. Specifying headers is optional, but useful for setting a user agent.
38 39 40 41 42 43 44 45 46 |
# File 'lib/harvest/base.rb', line 38 def initialize(={}) .assert_required_keys(:email, :password, :sub_domain) @email = [:email] @password = [:password] @sub_domain = [:sub_domain] @headers = [:headers] @ssl = [:ssl] configure_base_resource end |
Class Method Details
.debug_level ⇒ Object
5 6 7 |
# File 'lib/harvest/base.rb', line 5 def self.debug_level @debug_level end |
.debug_level=(debug_level) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/harvest/base.rb', line 9 def self.debug_level=(debug_level) raise ArgumentError, "debug level must be an integer" unless debug_level == debug_level.to_i return @debug_level if @debug_level == debug_level @debug_level = debug_level.to_i ActiveSupport::Notifications.unsubscribe(@subscriber) if @subscriber case @debug_level when 0 then when 1 then @subscriber = ActiveSupport::Notifications.subscribe(/request.active_resource/) do |*args| event = ActiveSupport::Notifications::Event.new(*args) puts "-- HARVEST #{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}, #{event.payload[:result].andand.code}: #{event.payload[:result].andand.}" end else @subscriber = ActiveSupport::Notifications.subscribe(/request.active_resource/) do |*args| event = ActiveSupport::Notifications::Event.new(*args) puts "-- HARVEST #{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}, #{event.payload[:result].andand.code}: #{event.payload[:result].andand.}" puts event.payload[:result].body + "\n" end end @debug_level end |
Instance Method Details
#clients ⇒ Object
Clients
52 53 54 |
# File 'lib/harvest/base.rb', line 52 def clients Harvest::Resources::Client end |
#contacts ⇒ Object
Contacts
57 58 59 |
# File 'lib/harvest/base.rb', line 57 def contacts Harvest::Resources::Contact end |
#expense_categories ⇒ Object
Expense categories.
67 68 69 |
# File 'lib/harvest/base.rb', line 67 def expense_categories Harvest::Resources::ExpenseCategory end |
#expenses ⇒ Object
Expenses.
62 63 64 |
# File 'lib/harvest/base.rb', line 62 def expenses Harvest::Resources::Expense end |
#invoice_messages ⇒ Object
Invoice Messages
95 96 97 |
# File 'lib/harvest/base.rb', line 95 def Harvest::Resources::InvoiceMessage end |
#invoices ⇒ Object
Invoices
90 91 92 |
# File 'lib/harvest/base.rb', line 90 def invoices Harvest::Resources::Invoice end |
#people ⇒ Object
People. Also provides access to time entries.
73 74 75 |
# File 'lib/harvest/base.rb', line 73 def people Harvest::Resources::Person end |