payload-api 0.3.4 → 0.4.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
  SHA256:
3
- metadata.gz: 3c1b0ae0bea650ee31b523d697b18fa5823ae0178ad8bb8ada76a02c06fa4d1b
4
- data.tar.gz: f474d53fb54ac628452b82634eccd292f68a472fa0e03250c889bd35980a1ecc
3
+ metadata.gz: c6a65380dc908d716ddb1642ecb6bab391061c469ffa9951b80d3db94e84b08d
4
+ data.tar.gz: 77978473db8ca858d60db59155625b3133e5d8470fa69ff6a76ec497c086c17a
5
5
  SHA512:
6
- metadata.gz: c1141993256d880877999ca29b9564c828432e0fa924189272ed7778c7f27995394a2576967e13192b6fabed5860a630ba503290d76f18a6660b7a92638ee548
7
- data.tar.gz: 68235f8ceb1fcdd0411f608add58c038b9d9fb79edd47a9f7b72af4abe62aa3b880491849aeca9d67b24585f62ba1ae1bc4168e8dd2406d31099c86f0ae2c85c
6
+ metadata.gz: '09dce62dabb4cd5d51432adec32190ffb4b0f9a924c3794c0cef3d009c6e0d73897d9d58ca1d8417a85709ca903581fbb444ad66dab3951b27b8bf2ed0e0198d'
7
+ data.tar.gz: e2d546eef549863a7c3da77c9c6e4ddb5446fa19cc93d854de7109530cff8645a51af2bc46f6a9095bd7b629fe99f464a30848262c459d3899d91d2eddc3ff7a
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2017 RentShare (http://rentshare.com)
3
+ Copyright (c) 2024 Payload (http://payload.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Payload RubyGem
2
2
 
3
- A RubyGem for integrating [Payload](https://payload.co).
3
+ A RubyGem for integrating [Payload](https://payload.com).
4
4
 
5
5
  ## Installation
6
6
 
@@ -91,4 +91,4 @@ customers = Payload::Customer.filter_by(
91
91
  ## Documentation
92
92
 
93
93
  To get further information on Payload's RubyGem and API capabilities,
94
- visit the unabridged [Payload Documentation](https://docs.payload.co/?ruby).
94
+ visit the unabridged [Payload Documentation](https://docs.payload.com/?ruby).
@@ -85,7 +85,7 @@ module Payload
85
85
 
86
86
  class PaymentItem < ARMObject
87
87
  @spec = { 'object' => 'line_item' }
88
- @poly = { 'type' => 'payment' }
88
+ @poly = { 'entry_type' => 'payment' }
89
89
  end
90
90
 
91
91
  class PaymentActivation < ARMObject
@@ -1,3 +1,3 @@
1
1
  module Payload
2
- VERSION = '0.3.4'
2
+ VERSION = '0.4.0'
3
3
  end
data/lib/payload.rb CHANGED
@@ -3,7 +3,7 @@ require "payload/objects"
3
3
  require "payload/arm/session"
4
4
 
5
5
  module Payload
6
- @URL = "https://api.payload.co"
6
+ @URL = "https://api.payload.com"
7
7
 
8
8
  class << self
9
9
  def api_key=(value)
data/payload.gemspec CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Payload::VERSION
9
9
  spec.required_ruby_version = ">= 2.0.0"
10
10
  spec.summary = "Payload ruby library"
11
- spec.description = "A simple library to interface with the Payload API. See https://docs.payload.co for details."
11
+ spec.description = "A simple library to interface with the Payload API. See https://docs.payload.com for details."
12
12
  spec.author = "Payload"
13
13
  spec.email = "help@payload.co"
14
- spec.homepage = "https://docs.payload.co"
14
+ spec.homepage = "https://docs.payload.com"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files`.split("\n")
@@ -0,0 +1,62 @@
1
+ require "payload"
2
+ require "payload/arm/object"
3
+ require 'base64'
4
+
5
+
6
+ RSpec.describe Payload::ARMRequest do
7
+
8
+ describe "#create" do
9
+
10
+ let(:instance) { described_class.new }
11
+
12
+ context "when a payment is created for an invoice" do
13
+ it "executes the appropriate request and returns the appropriate object" do
14
+
15
+ $test_id = 'txn_' + rand(9000000...9999999).to_s
16
+
17
+ Payload::api_key = 'test_key'
18
+ instance.instance_variable_set(:@cls, Payload::Payment)
19
+
20
+ expect(instance).to receive(:_execute_request) do |http, request|
21
+ expect(request.method).to eq("POST")
22
+ expect(http.address).to eq("api.payload.com")
23
+ expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
24
+ expect(request.path).to eq("/transactions?")
25
+ expect(request.body).to eq("{\"amount\":129.0,\"customer_id\":\"acct_3bW9JMoGYQul5fCIa9f8q\",\"allocations\":[{\"entry_type\":\"payment\",\"invoice_id\":\"inv_3eNP6uf94xHTXr0rMyvZJ\"}],\"type\":\"payment\"}")
26
+
27
+ class MockResponse
28
+ def initialize
29
+ end
30
+
31
+ def code
32
+ '200'
33
+ end
34
+
35
+ def body
36
+ '{
37
+ "id": "' + $test_id + '",
38
+ "object": "transaction"
39
+ }'
40
+ end
41
+ end
42
+
43
+ MockResponse.new
44
+ end
45
+
46
+ payment = instance.create(
47
+ amount: 129.0,
48
+ customer_id: 'acct_3bW9JMoGYQul5fCIa9f8q',
49
+ allocations: [
50
+ Payload::PaymentItem.new(
51
+ invoice_id: 'inv_3eNP6uf94xHTXr0rMyvZJ'
52
+ )
53
+ ],
54
+ )
55
+
56
+ expect(payment.id).to eq($test_id)
57
+ expect(payment.object).to eq("transaction")
58
+ expect(payment.session).to eq(instance.instance_variable_get(:@session))
59
+ end
60
+ end
61
+ end
62
+ end
@@ -26,7 +26,7 @@ RSpec.describe Payload::ARMRequest do
26
26
 
27
27
  expect(instance).to receive(:_execute_request) do |http, request|
28
28
  expect(request.method).to eq("GET")
29
- expect(http.address).to eq("api.payload.co")
29
+ expect(http.address).to eq("api.payload.com")
30
30
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
31
31
  expect(request.path).to eq("/customers?fields=name%2Cage")
32
32
 
@@ -81,7 +81,7 @@ RSpec.describe Payload::ARMRequest do
81
81
 
82
82
  expect(instance).to receive(:_execute_request) do |http, request|
83
83
  expect(request.method).to eq("GET")
84
- expect(http.address).to eq("api.payload.co")
84
+ expect(http.address).to eq("api.payload.com")
85
85
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
86
86
  expect(request.path).to eq("/customers?name=John&age=30")
87
87
 
@@ -144,7 +144,7 @@ RSpec.describe Payload::ARMRequest do
144
144
 
145
145
  expect(instance).to receive(:_execute_request) do |http, request|
146
146
  expect(request.method).to eq("POST")
147
- expect(http.address).to eq("api.payload.co")
147
+ expect(http.address).to eq("api.payload.com")
148
148
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
149
149
  expect(request.path).to eq("/customers?")
150
150
  expect(request.body).to eq("{\"type\":\"bill\",\"processing_id\":\"acct_3bz0zU99AX06SJwfMmfn0\",\"due_date\":\"2020-01-01\",\"items\":[{\"entry_type\":\"charge\",\"type\":\"item1\",\"amount\":29.99}],\"customer_id\":\"acct_3bW9JMoGYQul5fCIa9f8q\"}")
@@ -198,7 +198,7 @@ RSpec.describe Payload::ARMRequest do
198
198
 
199
199
  expect(instance).to receive(:_execute_request) do |http, request|
200
200
  expect(request.method).to eq("POST")
201
- expect(http.address).to eq("api.payload.co")
201
+ expect(http.address).to eq("api.payload.com")
202
202
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
203
203
  expect(request.path).to eq("/customers?")
204
204
  expect(request.body).to eq("{\"object\":\"list\",\"values\":[{\"name\":\"John\",\"age\":30},{\"name\":\"Alice\",\"age\":25},{\"name\":\"Bob\",\"age\":35}]}")
@@ -255,7 +255,7 @@ RSpec.describe Payload::ARMRequest do
255
255
 
256
256
  expect(instance).to receive(:_execute_request) do |http, request|
257
257
  expect(request.method).to eq("POST")
258
- expect(http.address).to eq("api.payload.co")
258
+ expect(http.address).to eq("api.payload.com")
259
259
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
260
260
  expect(request.path).to eq("/customers?")
261
261
  expect(request.body).to eq("{\"object\":\"list\",\"values\":[{\"name\":\"John\",\"age\":30},{\"name\":\"Alice\",\"age\":25},{\"name\":\"Bob\",\"age\":35}]}")
@@ -316,7 +316,7 @@ RSpec.describe Payload::ARMRequest do
316
316
 
317
317
  expect(instance).to receive(:_execute_request) do |http, request|
318
318
  expect(request.method).to eq("GET")
319
- expect(http.address).to eq("api.payload.co")
319
+ expect(http.address).to eq("api.payload.com")
320
320
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
321
321
  expect(request.path).to eq("/customers/" + $test_id + "?")
322
322
 
@@ -362,7 +362,7 @@ RSpec.describe Payload::ARMRequest do
362
362
 
363
363
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
364
364
  expect(request.method).to eq("PUT")
365
- expect(http.address).to eq("api.payload.co")
365
+ expect(http.address).to eq("api.payload.com")
366
366
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
367
367
  expect(request.path).to eq("/customers/" + $test_id + "?")
368
368
  expect(request.body).to eq("{\"name\":\"John\",\"age\":30}")
@@ -400,14 +400,14 @@ RSpec.describe Payload::ARMRequest do
400
400
  $test_id = 'acct_' + rand(9000000...9999999).to_s
401
401
 
402
402
  Payload::api_key = 'test_key'
403
- instance = Payload::Session.new('session_key', 'https://sandbox.payload.co')
403
+ instance = Payload::Session.new('session_key', 'https://sandbox.payload.com')
404
404
 
405
405
  cust = Payload::Customer.new({id: $test_id})
406
406
  cust.set_session(instance)
407
407
 
408
408
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
409
409
  expect(request.method).to eq("PUT")
410
- expect(http.address).to eq("sandbox.payload.co")
410
+ expect(http.address).to eq("sandbox.payload.com")
411
411
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('session_key')
412
412
  expect(request.path).to eq("/customers/" + $test_id + "?")
413
413
  expect(request.body).to eq("{\"name\":\"John\",\"age\":30}")
@@ -448,7 +448,7 @@ RSpec.describe Payload::ARMRequest do
448
448
 
449
449
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
450
450
  expect(request.method).to eq("PUT")
451
- expect(http.address).to eq("api.payload.co")
451
+ expect(http.address).to eq("api.payload.com")
452
452
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
453
453
  expect(request.path).to eq("/customers?")
454
454
  expect(request.body).to eq("{\"object\":\"list\",\"values\":[{\"name\":\"John\",\"age\":30,\"id\":\"" + $test_id_a + "\"},{\"name\":\"Alice\",\"age\":25,\"id\":\"" + $test_id_b + "\"},{\"name\":\"Bob\",\"age\":35,\"id\":\"" + $test_id_c + "\"}]}")
@@ -509,7 +509,7 @@ RSpec.describe Payload::ARMRequest do
509
509
 
510
510
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
511
511
  expect(request.method).to eq("PUT")
512
- expect(http.address).to eq("api.payload.co")
512
+ expect(http.address).to eq("api.payload.com")
513
513
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
514
514
  expect(request.path).to eq("/customers?name=John+Smith&mode=query")
515
515
  expect(request.body).to eq("{\"name\":\"John\",\"age\":30}")
@@ -562,7 +562,7 @@ RSpec.describe Payload::ARMRequest do
562
562
 
563
563
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
564
564
  expect(request.method).to eq("DELETE")
565
- expect(http.address).to eq("api.payload.co")
565
+ expect(http.address).to eq("api.payload.com")
566
566
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
567
567
  expect(request.path).to eq("/customers/" + $test_id + "?")
568
568
  expect(request.body).to eq(nil)
@@ -600,14 +600,14 @@ RSpec.describe Payload::ARMRequest do
600
600
  $test_id = 'acct_' + rand(9000000...9999999).to_s
601
601
 
602
602
  Payload::api_key = 'test_key'
603
- instance = Payload::Session.new('session_key', 'https://sandbox.payload.co')
603
+ instance = Payload::Session.new('session_key', 'https://sandbox.payload.com')
604
604
 
605
605
  cust = Payload::Customer.new({id: $test_id})
606
606
  cust.set_session(instance)
607
607
 
608
608
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
609
609
  expect(request.method).to eq("DELETE")
610
- expect(http.address).to eq("sandbox.payload.co")
610
+ expect(http.address).to eq("sandbox.payload.com")
611
611
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('session_key')
612
612
  expect(request.path).to eq("/customers/" + $test_id + "?")
613
613
  expect(request.body).to eq(nil)
@@ -648,7 +648,7 @@ RSpec.describe Payload::ARMRequest do
648
648
 
649
649
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
650
650
  expect(request.method).to eq("DELETE")
651
- expect(http.address).to eq("api.payload.co")
651
+ expect(http.address).to eq("api.payload.com")
652
652
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
653
653
  expect(request.path).to eq("/customers?")
654
654
  expect(request.body).to eq("{\"object\":\"list\",\"values\":[{\"id\":\"" + $test_id_a + "\"},{\"id\":\"" + $test_id_b + "\"},{\"id\":\"" + $test_id_c + "\"}]}")
@@ -711,7 +711,7 @@ RSpec.describe Payload::ARMRequest do
711
711
 
712
712
  expect_any_instance_of(Payload::ARMRequest).to receive(:_execute_request) do |inst, http, request|
713
713
  expect(request.method).to eq("DELETE")
714
- expect(http.address).to eq("api.payload.co")
714
+ expect(http.address).to eq("api.payload.com")
715
715
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
716
716
  expect(request.path).to eq("/customers?name=John+Smith&mode=query")
717
717
  expect(request.body).to eq(nil)
@@ -759,4 +759,4 @@ RSpec.describe Payload::ARMRequest do
759
759
  end
760
760
  end
761
761
  end
762
- end
762
+ end
@@ -10,7 +10,7 @@ RSpec.describe Payload::Session do
10
10
 
11
11
  it "sets the api key and uses default url" do
12
12
  expect(instance1.api_key).to eq('test_key')
13
- expect(instance1.api_url).to eq('https://api.payload.co')
13
+ expect(instance1.api_url).to eq('https://api.payload.com')
14
14
  end
15
15
  end
16
16
 
@@ -32,7 +32,7 @@ RSpec.describe Payload::Session do
32
32
  $test_id = 'acct_' + rand(9000000...9999999).to_s
33
33
 
34
34
  Payload::api_key = 'test_key'
35
- instance = Payload::Session.new('session_key', 'https://sandbox.payload.co')
35
+ instance = Payload::Session.new('session_key', 'https://sandbox.payload.com')
36
36
 
37
37
  arm_request = instance.query(Payload::Customer)
38
38
 
@@ -41,7 +41,7 @@ RSpec.describe Payload::Session do
41
41
 
42
42
  expect(arm_request).to receive(:_execute_request) do |http, request|
43
43
  expect(request.method).to eq("GET")
44
- expect(http.address).to eq("sandbox.payload.co")
44
+ expect(http.address).to eq("sandbox.payload.com")
45
45
  expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('session_key')
46
46
  expect(request.path).to eq("/customers?fields=name%2Cage")
47
47
 
@@ -88,7 +88,7 @@ RSpec.describe Payload::Session do
88
88
 
89
89
  it "builds the appropriate ARMRequest" do
90
90
  Payload::api_key = 'test_key'
91
- instance = Payload::Session.new('session_key', 'https://sandbox.payload.co')
91
+ instance = Payload::Session.new('session_key', 'https://sandbox.payload.com')
92
92
 
93
93
  cust = Payload::Customer.new({})
94
94
 
@@ -108,7 +108,7 @@ RSpec.describe Payload::Session do
108
108
 
109
109
  it "builds the appropriate ARMRequest" do
110
110
  Payload::api_key = 'test_key'
111
- instance = Payload::Session.new('session_key', 'https://sandbox.payload.co')
111
+ instance = Payload::Session.new('session_key', 'https://sandbox.payload.com')
112
112
 
113
113
  cust = Payload::Customer.new({})
114
114
 
@@ -128,7 +128,7 @@ RSpec.describe Payload::Session do
128
128
 
129
129
  it "builds the appropriate ARMRequest" do
130
130
  Payload::api_key = 'test_key'
131
- instance = Payload::Session.new('session_key', 'https://sandbox.payload.co')
131
+ instance = Payload::Session.new('session_key', 'https://sandbox.payload.com')
132
132
 
133
133
  cust = Payload::Customer.new({})
134
134
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payload-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Payload
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-10 00:00:00.000000000 Z
11
+ date: 2024-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A simple library to interface with the Payload API. See https://docs.payload.co
13
+ description: A simple library to interface with the Payload API. See https://docs.payload.com
14
14
  for details.
15
15
  email: help@payload.co
16
16
  executables: []
@@ -18,7 +18,7 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".github/workflows/publish.yml"
21
- - ".github/workflows/ruby-app.yml"
21
+ - ".github/workflows/test.yml"
22
22
  - LICENSE
23
23
  - README.md
24
24
  - lib/payload.rb
@@ -30,9 +30,10 @@ files:
30
30
  - lib/payload/utils.rb
31
31
  - lib/payload/version.rb
32
32
  - payload.gemspec
33
+ - spec/objects/payment_spec.rb
33
34
  - spec/payload/arm/request_spec.rb
34
35
  - spec/payload/arm/session_spec.rb
35
- homepage: https://docs.payload.co
36
+ homepage: https://docs.payload.com
36
37
  licenses:
37
38
  - MIT
38
39
  metadata: {}
File without changes