cin7_api 1.0.3 → 1.0.4

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
  SHA256:
3
- metadata.gz: 00aa61f9aba5bdaed71770a08bf215e94cc7dded390dcf68c04b175d672e359b
4
- data.tar.gz: cf3b16f9e72f5f213c2b6a9fc6cab2517354ca238eea1af5afd24b3da02f2a82
3
+ metadata.gz: def4242ec47be664686584c99a2375d3c349c3e30410caac8e42a0ae2ad24089
4
+ data.tar.gz: f71f8db45c6efec4c24252c9a5ee25050bc79b9626f64787213d68c6625807ce
5
5
  SHA512:
6
- metadata.gz: ef12eed82b1d6ffdfdbcf6881d5fd83b91552df444d4b016008253b8763e4cd893f101175e474d85b62196e16422211f0d0c89490f2b7d17171f803f7ffd2e0a
7
- data.tar.gz: 89e8c1b6f97614e2914bcc89e049a7e3273625e4e785be2a44a9c8a529504fd0a4e51e326f51c7aaba491c8f3e7462b438f1ce9c71e87bb191ec4886040ecef3
6
+ metadata.gz: 2e0bc2731ab0ec35e5d45efa3d748310b27833ccdaf76490a8272858608da8143db299119841d1a4b03e1ea36799e09e2a483aea15fd187857c76c77e5a15c47
7
+ data.tar.gz: bb2e02999a87823610ffc55037a6c1ad06752bdd9df89be4c2d35046f956d1605f9e1856d1a8e2b917d13ef5105231f89d807fc9c9fff734543503e80ace8621
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cin7_api (1.0.2)
4
+ cin7_api (1.0.4)
5
5
  activesupport
6
6
  faraday (~> 2.5)
7
7
  zeitwerk
@@ -19,10 +19,10 @@ GEM
19
19
  concurrent-ruby (1.1.10)
20
20
  diff-lcs (1.5.0)
21
21
  dotenv (2.8.1)
22
- faraday (2.5.2)
22
+ faraday (2.6.0)
23
23
  faraday-net_http (>= 2.0, < 3.1)
24
24
  ruby2_keywords (>= 0.0.4)
25
- faraday-net_http (3.0.0)
25
+ faraday-net_http (3.0.1)
26
26
  i18n (1.12.0)
27
27
  concurrent-ruby (~> 1.0)
28
28
  json (2.6.2)
@@ -69,7 +69,7 @@ GEM
69
69
  concurrent-ruby (~> 1.0)
70
70
  unicode-display_width (2.3.0)
71
71
  vcr (6.1.0)
72
- zeitwerk (2.6.0)
72
+ zeitwerk (2.6.1)
73
73
 
74
74
  PLATFORMS
75
75
  x86_64-darwin-21
@@ -2,20 +2,19 @@
2
2
 
3
3
  module Cin7API
4
4
  class CreditNoteResource < Resource
5
- # NOTE: Cin7 is doing a binary OR check for the filter params
6
5
  # @client.credit_note.where(sales_reference: "#1050", email: "postco360@example.com")
7
6
  def where(**params)
8
- credit_notes = get_request("CreditNotes", params: params).body
9
- credit_notes.map { |attributes| CreditNote.new(attributes) }
7
+ response_body = get_request("CreditNotes", params: params).body
8
+ credit_notes = response_body.map { |attributes| CreditNote.new(attributes) }
9
+ # Doing a filter here because Cin7 is doing a binary OR check for the filter params
10
+ credit_notes.filter do |credit_note|
11
+ params.reduce(true) { |acc, (key, value)| acc && credit_note[key] == value }
12
+ end
10
13
  end
11
14
 
12
15
  # @client.credit_note.find_by(sales_reference: "#1050", email: "postco360@example.com")
13
16
  def find_by(**params)
14
- credit_note =
15
- where(**params).find do |p|
16
- params.reduce(true) { |acc, (key, value)| acc && p[key] == value }
17
- end
18
- credit_note ? CreditNote.new(credit_note) : nil
17
+ where(**params).first
19
18
  end
20
19
 
21
20
  # @client.credit_note.find(2223)
@@ -2,19 +2,19 @@
2
2
 
3
3
  module Cin7API
4
4
  class PaymentResource < Resource
5
- # @client.payment.where(order_id: 2223)
5
+ # @client.payment.where(order_id: 2223, order_ref: "CRN-2223")
6
6
  def where(**params)
7
- payments = get_request("Payments", params: params).body
8
- payments.map { |attributes| Payment.new(attributes) }
7
+ response_body = get_request("Payments", params: params).body
8
+ payments = response_body.map { |attributes| Payment.new(attributes) }
9
+ # Doing a filter here because Cin7 is doing a binary OR check for the filter params
10
+ payments.filter do |payment|
11
+ params.reduce(true) { |acc, (key, value)| acc && payment[key] == value }
12
+ end
9
13
  end
10
14
 
11
15
  # @client.payment.find_by(order_id: 2223, order_ref: "CRN-2223")
12
16
  def find_by(**params)
13
- payment =
14
- where(**params).find do |p|
15
- params.reduce(true) { |acc, (key, value)| acc && p[key] == value }
16
- end
17
- payment.present? ? payment : nil
17
+ where(**params).first
18
18
  end
19
19
 
20
20
  # @client.payment.find(698)
@@ -2,20 +2,19 @@
2
2
 
3
3
  module Cin7API
4
4
  class SalesOrderResource < Resource
5
- # NOTE: Cin7 is doing a binary OR check for the filter params
6
5
  # @client.sales_order.where(reference: "#1050", email: "postco360@example.com")
7
6
  def where(**params)
8
- sales_orders = get_request("SalesOrders", params: params).body
9
- sales_orders.map { |attributes| SalesOrder.new(attributes) }
7
+ response_body = get_request("SalesOrders", params: params).body
8
+ sales_orders = response_body.map { |attributes| SalesOrder.new(attributes) }
9
+ # Doing a filter here because Cin7 is doing a binary OR check for the filter params
10
+ sales_orders.filter do |sales_order|
11
+ params.reduce(true) { |acc, (key, value)| acc && sales_order[key] == value }
12
+ end
10
13
  end
11
14
 
12
15
  # @client.sales_order.find_by(reference: "#1050", email: "postco360@example.com")
13
16
  def find_by(**params)
14
- sales_order =
15
- where(**params).find do |p|
16
- params.reduce(true) { |acc, (key, value)| acc && p[key] == value }
17
- end
18
- sales_order ? SalesOrder.new(sales_order) : nil
17
+ where(**params).first
19
18
  end
20
19
 
21
20
  # @client.sales_order.find(2218)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cin7API
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cin7_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wei Zhe Heng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-23 00:00:00.000000000 Z
11
+ date: 2022-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport