Class: SKApi::Resources::Invoice

Inherits:
Base show all
Defined in:
lib/resources/invoice.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, set_connection

Methods included from Utils::Serializer

included

Methods inherited from ActiveResource::Base

#encode, instantiate_collection, #load_attributes_from_response

Constructor Details

This class inherits a constructor from SKApi::Resources::Base

Class Method Details



42
43
44
45
46
# File 'lib/resources/invoice.rb', line 42

def self.api_links
  #internal links on fields=> id => salesking.eu/clients/4567.json
#external links to actions and related objects => invoeis => salesking.eu/clients/4567/invoices.json
  [:edit, :destroy, :copy, :print, :show, :payments, :payment_new]
end

.schemaObject

Class methods



13
14
15
16
# File 'lib/resources/invoice.rb', line 13

def self.schema
  { "type" => "object",
    "properties" => SKApi::Resources::Invoice.schema_props}
end

.schema_propsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/resources/invoice.rb', line 18

def self.schema_props
  {
     "id"             => {"type" => "string", "identity" => true, "optional" => true, "readonly" => true},
     "number"         => {"type" => "string", "optional" => true},
     "date"           => {"type" => "string", "format" =>"date", "optional" => true},
     "due_days"       => {"type" => "integer", "optional" => true},
     "title"          => {"type" => "string", "optional" => true},
     "status"         => {"type" => "string", "enum" => ["draft", "open", "closed"], "default" =>"draft", "optional" => true},
     "payment_method" => {"type" => "string", "enum" => ["cash", "bank_transfer", "credit_card", "paypal", "direct_debit", "cheque"], "optional" => true},
     "due_date"       => {"type" => "string", "format" =>"date", "optional" => true},
     "notes_before"   => {"type" => "string", "optional" => true},
     "notes_after"    => {"type" => "string", "optional" => true},
     "price_total"    => {"type" => "number", "optional" => true, "readonly" => true},
     "price_tax"      => {"type" => "number", "optional" => true, "readonly" => true},
     "created_at"     => {"type" => "string", "format" =>"date-time", "optional" => true, "readonly"=> true},
     "updated_at"     => {"type" => "string", "format" =>"date-time", "optional" => true, "readonly"=> true},
     "address_field"  => {"type" => "string", "optional" => true},
     "lock_version"   => {"type" => "integer", "optional" => true, "readonly" => true},
     "client_id"      => {"type" => "string"},
     "client"         => {"type" => "object", "properties" => SKApi::Resources::Client.schema_props, "optional" => true, "readonly" => true},
     "line_items"     => {"type" => "array","properties" => SKApi::Resources::LineItem.schema_props, "optional" => true}
   }
end

Instance Method Details

#saveObject



5
6
7
# File 'lib/resources/invoice.rb', line 5

def save
  save_with_validation
end