Module: Invoicexpress::Client::Sequences

Included in:
Invoicexpress::Client
Defined in:
lib/invoicexpress/client/sequences.rb

Instance Method Summary collapse

Instance Method Details

#create_sequence(sequence, options = {}) ⇒ Object

Creates a new sequence.

Parameters:

Returns:

  • Invoicexpress::Models::Sequence The sequence

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::UnprocessableEntity When there are errors on the submission



33
34
35
36
37
38
# File 'lib/invoicexpress/client/sequences.rb', line 33

def create_sequence(sequence, options={})
  raise(ArgumentError, "sequence has the wrong type") unless sequence.is_a?(Invoicexpress::Models::Sequence)

  params = { :klass => Invoicexpress::Models::Sequence, :body => sequence }
  post("sequences.xml", params.merge(options))
end

#sequence(sequence, options = {}) ⇒ Object

Returns a specific sequence.

Parameters:

Returns:

  • Invoicexpress::Models::Sequence The sequence

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::NotFound When the sequence doesn’t exist



21
22
23
24
25
# File 'lib/invoicexpress/client/sequences.rb', line 21

def sequence(sequence, options={})
  params = { :klass => Invoicexpress::Models::Sequence }

  get("sequences/#{id_from_sequence(sequence)}.xml", params.merge(options))
end

#sequences(options = {}) ⇒ Array<Invoicexpress::Models::Sequence>

Returns all your sequences.

Returns:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized



9
10
11
12
13
# File 'lib/invoicexpress/client/sequences.rb', line 9

def sequences(options = {})
  params = { :klass => Invoicexpress::Models::Sequence }

  get("sequences.xml", params.merge(options))
end

#update_sequence(sequence, options = {}) ⇒ Object

Updates a specific sequence. Only sequences with no finalized invoices can be updated.

Parameters:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::NotFound When the sequence doesn’t exist

  • Invoicexpress::UnprocessableEntity When there are errors on the submission



47
48
49
50
51
52
53
54
# File 'lib/invoicexpress/client/sequences.rb', line 47

def update_sequence(sequence, options={})
  raise(ArgumentError, "sequence has the wrong type") unless sequence.is_a?(Invoicexpress::Models::Sequence)
  if !sequence.id
    raise ArgumentError, "Sequence ID is required"
  end
  params = { :klass => Invoicexpress::Models::Sequence, :body => sequence }
  put("sequences/#{sequence.id}.xml", params.merge(options))
end