mollie-api-ruby 1.4.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.mdown +5 -5
  5. data/Rakefile +6 -0
  6. data/examples/1-new-payment.rb +4 -5
  7. data/examples/2-webhook-verification.rb +2 -2
  8. data/examples/4-ideal-payment.rb +3 -3
  9. data/examples/5-payments-history.rb +3 -3
  10. data/examples/6-list-activated-methods.rb +3 -3
  11. data/examples/7-refund-payment.rb +5 -5
  12. data/lib/{Mollie/API → mollie/api}/cacert.pem +0 -0
  13. data/lib/mollie/api/client.rb +120 -0
  14. data/lib/{Mollie/API/Client/Version.rb → mollie/api/client/version.rb} +1 -1
  15. data/lib/{Mollie/API/Exception.rb → mollie/api/exception.rb} +0 -0
  16. data/lib/mollie/api/object/base.rb +18 -0
  17. data/lib/mollie/api/object/customer.rb +28 -0
  18. data/lib/{Mollie/API/Object/Issuer.rb → mollie/api/object/issuer.rb} +1 -3
  19. data/lib/mollie/api/object/list.rb +44 -0
  20. data/lib/mollie/api/object/mandate.rb +35 -0
  21. data/lib/{Mollie/API/Object/Method.rb → mollie/api/object/method.rb} +12 -4
  22. data/lib/mollie/api/object/payment.rb +123 -0
  23. data/lib/mollie/api/object/payment/refund.rb +43 -0
  24. data/lib/mollie/api/object/subscription.rb +67 -0
  25. data/lib/{Mollie/API/Resource/Base.rb → mollie/api/resource/base.rb} +8 -8
  26. data/lib/{Mollie/API/Resource/Customers.rb → mollie/api/resource/customers.rb} +2 -2
  27. data/lib/{Mollie/API/Resource/Customers/Mandates.rb → mollie/api/resource/customers/mandates.rb} +5 -5
  28. data/lib/{Mollie/API/Resource/Customers/Payments.rb → mollie/api/resource/customers/payments.rb} +5 -5
  29. data/lib/mollie/api/resource/customers/subscriptions.rb +27 -0
  30. data/lib/{Mollie/API/Resource/Issuers.rb → mollie/api/resource/issuers.rb} +2 -2
  31. data/lib/{Mollie/API/Resource/Methods.rb → mollie/api/resource/methods.rb} +2 -2
  32. data/lib/{Mollie/API/Resource/Payments.rb → mollie/api/resource/payments.rb} +2 -2
  33. data/lib/{Mollie/API/Resource/Payments/Refunds.rb → mollie/api/resource/payments/refunds.rb} +5 -5
  34. data/lib/mollie/api/util.rb +37 -0
  35. data/mollie.gemspec +16 -14
  36. data/test/helper.rb +4 -0
  37. data/test/mollie/api/client_test.rb +99 -0
  38. data/test/mollie/api/object/base_test.rb +21 -0
  39. data/test/mollie/api/object/customer_test.rb +35 -0
  40. data/test/mollie/api/object/issuer_test.rb +23 -0
  41. data/test/mollie/api/object/list_test.rb +44 -0
  42. data/test/mollie/api/object/mandate_test.rb +45 -0
  43. data/test/mollie/api/object/method_test.rb +33 -0
  44. data/test/mollie/api/object/payment/refund_test.rb +46 -0
  45. data/test/mollie/api/object/payment_test.rb +91 -0
  46. data/test/mollie/api/object/subscription_test.rb +68 -0
  47. data/test/mollie/api/resource/base_test.rb +83 -0
  48. data/test/mollie/api/resource/customers/mandates_test.rb +23 -0
  49. data/test/mollie/api/resource/customers/payments_test.rb +23 -0
  50. data/test/mollie/api/resource/customers/subscriptions_test.rb +23 -0
  51. data/test/mollie/api/resource/customers_test.rb +13 -0
  52. data/test/mollie/api/resource/issuers_test.rb +13 -0
  53. data/test/mollie/api/resource/methods_test.rb +13 -0
  54. data/test/mollie/api/resource/payments/refunds_test.rb +23 -0
  55. data/test/mollie/api/resource/payments_test.rb +13 -0
  56. data/test/run-test.rb +15 -0
  57. metadata +99 -52
  58. data/lib/Mollie/API/Client.rb +0 -130
  59. data/lib/Mollie/API/Object/Base.rb +0 -18
  60. data/lib/Mollie/API/Object/Customer.rb +0 -16
  61. data/lib/Mollie/API/Object/List.rb +0 -35
  62. data/lib/Mollie/API/Object/Mandate.rb +0 -22
  63. data/lib/Mollie/API/Object/Payment.rb +0 -68
  64. data/lib/Mollie/API/Object/Payment/Refund.rb +0 -15
  65. data/lib/Mollie/API/Object/Subscription.rb +0 -26
  66. data/lib/Mollie/API/Resource/Customers/Subscriptions.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2408d6e8c1b9aef184a32b5d571998f3177e1d99
4
- data.tar.gz: d41e032d7d1542b37866a50b6d38ac23ec5f2342
3
+ metadata.gz: 7d5c227d854ac6e5a402fbd2b908c74498c99d00
4
+ data.tar.gz: 9d15b18d8eb8602b290ac72df24715347caab492
5
5
  SHA512:
6
- metadata.gz: aaef654274f774dfeedc710e05c394c24815565b5286683aa503d68150d63710be71175cf08700bfcf4e186055444c133467a9ed2c98d775958a69087def1129
7
- data.tar.gz: 03bac53f11dd5804f0117b72e373cb42a7bec3ee2433091762a859e95462387b19701e62d45a170a6e8de19ae63bfaa675cc17a6eb9dc2787808991cdddf391e
6
+ metadata.gz: 608d8337e5de29059eb38e6b612873c98f937b361655e7fe803a9c14e35ca43d6091ba563661cc11110e879a7ce45e5364348aeedc5ec6bd77e696d93cc7b30c
7
+ data.tar.gz: 33ec2a635718181ce1c8dc9ab89145253c82308d4cd5c376f115d18cb1e1d795d6eaf6a0d99f14b51ed3f1bb7d5aa81455c3963352b7bbb678017af47db79db3
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ before_install: gem install bundler
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3.0
8
+ - jruby
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: 2.0.0
12
+ - rvm: jruby
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
7
 
8
+ #### 2.0.0 - 2016-11-10
9
+ - Refactor to a more ruby like library.
10
+ - all methods use underscores
11
+ - payloads to call api functions will be camel cased before sending
12
+ - getters and setters are now just attr_accessors and omit get and set
13
+
8
14
  #### v1.4.2 - 2016-10-19
9
15
  - Added payment method KBC/CBC Payment Button
10
16
  - Fixed an issue where the required `mime-types` dependency did not work correctly ([#32](https://github.com/mollie/mollie-api-ruby/pull/32)).
data/README.mdown CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # Mollie API client for Ruby #
4
4
 
5
+ [![](https://travis-ci.org/mollie/mollie-api-ruby.png)](https://travis-ci.org/mollie/mollie-api-ruby)
6
+
5
7
  Accepting [iDEAL](https://www.mollie.com/ideal/), [Bancontact/Mister Cash](https://www.mollie.com/mistercash/), [SOFORT Banking](https://www.mollie.com/sofort/), [Creditcard](https://www.mollie.com/creditcard/), [SEPA Bank transfer](https://www.mollie.com/overboeking/), [SEPA Direct debit](https://www.mollie.com/directdebit/), [Bitcoin](https://www.mollie.com/bitcoin/), [PayPal](https://www.mollie.com/paypal/), [KBC/CBC Payment Button](https://www.mollie.com/kbccbc/), [Belfius Direct Net](https://www.mollie.com/belfiusdirectnet/) and [paysafecard](https://www.mollie.com/paysafecard/) online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.
6
8
 
7
9
  ## Requirements ##
@@ -11,7 +13,6 @@ To use the Mollie API client, the following things are required:
11
13
  + Create a new [Website profile](https://www.mollie.nl/beheer/account/profielen/) to generate API keys (live and test mode) and setup your webhook.
12
14
  + Now you're ready to use the Mollie API client in test mode.
13
15
  + In order to accept payments in live mode, payment methods must be activated in your account. Follow [a few of steps](https://www.mollie.nl/beheer/diensten), and let us handle the rest.
14
- + This API client requires the [REST Client](https://github.com/rest-client/rest-client) (with [mime-types](https://github.com/mime-types/ruby-mime-types/) version <3) and [JSON](https://rubygems.org/gems/json) gems.
15
16
 
16
17
  ## Installation ##
17
18
 
@@ -38,14 +39,13 @@ To successfully receive a payment, these steps should be implemented:
38
39
  Requiring the Mollie API Client.
39
40
 
40
41
  ```ruby
41
- require 'Mollie/API/Client'
42
+ require 'mollie/api/client'
42
43
  ```
43
44
 
44
45
  Initializing the Mollie API client, and setting your API key.
45
46
 
46
47
  ```ruby
47
- mollie = Mollie::API::Client.new
48
- mollie.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
48
+ mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
49
49
  ```
50
50
 
51
51
  Creating a new payment.
@@ -54,7 +54,7 @@ Creating a new payment.
54
54
  payment = mollie.payments.create(
55
55
  amount: 10.00,
56
56
  description: 'My first API payment',
57
- redirectUrl: 'https://webshop.example.org/order/12345/'
57
+ redirect_url: 'https://webshop.example.org/order/12345/'
58
58
  )
59
59
  ```
60
60
 
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ task default: %w[test]
2
+
3
+ task :test do
4
+ ruby "test/run-test.rb"
5
+ end
6
+
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Example 1 - How to prepare a new payment with the Mollie API.
3
3
  #
4
- require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
4
+ require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
5
5
 
6
6
  begin
7
7
  #
@@ -10,7 +10,7 @@ begin
10
10
  # See: https://www.mollie.nl/beheer/account/profielen/
11
11
  #
12
12
  mollie = Mollie::API::Client.new
13
- mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
13
+ mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
15
  #
16
16
  # Generate a unique order id for this example. It is important to include this unique attribute
@@ -36,11 +36,10 @@ begin
36
36
  payment = mollie.payments.create \
37
37
  :amount => 10.00,
38
38
  :description => "My first API payment",
39
- :redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
39
+ :redirect_url => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
40
40
  :metadata => {
41
41
  :order_id => order_id
42
42
  }
43
-
44
43
  #
45
44
  # In this example we store the order with its payment status in a database.
46
45
  #
@@ -49,7 +48,7 @@ begin
49
48
  #
50
49
  # Send the customer off to complete the payment.
51
50
  #
52
- $response.redirect payment.getPaymentUrl
51
+ $response.redirect payment.payment_url
53
52
  rescue Mollie::API::Exception => e
54
53
  $response.body << "API call failed: " << (CGI.escapeHTML e.message)
55
54
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Example 2 - How to verify Mollie API Payments in a webhook.
3
3
  #
4
- require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
4
+ require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
5
5
 
6
6
  begin
7
7
  #
@@ -10,7 +10,7 @@ begin
10
10
  # See: https://www.mollie.nl/beheer/account/profielen/
11
11
  #
12
12
  mollie = Mollie::API::Client.new
13
- mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
13
+ mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
15
  #
16
16
  # Retrieve the payment's current state.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Example 4 - How to prepare an iDEAL payment with the Mollie API.
3
3
  #
4
- require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
4
+ require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
5
5
 
6
6
  begin
7
7
  #
@@ -10,7 +10,7 @@ begin
10
10
  # See: https://www.mollie.nl/beheer/account/profielen/
11
11
  #
12
12
  mollie = Mollie::API::Client.new
13
- mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
13
+ mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
15
  #
16
16
  # First, let the customer pick the bank in a simple HTML form. This step is actually optional.
@@ -70,7 +70,7 @@ begin
70
70
  #
71
71
  # Send the customer off to complete the payment.
72
72
  #
73
- $response.redirect payment.getPaymentUrl
73
+ $response.redirect payment.payment_url
74
74
  end
75
75
  rescue Mollie::API::Exception => e
76
76
  $response.body << "API call failed: " << (CGI.escapeHTML e.message)
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Example 5 - How to retrieve your payments history.
3
3
  #
4
- require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
4
+ require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
5
5
 
6
6
  begin
7
7
  #
@@ -10,14 +10,14 @@ begin
10
10
  # See: https://www.mollie.nl/beheer/account/profielen/
11
11
  #
12
12
  mollie = Mollie::API::Client.new
13
- mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
13
+ mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
15
  #
16
16
  # Get the all payments for this API key ordered by newest.
17
17
  #
18
18
  payments = mollie.payments.all
19
19
 
20
- $response.body = "Your API key has #{payments.totalCount} payments, last #{payments.count}:<br>"
20
+ $response.body = "Your API key has #{payments.total_count} payments, last #{payments.count}:<br>"
21
21
 
22
22
  payments.each { |payment|
23
23
  $response.body << "&euro; #{payment.amount}, status: #{CGI.escapeHTML payment.status} (#{CGI.escapeHTML payment.id})<br>"
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Example 6 - How to get the currently activated payment methods.
3
3
  #
4
- require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
4
+ require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
5
5
 
6
6
  begin
7
7
  #
@@ -10,14 +10,14 @@ begin
10
10
  # See: https://www.mollie.nl/beheer/account/profielen/
11
11
  #
12
12
  mollie = Mollie::API::Client.new
13
- mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
13
+ mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
15
  #
16
16
  # Get the all the activated methods for this API key.
17
17
  #
18
18
  methods = mollie.methods.all
19
19
 
20
- $response.body << "Your API key has #{methods.totalCount} activated payment methods:<br>"
20
+ $response.body << "Your API key has #{methods.total_count} activated payment methods:<br>"
21
21
 
22
22
  methods.each { |method|
23
23
  $response.body << '<div style="line-height:40px; vertical-align:top">'
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Example 7 - How to refund a payment programmatically.
3
3
  #
4
- require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
4
+ require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
5
5
 
6
6
  begin
7
7
  #
@@ -10,7 +10,7 @@ begin
10
10
  # See: https://www.mollie.nl/beheer/account/profielen/
11
11
  #
12
12
  mollie = Mollie::API::Client.new
13
- mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
13
+ mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
15
  #
16
16
  # Retrieve the payment you want to refund from the API.
@@ -30,9 +30,9 @@ begin
30
30
  refunds = mollie.payments_refunds.with(payment).all
31
31
 
32
32
  refunds.each { |refund|
33
- $response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refundedDatetime)
34
- $response.body << '<br> Refunded: &euro; ' << (CGI.escapeHTML refund.amountRefunded)
35
- $response.body << '<br> Remaining: &euro; ' << (CGI.escapeHTML refund.amountRemaining)
33
+ $response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refunded_datetime)
34
+ $response.body << '<br> Refunded: &euro; ' << (CGI.escapeHTML refund.amount_refunded)
35
+ $response.body << '<br> Remaining: &euro; ' << (CGI.escapeHTML refund.amount_remaining)
36
36
  $response.body << '<br>'
37
37
  }
38
38
  rescue Mollie::API::Exception => e
File without changes
@@ -0,0 +1,120 @@
1
+ require "json"
2
+ require "time"
3
+ require "ostruct"
4
+ require "bigdecimal"
5
+
6
+ ["exception",
7
+ "util",
8
+ "client/version",
9
+ "resource/base",
10
+ "resource/customers",
11
+ "resource/customers/payments",
12
+ "resource/customers/mandates",
13
+ "resource/customers/subscriptions",
14
+ "resource/payments",
15
+ "resource/payments/refunds",
16
+ "resource/issuers",
17
+ "resource/methods",
18
+ "object/base",
19
+ "object/list",
20
+ "object/customer",
21
+ "object/mandate",
22
+ "object/subscription",
23
+ "object/payment",
24
+ "object/payment/refund",
25
+ "object/issuer",
26
+ "object/method"].each { |file| require File.expand_path file, File.dirname(__FILE__) }
27
+
28
+ module Mollie
29
+ module API
30
+ class Client
31
+ API_ENDPOINT = "https://api.mollie.nl"
32
+ API_VERSION = "v1"
33
+
34
+ attr_accessor :api_key
35
+ attr_reader :payments, :issuers, :methods, :payments_refunds,
36
+ :customers, :customers_payments, :customers_mandates, :customers_subscriptions,
37
+ :api_endpoint
38
+
39
+ def initialize(api_key)
40
+ @payments = Mollie::API::Resource::Payments.new self
41
+ @issuers = Mollie::API::Resource::Issuers.new self
42
+ @methods = Mollie::API::Resource::Methods.new self
43
+ @payments_refunds = Mollie::API::Resource::Payments::Refunds.new self
44
+ @customers = Mollie::API::Resource::Customers.new self
45
+ @customers_payments = Mollie::API::Resource::Customers::Payments.new self
46
+ @customers_mandates = Mollie::API::Resource::Customers::Mandates.new self
47
+ @customers_subscriptions = Mollie::API::Resource::Customers::Subscriptions.new self
48
+
49
+ @api_endpoint = API_ENDPOINT
50
+ @api_key = api_key
51
+ @version_strings = []
52
+
53
+ add_version_string "Mollie/" << VERSION
54
+ add_version_string "Ruby/" << RUBY_VERSION
55
+ add_version_string OpenSSL::OPENSSL_VERSION.split(" ").slice(0, 2).join "/"
56
+ end
57
+
58
+ def api_endpoint=(api_endpoint)
59
+ @api_endpoint = api_endpoint.chomp "/"
60
+ end
61
+
62
+ def add_version_string(version_string)
63
+ @version_strings << (version_string.gsub /\s+/, "-")
64
+ end
65
+
66
+ def perform_http_call(http_method, api_method, id = nil, http_body = {})
67
+ path = "/#{API_VERSION}/#{api_method}/#{id}".chomp('/')
68
+ case http_method
69
+ when 'GET'
70
+ request = Net::HTTP::Get.new(path)
71
+ when 'POST'
72
+ http_body.delete_if { |k, v| v.nil? }
73
+ request = Net::HTTP::Post.new(path)
74
+ request.body = Util.camelize_keys(http_body).to_json
75
+ when 'DELETE'
76
+ request = Net::HTTP::Delete.new(path)
77
+ else
78
+ raise Mollie::API::Exception.new("Invalid HTTP Method: #{http_method}")
79
+ end
80
+
81
+ request['Accept'] = 'application/json'
82
+ request['Authorization'] = "Bearer #{@api_key}"
83
+ request['User-Agent'] = @version_strings.join(" ")
84
+
85
+ begin
86
+ response = client.request(request)
87
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
88
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
89
+ raise Mollie::API::Exception.new(e.message)
90
+ end
91
+
92
+ http_code = response.code.to_i
93
+ case http_code
94
+ when 200, 201
95
+ Util.nested_underscore_keys(JSON.parse(response.body))
96
+ when 204
97
+ {} # No Content
98
+ else
99
+ response = JSON.parse(response.body)
100
+ exception = Mollie::API::Exception.new response['error']['message']
101
+ exception.code = http_code
102
+ exception.field = response['error']['field'] unless response['error']['field'].nil?
103
+ raise exception
104
+ end
105
+ end
106
+
107
+ private
108
+
109
+ def client
110
+ return @client if defined? @client
111
+ uri = URI.parse(@api_endpoint)
112
+ @client = Net::HTTP.new(uri.host, uri.port)
113
+ @client.use_ssl = true
114
+ @client.verify_mode = OpenSSL::SSL::VERIFY_PEER
115
+ @client.ca_file = (File.expand_path "cacert.pem", File.dirname(__FILE__))
116
+ @client
117
+ end
118
+ end
119
+ end
120
+ end
@@ -1,7 +1,7 @@
1
1
  module Mollie
2
2
  module API
3
3
  class Client
4
- CLIENT_VERSION = "1.4.2"
4
+ VERSION = "2.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,18 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Base
5
+ attr_reader :attributes
6
+
7
+ def initialize(attributes)
8
+ @attributes = attributes
9
+ attributes.each do |key, value|
10
+ if self.respond_to?("#{key}=")
11
+ public_send("#{key}=", value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Customer < Base
5
+ attr_accessor :id,
6
+ :mode,
7
+ :name,
8
+ :email,
9
+ :locale,
10
+ :metadata,
11
+ :recently_used_methods,
12
+ :created_datetime
13
+
14
+ def created_datetime=(created_datetime)
15
+ @created_datetime = Time.parse(created_datetime.to_s)
16
+ end
17
+
18
+ def recently_used_methods=(methods)
19
+ @recently_used_methods = Array(methods).map(&:to_s)
20
+ end
21
+
22
+ def metadata=(metadata)
23
+ @metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end