mollie-api-ruby 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +10 -0
  3. data/.rubocop_todo.yml +92 -0
  4. data/.travis.yml +3 -1
  5. data/CHANGELOG.md +1 -1
  6. data/Gemfile +1 -1
  7. data/Rakefile +1 -2
  8. data/bin/console +4 -4
  9. data/docs/migration_v2_2_x.md +1 -1
  10. data/docs/migration_v3_x.md +2 -2
  11. data/examples/chargebacks/get.rb +2 -2
  12. data/examples/customers/create-payment.rb +4 -4
  13. data/examples/customers/create.rb +3 -3
  14. data/examples/customers/delete.rb +1 -1
  15. data/examples/customers/get.rb +1 -1
  16. data/examples/customers/list-payments.rb +1 -1
  17. data/examples/customers/update.rb +2 -2
  18. data/examples/invoices/get.rb +1 -1
  19. data/examples/mandates/create.rb +7 -7
  20. data/examples/mandates/delete.rb +1 -1
  21. data/examples/mandates/get.rb +1 -1
  22. data/examples/mandates/list.rb +1 -1
  23. data/examples/methods/get.rb +2 -2
  24. data/examples/organisations/get.rb +1 -1
  25. data/examples/payments/delete.rb +1 -1
  26. data/examples/payments/get-customer.rb +1 -1
  27. data/examples/payments/get-mandate.rb +1 -1
  28. data/examples/payments/get-settlement.rb +1 -1
  29. data/examples/payments/get-subscription.rb +1 -1
  30. data/examples/payments/get.rb +1 -1
  31. data/examples/payments/webhook.rb +1 -1
  32. data/examples/permissions/get.rb +1 -1
  33. data/examples/profiles/create.rb +6 -6
  34. data/examples/profiles/delete.rb +1 -1
  35. data/examples/profiles/get.rb +1 -1
  36. data/examples/profiles/list-chargebacks.rb +1 -1
  37. data/examples/profiles/list-methods.rb +1 -1
  38. data/examples/profiles/list-payments.rb +1 -1
  39. data/examples/profiles/list-refunds.rb +1 -1
  40. data/examples/profiles/update.rb +3 -3
  41. data/examples/refunds/create.rb +3 -3
  42. data/examples/refunds/delete.rb +2 -2
  43. data/examples/refunds/get.rb +2 -2
  44. data/examples/settlements/get.rb +1 -1
  45. data/examples/settlements/list-chargebacks.rb +1 -1
  46. data/examples/settlements/list-payments.rb +1 -1
  47. data/examples/settlements/list-refunds.rb +1 -1
  48. data/examples/subscriptions/create.rb +5 -5
  49. data/examples/subscriptions/delete.rb +2 -2
  50. data/examples/subscriptions/get.rb +2 -2
  51. data/examples/subscriptions/list.rb +1 -1
  52. data/examples/subscriptions/update.rb +1 -1
  53. data/lib/cacert.pem +2 -26
  54. data/lib/mollie.rb +0 -1
  55. data/lib/mollie/amount.rb +1 -1
  56. data/lib/mollie/base.rb +8 -8
  57. data/lib/mollie/chargeback.rb +12 -6
  58. data/lib/mollie/client.rb +17 -17
  59. data/lib/mollie/customer/mandate.rb +10 -6
  60. data/lib/mollie/customer/subscription.rb +15 -7
  61. data/lib/mollie/exception.rb +1 -1
  62. data/lib/mollie/invoice.rb +14 -6
  63. data/lib/mollie/list.rb +9 -13
  64. data/lib/mollie/method.rb +15 -15
  65. data/lib/mollie/organization.rb +1 -1
  66. data/lib/mollie/payment.rb +36 -16
  67. data/lib/mollie/permission.rb +18 -17
  68. data/lib/mollie/profile.rb +11 -7
  69. data/lib/mollie/refund.rb +12 -8
  70. data/lib/mollie/settlement.rb +17 -9
  71. data/lib/mollie/util.rb +8 -8
  72. data/lib/mollie/version.rb +1 -1
  73. data/mollie-api-ruby.gemspec +5 -4
  74. data/test/helper.rb +1 -1
  75. data/test/mollie/amount_test.rb +1 -1
  76. data/test/mollie/base_test.rb +72 -72
  77. data/test/mollie/chargeback_test.rb +36 -37
  78. data/test/mollie/client_test.rb +49 -49
  79. data/test/mollie/customer/mandate_test.rb +40 -40
  80. data/test/mollie/customer/payment_test.rb +5 -6
  81. data/test/mollie/customer/subscription_test.rb +45 -45
  82. data/test/mollie/customer_test.rb +12 -12
  83. data/test/mollie/invoice_test.rb +29 -29
  84. data/test/mollie/list_test.rb +23 -23
  85. data/test/mollie/method_test.rb +8 -8
  86. data/test/mollie/organization_test.rb +9 -9
  87. data/test/mollie/payment/chargeback_test.rb +4 -4
  88. data/test/mollie/payment/refund_test.rb +4 -4
  89. data/test/mollie/payment_test.rb +111 -111
  90. data/test/mollie/profile_test.rb +41 -42
  91. data/test/mollie/refund_test.rb +39 -39
  92. data/test/mollie/settlement/chargeback_test.rb +4 -4
  93. data/test/mollie/settlement/payment_test.rb +5 -5
  94. data/test/mollie/settlement/refund_test.rb +4 -4
  95. data/test/mollie/settlement_test.rb +53 -53
  96. data/test/mollie/util_test.rb +9 -11
  97. data/test/run-test.rb +4 -4
  98. metadata +46 -30
@@ -1,4 +1,4 @@
1
1
  subscription = Mollie::Customer::Subscription.get(
2
- "sub_rVKGtNd6s3",
3
- customer_id: "cst_5a2pPrwaWy"
2
+ 'sub_rVKGtNd6s3',
3
+ customer_id: 'cst_5a2pPrwaWy'
4
4
  )
@@ -1 +1 @@
1
- subscriptions = Mollie::Customer::Subscription.all(customer_id: "cst_5a2pPrwaWy")
1
+ subscriptions = Mollie::Customer::Subscription.all(customer_id: 'cst_5a2pPrwaWy')
@@ -1,5 +1,5 @@
1
1
  subscription = Mollie::Customer::Subscription.update(
2
2
  'sub_rVKGtNd6s3',
3
- customer_id: 'cst_5a2pPrwaWy'
3
+ customer_id: 'cst_5a2pPrwaWy',
4
4
  amount: { value: '20.00', currency: 'EUR' }
5
5
  )
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Bundle of CA Root Certificates
3
3
  ##
4
- ## Certificate data from Mozilla as of: Fri Jun 1 09:01:33 2018 GMT
4
+ ## Certificate data from Mozilla as of: Tue Sep 4 09:47:40 2018 GMT
5
5
  ##
6
6
  ## This is a bundle of X.509 certificates of public Certificate Authorities
7
7
  ## (CA). These were automatically extracted from Mozilla's root certificates
@@ -14,7 +14,7 @@
14
14
  ## Just configure this file as the SSLCACertificateFile.
15
15
  ##
16
16
  ## Conversion done with mk-ca-bundle.pl version 1.27.
17
- ## SHA256: 704f02707ec6b4c4a7597a8c6039b020def11e64f3ef0605a9c3543d48038a57
17
+ ## SHA256: c80f571d9f4ebca4a91e0ad3a546f263153d71afffc845c6f8f52ce9d1a2e8ec
18
18
  ##
19
19
 
20
20
 
@@ -2635,30 +2635,6 @@ kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
2635
2635
  ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
2636
2636
  -----END CERTIFICATE-----
2637
2637
 
2638
- TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5
2639
- ====================================================
2640
- -----BEGIN CERTIFICATE-----
2641
- MIIEJzCCAw+gAwIBAgIHAI4X/iQggTANBgkqhkiG9w0BAQsFADCBsTELMAkGA1UEBhMCVFIxDzAN
2642
- BgNVBAcMBkFua2FyYTFNMEsGA1UECgxEVMOcUktUUlVTVCBCaWxnaSDEsGxldGnFn2ltIHZlIEJp
2643
- bGnFn2ltIEfDvHZlbmxpxJ9pIEhpem1ldGxlcmkgQS7Fni4xQjBABgNVBAMMOVTDnFJLVFJVU1Qg
2644
- RWxla3Ryb25payBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsSBINTAeFw0xMzA0MzAw
2645
- ODA3MDFaFw0yMzA0MjgwODA3MDFaMIGxMQswCQYDVQQGEwJUUjEPMA0GA1UEBwwGQW5rYXJhMU0w
2646
- SwYDVQQKDERUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnE
2647
- n2kgSGl6bWV0bGVyaSBBLsWeLjFCMEAGA1UEAww5VMOcUktUUlVTVCBFbGVrdHJvbmlrIFNlcnRp
2648
- ZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxIEg1MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
2649
- CgKCAQEApCUZ4WWe60ghUEoI5RHwWrom/4NZzkQqL/7hzmAD/I0Dpe3/a6i6zDQGn1k19uwsu537
2650
- jVJp45wnEFPzpALFp/kRGml1bsMdi9GYjZOHp3GXDSHHmflS0yxjXVW86B8BSLlg/kJK9siArs1m
2651
- ep5Fimh34khon6La8eHBEJ/rPCmBp+EyCNSgBbGM+42WAA4+Jd9ThiI7/PS98wl+d+yG6w8z5UNP
2652
- 9FR1bSmZLmZaQ9/LXMrI5Tjxfjs1nQ/0xVqhzPMggCTTV+wVunUlm+hkS7M0hO8EuPbJbKoCPrZV
2653
- 4jI3X/xml1/N1p7HIL9Nxqw/dV8c7TKcfGkAaZHjIxhT6QIDAQABo0IwQDAdBgNVHQ4EFgQUVpkH
2654
- HtOsDGlktAxQR95DLL4gwPswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
2655
- hvcNAQELBQADggEBAJ5FdnsXSDLyOIspve6WSk6BGLFRRyDN0GSxDsnZAdkJzsiZ3GglE9Rc8qPo
2656
- BP5yCccLqh0lVX6Wmle3usURehnmp349hQ71+S4pL+f5bFgWV1Al9j4uPqrtd3GqqpmWRgqujuwq
2657
- URawXs3qZwQcWDD1YIq9pr1N5Za0/EKJAWv2cMhQOQwt1WbZyNKzMrcbGW3LM/nfpeYVhDfwwvJl
2658
- lpKQd/Ct9JDpEXjXk4nAPQu6KfTomZ1yju2dL+6SfaHx/126M2CFYv4HAqGEVka+lgqaE9chTLd8
2659
- B59OTj+RdPsnnRHM3eaxynFNExc5JsUpISuTKWqW+qtB4Uu2NQvAmxU=
2660
- -----END CERTIFICATE-----
2661
-
2662
2638
  Certinomis - Root CA
2663
2639
  ====================
2664
2640
  -----BEGIN CERTIFICATE-----
@@ -5,7 +5,6 @@ require 'bigdecimal'
5
5
  require 'net/https'
6
6
 
7
7
  module Mollie
8
-
9
8
  end
10
9
 
11
10
  require 'mollie/exception'
@@ -7,7 +7,7 @@ module Mollie
7
7
  end
8
8
 
9
9
  def value=(val)
10
- @value = BigDecimal.new(val.to_s)
10
+ @value = BigDecimal(val.to_s)
11
11
  end
12
12
 
13
13
  def to_h
@@ -15,7 +15,7 @@ module Mollie
15
15
 
16
16
  class << self
17
17
  def create(data = {})
18
- request("POST", nil, data) do |response|
18
+ request('POST', nil, data) do |response|
19
19
  new(response)
20
20
  end
21
21
  end
@@ -24,25 +24,25 @@ module Mollie
24
24
  id = nil
25
25
  data = {}
26
26
 
27
- request("GET", id, data, options) do |response|
27
+ request('GET', id, data, options) do |response|
28
28
  Mollie::List.new(response, self)
29
29
  end
30
30
  end
31
31
 
32
32
  def get(id, options = {})
33
- request("GET", id, {}, options) do |response|
33
+ request('GET', id, {}, options) do |response|
34
34
  new(response)
35
35
  end
36
36
  end
37
37
 
38
38
  def update(id, data = {})
39
- request("PATCH", id, data) do |response|
39
+ request('PATCH', id, data) do |response|
40
40
  new(response)
41
41
  end
42
42
  end
43
43
 
44
44
  def delete(id, options = {})
45
- request("DELETE", id, options)
45
+ request('DELETE', id, options)
46
46
  end
47
47
 
48
48
  def request(method, id = 0, data = {}, options = {})
@@ -52,15 +52,15 @@ module Mollie
52
52
  end
53
53
 
54
54
  def id_param
55
- "#{name.downcase.split("::")[-1]}_id".to_sym
55
+ "#{name.downcase.split('::')[-1]}_id".to_sym
56
56
  end
57
57
 
58
58
  def parent_id
59
- "#{name.downcase.split("::")[-2]}_id".to_sym
59
+ "#{name.downcase.split('::')[-2]}_id".to_sym
60
60
  end
61
61
 
62
62
  def resource_name(parent_id = nil)
63
- path = name.downcase.split("::").slice(1..-1).map(&Util.method(:pluralize))
63
+ path = name.downcase.split('::').slice(1..-1).map(&Util.method(:pluralize))
64
64
 
65
65
  if path.size == 2 && parent_id
66
66
  path.join("/#{parent_id}/")
@@ -1,6 +1,5 @@
1
1
  module Mollie
2
2
  class Chargeback < Base
3
-
4
3
  attr_accessor :id,
5
4
  :payment,
6
5
  :amount,
@@ -10,18 +9,26 @@ module Mollie
10
9
  :reversed_at,
11
10
  :_links
12
11
 
13
- alias_method :links, :_links
12
+ alias links _links
14
13
 
15
14
  def reversed?
16
15
  !!reversed_at
17
16
  end
18
17
 
19
18
  def reversed_at=(reversed_at)
20
- @reversed_at = Time.parse(reversed_at) rescue nil
19
+ @reversed_at = begin
20
+ Time.parse(reversed_at)
21
+ rescue StandardError
22
+ nil
23
+ end
21
24
  end
22
25
 
23
26
  def created_at=(created_at)
24
- @created_at = Time.parse(created_at) rescue nil
27
+ @created_at = begin
28
+ Time.parse(created_at)
29
+ rescue StandardError
30
+ nil
31
+ end
25
32
  end
26
33
 
27
34
  def amount=(amount)
@@ -37,10 +44,9 @@ module Mollie
37
44
  end
38
45
 
39
46
  def settlement(options = {})
40
- settlement_id = Util.extract_id(links, "settlement")
47
+ settlement_id = Util.extract_id(links, 'settlement')
41
48
  return if settlement_id.nil?
42
49
  Settlement.get(settlement_id, options)
43
50
  end
44
-
45
51
  end
46
52
  end
@@ -1,10 +1,10 @@
1
1
  module Mollie
2
2
  class Client
3
- API_ENDPOINT = 'https://api.mollie.com'
4
- API_VERSION = 'v2'
3
+ API_ENDPOINT = 'https://api.mollie.com'.freeze
4
+ API_VERSION = 'v2'.freeze
5
5
 
6
- MODE_TEST = 'test'
7
- MODE_LIVE = 'live'
6
+ MODE_TEST = 'test'.freeze
7
+ MODE_LIVE = 'live'.freeze
8
8
 
9
9
  class << self
10
10
  attr_accessor :configuration
@@ -66,9 +66,9 @@ module Mollie
66
66
  api_key = http_body.delete(:api_key) || query.delete(:api_key) || @api_key
67
67
  api_endpoint = http_body.delete(:api_endpoint) || query.delete(:api_endpoint) || @api_endpoint
68
68
 
69
- if query.length > 0
69
+ unless query.empty?
70
70
  camelized_query = Util.camelize_keys(query)
71
- path += "?#{build_nested_query(camelized_query)}"
71
+ path += "?#{build_nested_query(camelized_query)}"
72
72
  end
73
73
 
74
74
  uri = URI.parse(api_endpoint)
@@ -81,19 +81,19 @@ module Mollie
81
81
  when 'GET'
82
82
  request = Net::HTTP::Get.new(path)
83
83
  when 'POST'
84
- http_body.delete_if { |k, v| v.nil? }
84
+ http_body.delete_if { |_k, v| v.nil? }
85
85
  request = Net::HTTP::Post.new(path)
86
86
  request.body = Util.camelize_keys(http_body).to_json
87
87
  when 'PATCH'
88
- http_body.delete_if { |k, v| v.nil? }
88
+ http_body.delete_if { |_k, v| v.nil? }
89
89
  request = Net::HTTP::Patch.new(path)
90
90
  request.body = Util.camelize_keys(http_body).to_json
91
91
  when 'DELETE'
92
- http_body.delete_if { |k, v| v.nil? }
92
+ http_body.delete_if { |_k, v| v.nil? }
93
93
  request = Net::HTTP::Delete.new(path)
94
94
  request.body = Util.camelize_keys(http_body).to_json
95
95
  else
96
- raise Mollie::Exception.new("Invalid HTTP Method: #{http_method}")
96
+ raise Mollie::Exception, "Invalid HTTP Method: #{http_method}"
97
97
  end
98
98
 
99
99
  request['Accept'] = 'application/json'
@@ -104,8 +104,8 @@ module Mollie
104
104
  begin
105
105
  response = client.request(request)
106
106
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
107
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
108
- raise Mollie::Exception.new(e.message)
107
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
108
+ raise Mollie::Exception, e.message
109
109
  end
110
110
 
111
111
  http_code = response.code.to_i
@@ -126,17 +126,17 @@ module Mollie
126
126
  def build_nested_query(value, prefix = nil)
127
127
  case value
128
128
  when Array
129
- value.map { |v|
129
+ value.map do |v|
130
130
  build_nested_query(v, "#{prefix}[]")
131
- }.join("&")
131
+ end.join('&')
132
132
  when Hash
133
- value.map { |k, v|
133
+ value.map do |k, v|
134
134
  build_nested_query(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k))
135
- }.reject(&:empty?).join('&')
135
+ end.reject(&:empty?).join('&')
136
136
  when nil
137
137
  prefix
138
138
  else
139
- raise ArgumentError, "value must be a Hash" if prefix.nil?
139
+ raise ArgumentError, 'value must be a Hash' if prefix.nil?
140
140
  "#{prefix}=#{escape(value)}"
141
141
  end
142
142
  end
@@ -1,9 +1,9 @@
1
1
  module Mollie
2
2
  class Customer
3
3
  class Mandate < Base
4
- STATUS_VALID = "valid"
5
- STATUS_INVALID = "invalid"
6
- STATUS_PENDING = "pending"
4
+ STATUS_VALID = 'valid'.freeze
5
+ STATUS_INVALID = 'invalid'.freeze
6
+ STATUS_PENDING = 'pending'.freeze
7
7
 
8
8
  attr_accessor :id,
9
9
  :status,
@@ -14,14 +14,18 @@ module Mollie
14
14
  :created_at,
15
15
  :_links
16
16
 
17
- alias_method :links, :_links
17
+ alias links _links
18
18
 
19
19
  def details=(details)
20
20
  @details = OpenStruct.new(details) if details.is_a?(Hash)
21
21
  end
22
22
 
23
23
  def created_at=(created_at)
24
- @created_at = Time.parse(created_at.to_s) rescue nil
24
+ @created_at = begin
25
+ Time.parse(created_at.to_s)
26
+ rescue StandardError
27
+ nil
28
+ end
25
29
  end
26
30
 
27
31
  def valid?
@@ -37,7 +41,7 @@ module Mollie
37
41
  end
38
42
 
39
43
  def customer(options = {})
40
- customer_id = Util.extract_id(links, "customer")
44
+ customer_id = Util.extract_id(links, 'customer')
41
45
  Customer.get(customer_id, options)
42
46
  end
43
47
  end
@@ -1,11 +1,11 @@
1
1
  module Mollie
2
2
  class Customer
3
3
  class Subscription < Base
4
- STATUS_ACTIVE = "active"
5
- STATUS_PENDING = "pending" # Waiting for a valid mandate.
6
- STATUS_CANCELED = "canceled"
7
- STATUS_SUSPENDED = "suspended" # Active, but mandate became invalid.
8
- STATUS_COMPLETED = "completed"
4
+ STATUS_ACTIVE = 'active'.freeze
5
+ STATUS_PENDING = 'pending'.freeze # Waiting for a valid mandate.
6
+ STATUS_CANCELED = 'canceled'.freeze
7
+ STATUS_SUSPENDED = 'suspended'.freeze # Active, but mandate became invalid.
8
+ STATUS_COMPLETED = 'completed'.freeze
9
9
 
10
10
  attr_accessor :id,
11
11
  :customer_id,
@@ -41,11 +41,19 @@ module Mollie
41
41
  end
42
42
 
43
43
  def created_at=(created_at)
44
- @created_at = Time.parse(created_at.to_s) rescue nil
44
+ @created_at = begin
45
+ Time.parse(created_at.to_s)
46
+ rescue StandardError
47
+ nil
48
+ end
45
49
  end
46
50
 
47
51
  def canceled_at=(canceled_at)
48
- @canceled_at = Time.parse(canceled_at.to_s) rescue nil
52
+ @canceled_at = begin
53
+ Time.parse(canceled_at.to_s)
54
+ rescue StandardError
55
+ nil
56
+ end
49
57
  end
50
58
 
51
59
  def amount=(amount)
@@ -2,7 +2,7 @@ module Mollie
2
2
  class Exception < StandardError
3
3
  end
4
4
 
5
- class RequestError < Exception
5
+ class RequestError < RuntimeError
6
6
  attr_accessor :status, :title, :detail, :field, :links
7
7
 
8
8
  def initialize(error)
@@ -1,8 +1,8 @@
1
1
  module Mollie
2
2
  class Invoice < Base
3
- STATUS_OPEN = "open"
4
- STATUS_PAID = "paid"
5
- STATUS_OVERDUE = "overdue"
3
+ STATUS_OPEN = 'open'.freeze
4
+ STATUS_PAID = 'paid'.freeze
5
+ STATUS_OVERDUE = 'overdue'.freeze
6
6
 
7
7
  class Line < Base
8
8
  attr_accessor :period, :description, :count, :vat_percentage, :amount
@@ -25,7 +25,7 @@ module Mollie
25
25
  :lines,
26
26
  :_links
27
27
 
28
- alias_method :links, :_links
28
+ alias links _links
29
29
 
30
30
  def open?
31
31
  status == STATUS_OPEN
@@ -52,11 +52,19 @@ module Mollie
52
52
  end
53
53
 
54
54
  def issued_at=(issued_at)
55
- @issued_at = Time.parse(issued_at) rescue nil
55
+ @issued_at = begin
56
+ Time.parse(issued_at)
57
+ rescue StandardError
58
+ nil
59
+ end
56
60
  end
57
61
 
58
62
  def due_at=(due_at)
59
- @due_at = Time.parse(due_at) rescue nil
63
+ @due_at = begin
64
+ Time.parse(due_at)
65
+ rescue StandardError
66
+ nil
67
+ end
60
68
  end
61
69
 
62
70
  def lines=(lines)
@@ -3,19 +3,19 @@ module Mollie
3
3
  include Enumerable
4
4
 
5
5
  attr_accessor :klass, :items, :_links
6
- alias_method :links, :_links
6
+ alias links _links
7
7
 
8
8
  def initialize(list_attributes, klass)
9
9
  @klass = klass
10
10
 
11
- if list_attributes['_embedded']
12
- list_attributes['items'] ||= list_attributes['_embedded'].fetch(klass.resource_name, [])
13
- else
14
- list_attributes['items'] ||= []
15
- end
11
+ list_attributes['items'] ||= if list_attributes['_embedded']
12
+ list_attributes['_embedded'].fetch(klass.resource_name, [])
13
+ else
14
+ []
15
+ end
16
16
  super list_attributes
17
17
 
18
- @items = self.items.map do |attributes|
18
+ @items = items.map do |attributes|
19
19
  klass.new attributes
20
20
  end
21
21
  end
@@ -25,9 +25,7 @@ module Mollie
25
25
  end
26
26
 
27
27
  def next(options = {})
28
- if links['next'].nil?
29
- return self.class.new({}, klass)
30
- end
28
+ return self.class.new({}, klass) if links['next'].nil?
31
29
 
32
30
  href = URI.parse(links['next']['href'])
33
31
  query = URI.decode_www_form(href.query).to_h
@@ -36,9 +34,7 @@ module Mollie
36
34
  end
37
35
 
38
36
  def previous(options = {})
39
- if links['previous'].nil?
40
- return self.class.new({}, klass)
41
- end
37
+ return self.class.new({}, klass) if links['previous'].nil?
42
38
 
43
39
  href = URI.parse(links['previous']['href'])
44
40
  query = URI.decode_www_form(href.query).to_h