qbwc_requests 0.1.03 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # QbwcRequests
1
+ # Qbwc Requests
2
2
 
3
3
  With qbwc_requests you have an easy way to create Qbxml requests.
4
4
 
5
+ [![Build Status](https://semaphoreci.com/api/v1/projects/c357ba42-3d3e-4061-985e-6c3c9c68a9b4/557601/badge.svg)](https://semaphoreci.com/apotema/qbwc_requests)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -19,7 +21,7 @@ Or install it yourself as:
19
21
  ## Usage
20
22
 
21
23
  * Query Requisitions
22
-
24
+
23
25
  ```ruby
24
26
  Qbwc::Request::V07::Account.query
25
27
  ```
@@ -43,7 +45,7 @@ That will create an Account query for the qbxml version 7.0
43
45
  * Add Requisitions
44
46
 
45
47
  ```ruby
46
- Qbwc::Request::V07::Account.new(name: 'Some Account name').add
48
+ Qbwc::Request::V07::Account.new(name: 'Some Account name').add("2")
47
49
  ```
48
50
 
49
51
  result
@@ -95,7 +97,7 @@ Right now we just have the following models on this gem.
95
97
  - Invoices
96
98
  - Estimates
97
99
 
98
- The Qbxml version for this models is the 7.0.
100
+ The Qbxml version for this models is the 7.0
99
101
 
100
102
 
101
103
  ## Contributing
@@ -104,4 +106,4 @@ The Qbxml version for this models is the 7.0.
104
106
  2. Create your feature branch (`git checkout -b my-new-feature`)
105
107
  3. Commit your changes (`git commit -am 'Add some feature'`)
106
108
  4. Push to the branch (`git push origin my-new-feature`)
107
- 5. Create new Pull Request
109
+ 5. Create new Pull Request
@@ -1,4 +1,4 @@
1
- module Qbwc
1
+ module Qbwc
2
2
  module Request
3
3
  class Base
4
4
 
@@ -7,13 +7,17 @@ module Qbwc
7
7
  include ActiveModel::Validations
8
8
  include ActiveModel::Conversion
9
9
 
10
- def self.query options = nil
10
+ def self.query options = nil, header = nil
11
11
  options = { max_returned: 2000 } if options == nil or options.empty?
12
- XmlActions.query "#{underscore self.name.demodulize}_query_rq", options
12
+ XmlActions.query "#{underscore self.name.demodulize}_query_rq", options, header
13
13
  end
14
-
15
- def add
16
- self.valid? ? add_xml : self
14
+
15
+ def modify request_id
16
+ modify_xml request_id
17
+ end
18
+
19
+ def add request_id
20
+ self.valid? ? add_xml(request_id) : self
17
21
  end
18
22
 
19
23
  def initialize(attributes = {})
@@ -44,20 +48,30 @@ module Qbwc
44
48
  def compact opts={}
45
49
  # I pass two times to avoid {v: '1',k: {}}, gotta find a better algorithm (recursive)
46
50
  return {} if opts.nil?
47
- proc = Proc.new { |k, v| v.kind_of?(Hash) ? (v.delete_if(&proc); nil) : (v == nil || v.empty?) };
51
+ proc = Proc.new { |k, v| v.kind_of?(Hash) ? (v.delete_if(&proc); nil) : (v == nil || (v.respond_to?(:empty) && v.empty?)) };
48
52
  hash = opts.delete_if(&proc)
49
- hash.delete_if { |k, v| (v == nil || v.empty?) }
53
+ hash.delete_if { |k, v| (v == nil || (v.respond_to?(:empty) && v.empty?)) }
50
54
  end
51
55
 
52
- def add_xml
56
+ def add_xml request_id
53
57
  req = XmlActions.header
54
58
  req['qbxml']['qbxml_msgs_rq']["#{class_name}_add_rq"] = {"xml_attributes"=>
55
- {"requestID"=>"2"},
59
+ {"requestID"=>"#{request_id}"},
56
60
  "#{class_name}_add"=> self.ordered_fields
57
61
  }
58
62
  XmlActions.to_xml(req)
59
63
  end
60
64
 
65
+
66
+ def modify_xml request_id
67
+ req = XmlActions.header
68
+ req['qbxml']['qbxml_msgs_rq']["#{class_name}_mod_rq"] = {"xml_attributes"=>
69
+ {"requestID"=>"#{request_id}"},
70
+ "#{class_name}_mod"=> self.ordered_fields
71
+ }
72
+ XmlActions.to_xml(req)
73
+ end
74
+
61
75
  end
62
76
  end
63
77
  end
@@ -0,0 +1,11 @@
1
+ module Qbwc
2
+ module Request
3
+ module V07
4
+ class GeneralDetailReport < Qbwc::Request::Base
5
+
6
+
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,9 +1,9 @@
1
- module Qbwc
1
+ module Qbwc
2
2
  module Request
3
3
  module V07
4
4
  class Item
5
5
  def self.query
6
- XmlActions.query "item_query_rq", max_returned: 2000
6
+ XmlActions.query "item_query_rq", {max_returned: 2000}, {}
7
7
  end
8
8
  end
9
9
  end
@@ -1,4 +1,4 @@
1
- module Qbwc
1
+ module Qbwc
2
2
  module Request
3
3
  module V07
4
4
  class PurchaseOrder < Qbwc::Request::Base
@@ -26,7 +26,12 @@ module Qbwc
26
26
  field :other2
27
27
  field :purchase_order_line_add
28
28
  field :purchase_order_line_group_add
29
-
29
+
30
+ #MODIFICATION FIELDS
31
+ field :purchase_order_line_mod
32
+ field :txn_ID
33
+ field :edit_sequence
34
+
30
35
  end
31
36
  end
32
37
  end
@@ -1,4 +1,4 @@
1
- module Qbwc
1
+ module Qbwc
2
2
  module Request
3
3
  module V07
4
4
  class Vendor < Qbwc::Request::Base
@@ -10,15 +10,21 @@ module Qbwc
10
10
  field :first_name
11
11
  field :middle_name
12
12
  field :last_name
13
+ field :vendor_address
13
14
  field :phone
15
+ field :alt_phone
16
+ field :fax
14
17
  field :email
15
18
  field :contact
19
+ field :alt_contact
16
20
  field :name_on_check
21
+ field :account_number
22
+ field :notes
17
23
  field :is_vendor_eligible_for_1099
18
24
  field :open_balance
19
25
 
20
26
  validates :name, presence: true
21
-
27
+
22
28
  end
23
29
  end
24
30
  end
@@ -0,0 +1,17 @@
1
+ module Qbwc
2
+ module Request
3
+ module V07
4
+ class VendorAddress < Qbwc::Request::Base
5
+
6
+ field :addr1
7
+ field :addr2
8
+ field :addr3
9
+ field :addr4
10
+ field :city
11
+ field :state
12
+ field :postal_code
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,19 +1,27 @@
1
1
  module Qbwc
2
2
  module XmlActions
3
3
 
4
- def self.query req, options
4
+ def self.query req, options, header
5
5
  hash = {"qbxml"=>
6
- {"xml_attributes"=>{},
6
+ {"xml_attributes"=> {},
7
7
  "qbxml_msgs_rq"=>
8
- {"xml_attributes"=>{"onError"=>"stopOnError"},
8
+ {"xml_attributes" => {"onError"=>"stopOnError"},
9
9
  "#{req}"=>
10
- {"xml_attributes"=>{}}.merge(options)
10
+ {"xml_attributes"=> self.header_attributes(header)}.merge(options)
11
11
  }
12
12
  }
13
13
  }
14
14
  self.to_xml(hash)
15
15
  end
16
16
 
17
+ def self.header_attributes attributes = {}
18
+ hash = {}
19
+ if attributes
20
+ hash["requestID"] = attributes["requestID"] if attributes["requestID"]
21
+ end
22
+ hash
23
+ end
24
+
17
25
  def self.header
18
26
  {"qbxml"=>
19
27
  {"xml_attributes"=>{}, "qbxml_msgs_rq"=>
@@ -1,3 +1,3 @@
1
1
  module QbwcRequests
2
- VERSION = "0.1.03"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -8,12 +8,12 @@ class GenericBase < Qbwc::Request::Base
8
8
  end
9
9
 
10
10
  describe GenericBase do
11
-
11
+
12
12
  describe '#initialize' do
13
13
 
14
14
  it 'should deal with nil values' do
15
15
  expect {
16
- GenericBase.new(nil)
16
+ GenericBase.new(nil)
17
17
  }.to_not raise_error
18
18
  end
19
19
 
@@ -35,7 +35,7 @@ describe GenericBase do
35
35
 
36
36
  it 'should not raise error for nil values' do
37
37
  expect {
38
- GenericBase.new(parameters).add()
38
+ GenericBase.new(parameters).add("request_id")
39
39
  }.to_not raise_error
40
40
  end
41
41
 
@@ -46,13 +46,13 @@ describe GenericBase do
46
46
  <?qbxml version="7.0"?>
47
47
  <QBXML>
48
48
  <QBXMLMsgsRq onError="stopOnError">
49
- <GenericBaseAddRq requestID="2">
49
+ <GenericBaseAddRq requestID="request_id">
50
50
  <GenericBaseAdd></GenericBaseAdd>
51
51
  </GenericBaseAddRq>
52
52
  </QBXMLMsgsRq>
53
53
  </QBXML>
54
54
  XML
55
- add_xml = GenericBase.new(parameters).add()
55
+ add_xml = GenericBase.new(parameters).add("request_id")
56
56
  expect( add_xml ).to be_xml_equal_to expected_xml
57
57
  end
58
58
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Qbwc::Request::V07::Account do
4
-
4
+
5
5
  it_behaves_like 'queryable'
6
6
 
7
7
  it { is_expected.to validate_field_presence_of :name }
@@ -16,7 +16,7 @@ RSpec.describe Qbwc::Request::V07::Account do
16
16
  <?qbxml version="7.0"?>
17
17
  <QBXML>
18
18
  <QBXMLMsgsRq onError="stopOnError">
19
- <AccountAddRq requestID="2">
19
+ <AccountAddRq requestID="request_id">
20
20
  <AccountAdd>
21
21
  <Name>a</Name>
22
22
  </AccountAdd>
@@ -24,9 +24,9 @@ RSpec.describe Qbwc::Request::V07::Account do
24
24
  </QBXMLMsgsRq>
25
25
  </QBXML>
26
26
  XML
27
- expect( account.add ).to be_xml_equal_to xml
27
+ expect( account.add("request_id") ).to be_xml_equal_to xml
28
28
  end
29
29
 
30
30
  end
31
31
 
32
- end
32
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Qbwc::Request::V07::Bill do
4
-
4
+
5
5
  it_behaves_like 'queryable'
6
6
 
7
7
  describe "add" do
@@ -14,14 +14,14 @@ RSpec.describe Qbwc::Request::V07::Bill do
14
14
  <?qbxml version="7.0"?>
15
15
  <QBXML>
16
16
  <QBXMLMsgsRq onError="stopOnError">
17
- <BillAddRq requestID="2">
17
+ <BillAddRq requestID="request_id">
18
18
  <BillAdd>
19
19
  </BillAdd>
20
20
  </BillAddRq>
21
21
  </QBXMLMsgsRq>
22
22
  </QBXML>
23
23
  XML
24
- expect( bill.add ).to be_xml_equal_to xml
24
+ expect( bill.add("request_id") ).to be_xml_equal_to xml
25
25
  end
26
26
 
27
27
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Qbwc::Request::V07::Customer do
4
-
4
+
5
5
  it_behaves_like 'queryable'
6
6
 
7
7
  it { is_expected.to validate_field_presence_of :name }
@@ -16,7 +16,7 @@ RSpec.describe Qbwc::Request::V07::Customer do
16
16
  <?qbxml version="7.0"?>
17
17
  <QBXML>
18
18
  <QBXMLMsgsRq onError="stopOnError">
19
- <CustomerAddRq requestID="2">
19
+ <CustomerAddRq requestID="request_id">
20
20
  <CustomerAdd>
21
21
  <Name>a</Name>
22
22
  </CustomerAdd>
@@ -24,9 +24,9 @@ RSpec.describe Qbwc::Request::V07::Customer do
24
24
  </QBXMLMsgsRq>
25
25
  </QBXML>
26
26
  XML
27
- expect( customer.add ).to be_xml_equal_to xml
27
+ expect( customer.add("request_id") ).to be_xml_equal_to xml
28
28
  end
29
29
 
30
30
  end
31
31
 
32
- end
32
+ end
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Qbwc::Request::V07::Estimate do
4
-
4
+
5
5
  it_behaves_like 'queryable'
6
6
 
7
7
  it{ is_expected.to validate_field_presence_of :customer_ref }
8
8
  it{ is_expected.to validate_field_presence_of :estimate_line_add }
9
9
 
10
10
  describe "add" do
11
-
11
+
12
12
  let(:estimate){ Qbwc::Request::V07::Estimate.new(customer_ref: {full_name: 'Some customer name'}, estimate_line_add: {item_ref: {full_name: 'Some intem name'}}) }
13
13
 
14
- it "should create an add estimate xml" do
14
+ it "should create an add estimate xml" do
15
15
  xml = <<-XML
16
16
  <?xml version='1.0' encoding='utf-8'?>
17
17
  <?qbxml version="7.0"?>
18
18
  <QBXML>
19
19
  <QBXMLMsgsRq onError="stopOnError">
20
- <EstimateAddRq requestID="2">
20
+ <EstimateAddRq requestID="request_id">
21
21
  <EstimateAdd>
22
22
  <CustomerRef>
23
23
  <FullName>Some customer name</FullName>
@@ -32,8 +32,8 @@ RSpec.describe Qbwc::Request::V07::Estimate do
32
32
  </QBXMLMsgsRq>
33
33
  </QBXML>
34
34
  XML
35
- expect( estimate.add ).to be_xml_equal_to xml
35
+ expect( estimate.add("request_id") ).to be_xml_equal_to xml
36
36
  end
37
-
37
+
38
38
  end
39
- end
39
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Qbwc::Request::V07::GeneralDetailReport do
4
+
5
+ it_behaves_like 'queryable'
6
+
7
+ end
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Qbwc::Request::V07::Invoice do
4
-
4
+
5
5
  it_behaves_like 'queryable'
6
6
 
7
7
  it{ is_expected.to validate_field_presence_of :customer_ref }
8
8
  it{ is_expected.to validate_field_presence_of :invoice_line_add }
9
9
 
10
10
  describe "add" do
11
-
11
+
12
12
  let(:invoice){ Qbwc::Request::V07::Invoice.new(customer_ref: {full_name: 'Some customer name'}, invoice_line_add: {item_ref: {full_name: 'Some item name'}}) }
13
13
 
14
- it "should create an add invoice xml" do
14
+ it "should create an add invoice xml" do
15
15
  xml = <<-XML
16
16
  <?xml version='1.0' encoding='utf-8'?>
17
17
  <?qbxml version="7.0"?>
18
18
  <QBXML>
19
19
  <QBXMLMsgsRq onError="stopOnError">
20
- <InvoiceAddRq requestID="2">
20
+ <InvoiceAddRq requestID="request_id">
21
21
  <InvoiceAdd>
22
22
  <CustomerRef>
23
23
  <FullName>Some customer name</FullName>
@@ -32,8 +32,8 @@ RSpec.describe Qbwc::Request::V07::Invoice do
32
32
  </QBXMLMsgsRq>
33
33
  </QBXML>
34
34
  XML
35
- expect( invoice.add ).to be_xml_equal_to xml
35
+ expect( invoice.add("request_id") ).to be_xml_equal_to xml
36
36
  end
37
37
 
38
38
  end
39
- end
39
+ end