paycargo 0.1.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.
@@ -0,0 +1,51 @@
1
+ module Paycargo
2
+ class Resource
3
+ attr_reader :client
4
+
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ def get_request(url, params: {}, headers: {})
10
+ handle_response client.connection.get(url, params, default_headers.merge(headers))
11
+ end
12
+
13
+ def post_request(url, body:, headers: {})
14
+ handle_response client.connection.post(url, body, default_headers.merge(headers))
15
+ end
16
+
17
+ def patch_request(url, body:, headers: {})
18
+ handle_response client.connection.patch(url, body, default_headers.merge(headers))
19
+ end
20
+
21
+ def put_request(url, body:, headers: {})
22
+ handle_response client.connection.put(url, body, default_headers.merge(headers))
23
+ end
24
+
25
+ def delete_request(url, params: {}, headers: {})
26
+ handle_response client.connection.delete(url, params, default_headers.merge(headers))
27
+ end
28
+
29
+ def default_headers
30
+ { authorization: client.token }
31
+ end
32
+
33
+ def handle_response(response)
34
+ #message = response.body["message"]
35
+
36
+ case response.status
37
+ when 401
38
+ raise Error, "#{response.body}"
39
+ when 404
40
+ raise Error, "#{response.body}"
41
+ when 429
42
+ raise Error, "#{response.body}"
43
+ when 500
44
+ raise Error, "#{response.body}"
45
+ end
46
+
47
+ response
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ module Paycargo
2
+ class PayerResource < Resource
3
+
4
+ # This endpoint retrieves the following data, per payer, per payment method:
5
+ # - get funds availability
6
+ # - get funds limit
7
+ def funds(id)
8
+ get_request("payer/funds/#{id}").body
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,34 @@
1
+ module Paycargo
2
+ class ReportsResource < Resource
3
+
4
+ #Get Payer ACH Report
5
+ # PARAMS
6
+ #- fleet_id: 283046
7
+ #- Account fleet id ( payerId)
8
+
9
+ #- startDate: 10/01/2020
10
+ #Start Date in MM/DD/YYYY format
11
+
12
+ #- endDate: 11/01/2020
13
+ #End Date in MM/DD/YYYY format
14
+
15
+ #- client_id: 284347
16
+ #Account client id
17
+
18
+ #- report_action_name: getACHReconciliation
19
+ #PayCargo report type name, for ACH report : getACHReconciliation
20
+
21
+ #- type: SHIPPER
22
+ #Account type : SHIPPER or CARRIER
23
+
24
+ #- accountName: all
25
+ #- Account name of branch if any. Apply "all" to get data from branches for HQ
26
+
27
+ #- fleetLimit: fleet_id
28
+ #- providerLimit: provier_id
29
+ def payer(**params)
30
+ get_request("reports/singleReport", params: params).body
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,71 @@
1
+ module Paycargo
2
+ class TransactionsResource < Resource
3
+
4
+ #GET all Transactions for a client.
5
+ #PARAMS
6
+ #- page
7
+ #- count
8
+ def list(**params)
9
+ Collection.from_response get_request("transactions", params: params), type: Transaction
10
+ end
11
+
12
+ #GET a transaction by id (must update token)
13
+ def retreive(id, **params)
14
+ Transaction.new get_request("transaction/#{id}", params: params).body
15
+ end
16
+
17
+ #POSTing a new transaction
18
+ #BODY
19
+ #- payerId: 281302
20
+ #- vendorId: 279546
21
+ #- type: Other
22
+ #- subcategory: I-432188
23
+ #- number: 929-83294551
24
+ #- departureDate: 2018-04-01
25
+ #- arrivalDate: 2018-04-24
26
+ #- total: 100
27
+ #- notes: This is a test for paycargo credit new flow
28
+ #- userId: 778042
29
+ #- direction: Outbound
30
+ #- parent: dsgfdg
31
+ #- paymentDueDate: 2018-04-24
32
+ #- hasArrived: Y
33
+ #- customerRefNumber: 63045050500000
34
+ #- shipperRefNumber: tdfgfdgfd
35
+ #- paymentType: PAYCARGO_CREDIT
36
+ def create(**attributes)
37
+ Transaction.new post_request("transaction", body: attributes).body
38
+ end
39
+
40
+ #PUT Approve a Transaction
41
+ def approve(id)
42
+ Transaction.new put_request("transaction/pay/#{id}").body
43
+ end
44
+
45
+ #Proof Transaction
46
+ #PUTing a transaction to 'proof'
47
+ def proof(id)
48
+ Transaction.new put_request("transaction/proof/#{id}").body
49
+ end
50
+
51
+ #GETs a transaction by number (must update token)
52
+ #PARAMS
53
+ #- number
54
+ #- vendorId
55
+ def by_number(**params)
56
+ Transaction.new get_request("transaction/number/", params: params).body
57
+ end
58
+
59
+ #GETing a transaction's history
60
+ def history(id, **params)
61
+ get_request("transaction/history/#{id}", params: params).body
62
+ end
63
+
64
+ #Get Fees for transaction. paymentType and transactionId OR paymentType
65
+ #and vendorId and payerId are required to getFees
66
+ def fees(**params)
67
+ get_request("transaction/fees", params: params).body
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paycargo
4
+ VERSION = "0.1.0"
5
+ end
data/lib/paycargo.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "paycargo/version"
4
+
5
+ module Paycargo
6
+ autoload :Client, "paycargo/client"
7
+ autoload :Collection, "paycargo/collection"
8
+ autoload :Error, "paycargo/error"
9
+ autoload :Object, "paycargo/object"
10
+ autoload :Resource, "paycargo/resource"
11
+
12
+ autoload :TransactionsResource, "paycargo/resources/transactions"
13
+ autoload :PayerResource, "paycargo/resources/payer"
14
+ autoload :ReportsResource, "paycargo/resources/reports"
15
+
16
+ autoload :Transaction, "paycargo/objects/transaction.rb"
17
+ autoload :Payer, "paycargo/objects/payer.rb"
18
+ autoload :Report, "paycargo/objects/report.rb"
19
+ end
data/sig/paycargo.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Paycargo
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paycargo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jose Perez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.14.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.14.0
41
+ description: Ruby wrapper library for Paycargo's API.
42
+ email:
43
+ - jose.perez@vertilux.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - CHANGELOG.md
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.org
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - docs/index.html
59
+ - docs/style.css
60
+ - lib/paycargo.rb
61
+ - lib/paycargo/client.rb
62
+ - lib/paycargo/collection.rb
63
+ - lib/paycargo/error.rb
64
+ - lib/paycargo/object.rb
65
+ - lib/paycargo/objects/payer.rb
66
+ - lib/paycargo/objects/report.rb
67
+ - lib/paycargo/objects/transaction.rb
68
+ - lib/paycargo/resource.rb
69
+ - lib/paycargo/resources/payer.rb
70
+ - lib/paycargo/resources/reports.rb
71
+ - lib/paycargo/resources/transactions.rb
72
+ - lib/paycargo/version.rb
73
+ - sig/paycargo.rbs
74
+ homepage: https://lepepe.github.io/paycargo
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ homepage_uri: https://lepepe.github.io/paycargo
80
+ source_code_uri: https://lepepe.github.io/paycargo
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.6.0
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.3.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Ruby wrapper library for Paycargo's API.
100
+ test_files: []