agris 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ea4982d122c579b9b71f3ab91b6a2d42e2e48c8
4
- data.tar.gz: 83a5b68f31c5e89faf9ff0f9e01dcdfa3a90403c
3
+ metadata.gz: cbd46cc8f2b9b4bf6ca1af3e2953f2b7ce26aef6
4
+ data.tar.gz: b6115cd1b162c8e4e0bab1849a85b1bcbcc61c12
5
5
  SHA512:
6
- metadata.gz: dc70709cbb66bf2d468baed243b87a0dc19df95780640fd65f2d113cf2a3618c43d387b6908256c1feb8794e5f13731bd90845cd0258f804d36e9e67d0f2d9ac
7
- data.tar.gz: 52ea2f398b04bc08cb31adcc5ee659ecae224d58c0ea6f15bfef1409dbbd145eceb4445fa59c4e13ef397f4e38a49b354f564a0c76eff0909f086ffddf3d36f6
6
+ metadata.gz: e0d6669a41eda7418e5a396766098a0e56e43101f484bb08e527ba4785977ab2a8bdb3e3680e14284b4752ce199e2f3f27a9026e06bbe6971f0001c646c1b7fd
7
+ data.tar.gz: d13a3daf42827bbc6b4ae50de0c75141519c2796180c3145253c6ba720b79f9e0a9e8a320bb699230e8df38f225e3eef267c9458bd3a7b3ad7bb316d1b131867
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'rubocop', '0.49.0'
30
30
  spec.add_development_dependency 'simplecov'
31
31
  spec.add_development_dependency 'webmock', '~> 2.3'
32
+ spec.add_development_dependency 'pry-byebug'
32
33
  end
@@ -10,7 +10,9 @@ module Agris
10
10
 
11
11
  def last_request_date_time
12
12
  DateTime.parse(
13
- @output_hash["#{resource_name}s"]['system']['lastrequestdatetime']
13
+ @output_hash[pluralized_resource_name] \
14
+ ['system'] \
15
+ ['lastrequestdatetime']
14
16
  )
15
17
  end
16
18
 
@@ -35,6 +37,10 @@ module Agris
35
37
  .downcase
36
38
  end
37
39
 
40
+ def pluralized_resource_name
41
+ resource_type.pluralized_name
42
+ end
43
+
38
44
  def resource_type
39
45
  @resource_type ||= Object.const_get(
40
46
  self
@@ -48,7 +54,7 @@ module Agris
48
54
 
49
55
  def resources
50
56
  # Wrap and flatten for single responses
51
- [@output_hash["#{resource_name}s"][resource_name]]
57
+ [@output_hash[pluralized_resource_name][resource_name]]
52
58
  .compact
53
59
  .flatten
54
60
  end
@@ -2,11 +2,15 @@
2
2
  module Agris
3
3
  module Api
4
4
  module Grain
5
+ autoload :Commodity, 'agris/api/grain/commodity'
6
+ autoload :CommodityCodes, 'agris/api/grain/commodity_codes'
5
7
  autoload :Contract, 'agris/api/grain/contract'
6
8
  autoload :PurchaseContracts, 'agris/api/grain/purchase_contracts'
7
9
  autoload :NewTicket, 'agris/api/grain/new_ticket'
8
10
  autoload :NewTicketApplication, 'agris/api/grain/new_ticket_application'
9
11
  autoload :NewTicketRemark, 'agris/api/grain/new_ticket_remark'
12
+ autoload :SpecificCommodityCodeExtract,
13
+ 'agris/api/grain/specific_commodity_code_extract'
10
14
  autoload :SpecificPurchaseContractExtract,
11
15
  'agris/api/grain/specific_purchase_contract_extract'
12
16
  autoload :Tickets,
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+ module Agris
3
+ module Api
4
+ module Grain
5
+ class Commodity
6
+ include XmlModel
7
+
8
+ def self.pluralized_name
9
+ 'commodities'
10
+ end
11
+
12
+ ATTRIBUTE_NAMES = %w(
13
+ unique_id
14
+ integration_guid
15
+ location
16
+ location_description
17
+ code
18
+ code_description
19
+ dpr_by_variety_class
20
+ buy_sell_uom_code
21
+ buy_sell_uom
22
+ inv_buy_sell_uom_code
23
+ inv_buy_sell_uom_code_desc
24
+ position_uom
25
+ ledger_uom
26
+ buy_sell_weight_factor
27
+ position_weight_factor
28
+ ledger_weight_factor
29
+ status
30
+ status_description
31
+ hedgeable
32
+ valid_future_month
33
+ nearby_future_month
34
+ default_future_month
35
+ default_board_name
36
+ inbound_freight_account
37
+ inbound_freight_account_desc
38
+ outbound_freight_account
39
+ outbound_freight_account_desc
40
+ ar_invoice_type
41
+ ar_invoice_type_desc
42
+ position_report_field_1
43
+ position_report_field_2
44
+ ap_voucher_type
45
+ ap_voucher_type_desc
46
+ taxable_1
47
+ taxable_2
48
+ taxable_3
49
+ taxable_4
50
+ inbound_adjust_prcnt
51
+ outbound_adjust_prcnt
52
+ minimum_price
53
+ maximum_price
54
+ cash_price
55
+ cash_basis
56
+ freight_tax_percent
57
+ hedge_percent
58
+ uom_product_group
59
+ uom_product_group_description
60
+ delete
61
+ lastchangedatetime
62
+ last_change_user_id
63
+ last_change_user_name
64
+ ).freeze
65
+
66
+ attr_reader(*ATTRIBUTE_NAMES)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ module Agris
3
+ module Api
4
+ module Grain
5
+ module CommodityCodes
6
+ def commodity_code(location, code)
7
+ extract = Agris::Api::Grain::SpecificCommodityCodeExtract
8
+ .new(location, code)
9
+
10
+ commodity_codes([extract])
11
+ end
12
+
13
+ def commodity_codes(extracts)
14
+ extract_documents(
15
+ Messages::QueryCommodityCodeDocuments.new(extracts),
16
+ Agris::Api::Grain::Commodity
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module Agris
3
+ module Api
4
+ module Grain
5
+ class SpecificCommodityCodeExtract
6
+ include ::Agris::XmlModel
7
+
8
+ attr_accessor :location, :code
9
+
10
+ def initialize(location, code)
11
+ @location = location
12
+ @code = code
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,12 +2,16 @@
2
2
  module Agris
3
3
  module Api
4
4
  module Messages
5
+ autoload :DocumentQueryBase,
6
+ 'agris/api/messages/document_query_base'
5
7
  autoload :MessageBase,
6
8
  'agris/api/messages/message_base'
7
9
  autoload :Import,
8
10
  'agris/api/messages/import'
9
11
  autoload :QueryBase,
10
12
  'agris/api/messages/query_base'
13
+ autoload :QueryCommodityCodeDocuments,
14
+ 'agris/api/messages/query_commodity_code_documents'
11
15
  autoload :QueryChangedDeliveryTickets,
12
16
  'agris/api/messages/query_changed_delivery_tickets'
13
17
  autoload :QueryChangedPurchaseContracts,
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module Agris
3
+ module Api
4
+ module Messages
5
+ class DocumentQueryBase < QueryBase
6
+ def initialize(document_references)
7
+ @document_references = document_references
8
+ end
9
+
10
+ protected
11
+
12
+ def input_hash
13
+ input_base_hash
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module Agris
3
+ module Api
4
+ module Messages
5
+ class QueryCommodityCodeDocuments < DocumentQueryBase
6
+ def message_number
7
+ 81_300
8
+ end
9
+
10
+ protected
11
+
12
+ def xml_hash
13
+ xml_base_hash
14
+ .merge(
15
+ commodity: @document_references.map(&:to_xml_hash)
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,21 +2,13 @@
2
2
  module Agris
3
3
  module Api
4
4
  module Messages
5
- class QueryDeliveryTicketDocuments < QueryBase
6
- def initialize(document_references)
7
- @document_references = document_references
8
- end
9
-
5
+ class QueryDeliveryTicketDocuments < DocumentQueryBase
10
6
  def message_number
11
7
  80_600
12
8
  end
13
9
 
14
10
  protected
15
11
 
16
- def input_hash
17
- input_base_hash
18
- end
19
-
20
12
  def xml_hash
21
13
  xml_base_hash
22
14
  .merge(
@@ -2,21 +2,13 @@
2
2
  module Agris
3
3
  module Api
4
4
  module Messages
5
- class QueryInvoiceDocuments < QueryBase
6
- def initialize(document_references)
7
- @document_references = document_references
8
- end
9
-
5
+ class QueryInvoiceDocuments < DocumentQueryBase
10
6
  def message_number
11
7
  80_500
12
8
  end
13
9
 
14
10
  protected
15
11
 
16
- def input_hash
17
- input_base_hash
18
- end
19
-
20
12
  def xml_hash
21
13
  xml_base_hash
22
14
  .merge(
@@ -2,21 +2,13 @@
2
2
  module Agris
3
3
  module Api
4
4
  module Messages
5
- class QueryOrderDocuments < QueryBase
6
- def initialize(document_references)
7
- @document_references = document_references
8
- end
9
-
5
+ class QueryOrderDocuments < DocumentQueryBase
10
6
  def message_number
11
7
  80_900
12
8
  end
13
9
 
14
10
  protected
15
11
 
16
- def input_hash
17
- input_base_hash
18
- end
19
-
20
12
  def xml_hash
21
13
  xml_base_hash
22
14
  .merge(
@@ -2,21 +2,13 @@
2
2
  module Agris
3
3
  module Api
4
4
  module Messages
5
- class QueryPurchaseContractDocuments < QueryBase
6
- def initialize(document_references)
7
- @document_references = document_references
8
- end
9
-
5
+ class QueryPurchaseContractDocuments < DocumentQueryBase
10
6
  def message_number
11
7
  80_150
12
8
  end
13
9
 
14
10
  protected
15
11
 
16
- def input_hash
17
- input_base_hash
18
- end
19
-
20
12
  def xml_hash
21
13
  xml_base_hash
22
14
  .merge(
@@ -3,6 +3,7 @@ module Agris
3
3
  class Client
4
4
  include Api::AccountsPayables::Vouchers
5
5
  include Api::AccountsReceivables::Invoices
6
+ include Api::Grain::CommodityCodes
6
7
  include Api::Grain::PurchaseContracts
7
8
  include Api::Grain::Tickets
8
9
  include Api::Inventory::DeliveryTickets
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Agris
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
@@ -58,6 +58,10 @@ module Agris
58
58
 
59
59
  klass.new(translated_hash)
60
60
  end
61
+
62
+ def pluralized_name
63
+ "#{name.split('::').last.downcase}s"
64
+ end
61
65
  end
62
66
  end
63
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Gray
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-04-06 00:00:00.000000000 Z
12
+ date: 2018-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -109,6 +109,20 @@ dependencies:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '2.3'
112
+ - !ruby/object:Gem::Dependency
113
+ name: pry-byebug
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
112
126
  description:
113
127
  email:
114
128
  - wopr42@gmail.com
@@ -138,11 +152,14 @@ files:
138
152
  - lib/agris/api/accounts_receivables/specific_invoice_extract.rb
139
153
  - lib/agris/api/document_query_response.rb
140
154
  - lib/agris/api/grain.rb
155
+ - lib/agris/api/grain/commodity.rb
156
+ - lib/agris/api/grain/commodity_codes.rb
141
157
  - lib/agris/api/grain/contract.rb
142
158
  - lib/agris/api/grain/new_ticket.rb
143
159
  - lib/agris/api/grain/new_ticket_application.rb
144
160
  - lib/agris/api/grain/new_ticket_remark.rb
145
161
  - lib/agris/api/grain/purchase_contracts.rb
162
+ - lib/agris/api/grain/specific_commodity_code_extract.rb
146
163
  - lib/agris/api/grain/specific_purchase_contract_extract.rb
147
164
  - lib/agris/api/grain/tickets.rb
148
165
  - lib/agris/api/inventory.rb
@@ -153,6 +170,7 @@ files:
153
170
  - lib/agris/api/inventory/specific_delivery_ticket_extract.rb
154
171
  - lib/agris/api/inventory/specific_order_extract.rb
155
172
  - lib/agris/api/messages.rb
173
+ - lib/agris/api/messages/document_query_base.rb
156
174
  - lib/agris/api/messages/import.rb
157
175
  - lib/agris/api/messages/message_base.rb
158
176
  - lib/agris/api/messages/query_base.rb
@@ -160,6 +178,7 @@ files:
160
178
  - lib/agris/api/messages/query_changed_invoices.rb
161
179
  - lib/agris/api/messages/query_changed_orders.rb
162
180
  - lib/agris/api/messages/query_changed_purchase_contracts.rb
181
+ - lib/agris/api/messages/query_commodity_code_documents.rb
163
182
  - lib/agris/api/messages/query_delivery_ticket_documents.rb
164
183
  - lib/agris/api/messages/query_invoice_documents.rb
165
184
  - lib/agris/api/messages/query_order_documents.rb