Module: Invoicexpress::Client::Schedules
- Included in:
- Invoicexpress::Client
- Defined in:
- lib/invoicexpress/client/schedules.rb
Instance Method Summary collapse
-
#activate_schedule(schedule, options = {}) ⇒ Object
Activates a previously deactivated schedule.
-
#create_schedule(schedule, options = {}) ⇒ Object
Creates a new schedule.
-
#deactivate_schedule(schedule, options = {}) ⇒ Object
Deactivates a schedule.
-
#schedule(schedule, options = {}) ⇒ Object
Returns a specific schedule.
-
#schedules(options = {}) ⇒ Array<Invoicexpress::Models::Schedule>
Returns all your schedules.
-
#update_schedule(schedule, options = {}) ⇒ Object
Updates a schedule.
Instance Method Details
#activate_schedule(schedule, options = {}) ⇒ Object
Activates a previously deactivated schedule
75 76 77 78 79 80 |
# File 'lib/invoicexpress/client/schedules.rb', line 75 def activate_schedule(schedule, ={}) raise(ArgumentError, "schedule has the wrong type") unless schedule.is_a?(Invoicexpress::Models::Schedule) params = { :body => schedule, :klass => Invoicexpress::Models::Schedule } put("schedules/#{id_from_schedule(schedule)}/activate", params.merge()) end |
#create_schedule(schedule, options = {}) ⇒ Object
Creates a new schedule. It also allows you to create a new client and/or items in the same request. If the client name does not exist a new one is created. Regarding item taxes, if the tax name is not found, it is ignored and no tax is applied to that item. If no item exists with the given name a new one will be created. If the item exists it will be updated with the new values. Be careful when updating the schedule items, as any missing items from the original invoice are deleted.
28 29 30 31 32 33 |
# File 'lib/invoicexpress/client/schedules.rb', line 28 def create_schedule(schedule, ={}) raise(ArgumentError, "schedule has the wrong type") unless schedule.is_a?(Invoicexpress::Models::Schedule) params = { :klass => Invoicexpress::Models::Schedule, :body => schedule } post("schedules.xml", params.merge()) end |
#deactivate_schedule(schedule, options = {}) ⇒ Object
Deactivates a schedule. No invoices are created while the schedule is deactivated
89 90 91 92 93 94 |
# File 'lib/invoicexpress/client/schedules.rb', line 89 def deactivate_schedule(schedule, ={}) raise(ArgumentError, "schedule has the wrong type") unless schedule.is_a?(Invoicexpress::Models::Schedule) params = { :body => schedule, :klass => Invoicexpress::Models::Schedule } put("schedules/#{id_from_schedule(schedule)}/deactivate", params.merge()) end |
#schedule(schedule, options = {}) ⇒ Object
Returns a specific schedule.
41 42 43 44 |
# File 'lib/invoicexpress/client/schedules.rb', line 41 def schedule(schedule, ={}) params = { :klass => Invoicexpress::Models::Schedule } get("schedules/#{id_from_schedule(schedule)}.xml", params.merge()) end |
#schedules(options = {}) ⇒ Array<Invoicexpress::Models::Schedule>
Returns all your schedules.
10 11 12 13 14 |
# File 'lib/invoicexpress/client/schedules.rb', line 10 def schedules( = {}) params = { :klass => Invoicexpress::Models::Schedule } get("schedules.xml", params.merge()) end |
#update_schedule(schedule, options = {}) ⇒ Object
Updates a schedule. It also allows you to create a new client and/or items in the same request. If the client name does not exist a new one is created. Regarding item taxes, if the tax name is not found, it is ignored and no tax is applied to that item. If no item exists with the given name a new one will be created. If the item exists it will be updated with the new values. Be careful when updating the schedule items, as any missing items from the original invoice are deleted.
58 59 60 61 62 63 64 65 |
# File 'lib/invoicexpress/client/schedules.rb', line 58 def update_schedule(schedule, ={}) raise(ArgumentError, "schedule has the wrong type") unless schedule.is_a?(Invoicexpress::Models::Schedule) if !schedule.id raise ArgumentError, "Schedule's ID is required" end params = { :klass => Invoicexpress::Models::Schedule, :body => schedule.to_core_schedule() } put("schedules/#{schedule.id}.xml", params.merge()) end |