Class: Quickeebooks::Online::Service::Account

Inherits:
ServiceBase
  • Object
show all
Defined in:
lib/quickeebooks/online/service/account.rb

Constant Summary

Constants inherited from ServiceBase

ServiceBase::QB_BASE_URI, ServiceBase::XML_NS

Instance Attribute Summary

Attributes inherited from ServiceBase

#base_uri, #oauth, #realm_id

Instance Method Summary collapse

Methods inherited from ServiceBase

#access_token=, #base_url=, #initialize, #login_name, #url_for_base, #url_for_resource

Constructor Details

This class inherits a constructor from Quickeebooks::Online::Service::ServiceBase

Instance Method Details

#create(account) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/quickeebooks/online/service/account.rb', line 13

def create()
  raise InvalidModelException unless .valid?
  xml = .to_xml_ns
  response = do_http_post(url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular), valid_xml_document(xml))
  if response && response.code.to_i == 200
    Quickeebooks::Online::Model::Account.from_xml(response.body)
  else
    nil
  end
end

#delete(account) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/quickeebooks/online/service/account.rb', line 41

def delete()
  raise InvalidModelException.new("Missing required parameters for delete") unless .valid_for_deletion?
  xml = valid_xml_document(.to_xml_ns(:fields => ['Id', 'SyncToken']))
  url = "#{url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)}/#{.id}"
  response = do_http_post(url, xml, {:methodx => "delete"})
  response.code.to_i == 200
end

#fetch_by_id(account_id) ⇒ Object



36
37
38
39
# File 'lib/quickeebooks/online/service/account.rb', line 36

def fetch_by_id()
  response = do_http_get("#{url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)}/#{}")
  Quickeebooks::Online::Model::Account.from_xml(response.body)
end

#list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object



9
10
11
# File 'lib/quickeebooks/online/service/account.rb', line 9

def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
  fetch_collection(Quickeebooks::Online::Model::Account, filters, page, per_page, sort, options)
end

#update(account) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/quickeebooks/online/service/account.rb', line 24

def update()
  raise InvalidModelException unless .valid_for_update?
  xml = .to_xml_ns
  url = "#{url_for_resource(Quickeebooks::Online::Model::Account.resource_for_singular)}/#{.id}"
  response = do_http_post(url, valid_xml_document(xml))
  if response && response.code.to_i == 200
    Quickeebooks::Online::Model::Account.from_xml(response.body)
  else
    nil
  end
end