revolut 0.1.0 → 0.2.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: e78472bddc6b9b4a144e58443790a36e86b323d15d9c2e486e475aef7797dd64
4
- data.tar.gz: 77607ab1818d51ff6fa56b32b5cd0ac52ee5b3faf532657f3a75773923121f45
3
+ metadata.gz: 2b9657e59d398bee91251de918c472f74dd2aea52151166a668edfcacf5f9cad
4
+ data.tar.gz: 3b1c166bf2a570fccf8243999c66cf8f5293b6b50367089ebba92e2836b2b0e7
5
5
  SHA512:
6
- metadata.gz: 700c67c2106597bd89d3d44f8abda929b29dfa3a209c2dad0e7485260b3e918c95bca3dea18cc3bf8b8036340da8c0371ac1faf12299a0374fd73f11191c51d4
7
- data.tar.gz: 0d17e68f636e0eaf36556791c93c2434577060d740c0231fd1a8f64865eccdd90e31ea49dc7b9e13efe679e9a7d90dd6e1f03041d41fdca67e1b289fb15696e4
6
+ metadata.gz: a366caacfcd613d84be4ce92d5003f9d236ce83254d0fdd9ee61b44926e0f8de4fb590ed64cc27f3ef68a38c6ac5b46e692ab5b0ececbb35188d1f0f12199625
7
+ data.tar.gz: 27e73e91527b52b1f2232e434cca58a72d911aac80954a4224bf4204019856151c3c6096bcf2ce472c8d33c9fc71dc35182bddefc3323940a2b27b3586effad2
@@ -1,5 +1,36 @@
1
1
  sudo: false
2
+
3
+ cache:
4
+ bundler: true
5
+
6
+ env:
7
+ global:
8
+ - CC_TEST_REPORTER_ID=f86c6bdee47c51e643c1359af6752ac4d85084f5c484733b596f5f9572a91b93
9
+
2
10
  language: ruby
3
11
  rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.2
12
+ - 2.1.0
13
+ - 2.2.0
14
+ - 2.3.0
15
+ - 2.4.0
16
+ - 2.5.0
17
+ - ruby-head
18
+
19
+ before_install:
20
+ - gem install bundler -v 1.16.2
21
+ - gem update --system
22
+
23
+ before_script:
24
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25
+ - chmod +x ./cc-test-reporter
26
+ - ./cc-test-reporter before-build
27
+
28
+ script:
29
+ - bundle exec rspec
30
+
31
+ after_script:
32
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
33
+
34
+ matrix:
35
+ allow_failures:
36
+ - rvm: ruby-head
data/Gemfile CHANGED
@@ -13,7 +13,6 @@ end
13
13
  group :test do
14
14
  gem 'rake' # For Travis CI
15
15
  gem 'simplecov', '~> 0.16', require: false
16
- gem 'webmock', '~> 3.4'
17
16
  end
18
17
 
19
18
  # Specify your gem's dependencies in revolut.gemspec
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Revolut
1
+ # Revolut API Ruby wrapper
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/revolut`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ A Ruby gem which helps to communicate with [Revolut Business][revolut] API.
6
4
 
7
5
  ## Installation
8
6
 
@@ -12,17 +10,56 @@ Add this line to your application's Gemfile:
12
10
  gem 'revolut'
13
11
  ```
14
12
 
15
- And then execute:
13
+ ## Usage
16
14
 
17
- $ bundle
15
+ ### Authentication
18
16
 
19
- Or install it yourself as:
17
+ When you sign up for an account, you can generate production or sandbox **API key** in settings page.
18
+ You will need this API key to communicate with [Revolut][revolut] API.
19
+ When testing, you should use Sandbox environment.
20
20
 
21
- $ gem install revolut
21
+ Before making any request, you should authenticate first. Use the response object to
22
+ make requests afterward.
22
23
 
23
- ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ```ruby
26
+ client = Revolut::Client.new(api_key: 'my-secret-api-key')
27
+ ```
28
+
29
+ Example:
30
+
31
+ ```ruby
32
+ client.accounts
33
+ ```
34
+
35
+ Or create file under `config/initializers/revolut.rb`
36
+
37
+ ```ruby
38
+ Revolut.configure do |config|
39
+ config.api_key = 'my-secret-api-key'
40
+ config.environment = :sandbox # Or :production
41
+ end
42
+ ```
43
+
44
+ When you configured global settings in file, then you can request methods
45
+ on `Revolut` class directly.
46
+
47
+ Example:
48
+
49
+ ```ruby
50
+ Revolut.accounts
51
+ ```
52
+
53
+ ## Supported Ruby Versions
54
+
55
+ This library aims to support and is [tested against][travis] the following Ruby
56
+ implementations:
57
+
58
+ * Ruby 2.1.0
59
+ * Ruby 2.2.0
60
+ * Ruby 2.3.0
61
+ * Ruby 2.4.0
62
+ * Ruby 2.5.0
26
63
 
27
64
  ## Development
28
65
 
@@ -32,7 +69,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
69
 
33
70
  ## Contributing
34
71
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/revolut. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jpalumickas/revolut-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
73
 
37
74
  ## License
38
75
 
@@ -40,4 +77,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
77
 
41
78
  ## Code of Conduct
42
79
 
43
- Everyone interacting in the Revolut project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/revolut/blob/master/CODE_OF_CONDUCT.md).
80
+ Everyone interacting in the Revolut project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jpalumickas/revolut-ruby/blob/master/CODE_OF_CONDUCT.md).
81
+
82
+ [travis]: https://travis-ci.org/jpalumickas/revolut-ruby
83
+
84
+ [revolut]: https://www.revolut.com
@@ -1,5 +1,5 @@
1
1
  require 'revolut/version'
2
- # require 'revolut/utils'
2
+ require 'revolut/utils'
3
3
  require 'revolut/error'
4
4
  require 'revolut/client'
5
5
 
@@ -2,16 +2,21 @@ require 'revolut/connection'
2
2
  require 'revolut/configuration'
3
3
 
4
4
  require 'revolut/clients/accounts'
5
+ require 'revolut/clients/counterparties'
6
+ require 'revolut/clients/webhooks'
5
7
 
6
8
  module Revolut
7
9
  # Wrapper class for all actions.
8
10
  class Client
9
11
  include Revolut::Clients::Accounts
12
+ include Revolut::Clients::Counterparties
13
+ include Revolut::Clients::Webhooks
10
14
 
11
15
  # Initialize client.
12
16
  #
13
17
  # @param options [Hash] A customizable set of options.
14
18
  # @option options [String] :api_key API Key provider from Revlut.
19
+ # @option options [String] :environment Environment (Production/Sanbox).
15
20
  def initialize(options = {})
16
21
  config.api_key = options[:api_key] if options[:api_key]
17
22
  config.environment = options[:environment] if options[:environment]
@@ -0,0 +1,42 @@
1
+ module Revolut
2
+ module Clients
3
+ # Revolut Accounts
4
+ module Counterparties
5
+ # List counterparties
6
+ #
7
+ # @see https://revolutdev.github.io/business-api/?shell--sandbox#get-counterparties
8
+ #
9
+ # @return [Hash] Response from API.
10
+ def counterparties
11
+ connection.get('counterparties')
12
+ end
13
+
14
+ # Get Counterparty
15
+ #
16
+ # @see https://revolutdev.github.io/business-api/?shell--sandbox#get-counterparty
17
+ #
18
+ # @return [Hash] Response from API.
19
+ def counterparty(id)
20
+ connection.get("counterparty/#{id}")
21
+ end
22
+
23
+ # Add Revolut Counterparty
24
+ #
25
+ # @see https://revolutdev.github.io/business-api/?shell--sandbox#add-revolut-counterparty
26
+ #
27
+ # @return [Hash] Response from API.
28
+ def add_counterparty(params = {})
29
+ connection.post('counterparty', params)
30
+ end
31
+
32
+ # Delete Counterparty
33
+ #
34
+ # @see https://revolutdev.github.io/business-api/?shell--sandbox#delete-counterparty
35
+ #
36
+ # @return [Hash] Response from API.
37
+ def delete_counterparty(id)
38
+ connection.delete("counterparty/#{id}")
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,15 @@
1
+ module Revolut
2
+ module Clients
3
+ # Revolut Webhooks
4
+ module Webhooks
5
+ # Create webhook
6
+ #
7
+ # @see https://revolutdev.github.io/business-api/?shell--sandbox#setting-up-a-web-hook
8
+ #
9
+ # @return [Hash] Response from API.
10
+ def create_webhook(params = {})
11
+ connection.post('webhook', params)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -18,10 +18,6 @@ module Revolut
18
18
  request(:get, path, options).body
19
19
  end
20
20
 
21
- def put(path, options = {})
22
- request(:put, path, {}, options).body
23
- end
24
-
25
21
  def post(path, options = {})
26
22
  request(:post, path, {}, options).body
27
23
  end
@@ -38,13 +38,11 @@ module Revolut
38
38
  # @param response [Faraday::Env] HTTP response.
39
39
  #
40
40
  # @return [String] Revolut error message.
41
- def self.error_message(_response)
42
- nil
43
- # return unless response.body.is_a?(Hash)
44
- # return unless response.body['error']
45
- #
46
- # message = response.body['error']['message']
47
- # Revolut::Utils.presence(message)
41
+ def self.error_message(response)
42
+ return unless response.body.is_a?(Hash)
43
+ message = response.body['message']
44
+ return unless message
45
+ Revolut::Utils.presence(message)
48
46
  end
49
47
  end
50
48
 
@@ -0,0 +1,21 @@
1
+ module Revolut
2
+ module Utils
3
+ BLANK_RE = /\A[[:space:]]*\z/
4
+
5
+ class << self
6
+ def blank?(obj)
7
+ return !!BLANK_RE.match(obj) if obj.is_a?(String)
8
+
9
+ obj.respond_to?(:empty?) ? !!obj.empty? : !obj
10
+ end
11
+
12
+ def present?(obj)
13
+ !blank?(obj)
14
+ end
15
+
16
+ def presence(obj)
17
+ obj if present?(obj)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Revolut
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -12,6 +12,11 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Ruby gem for Revolut API'
13
13
  spec.homepage = 'https://github.com/jpalumickas/revolut-ruby'
14
14
  spec.license = 'MIT'
15
+ spec.metadata = {
16
+ 'bug_tracker_uri' => 'https://github.com/jpalumickas/revolut-ruby/issues',
17
+ 'source_code_uri' => "https://github.com/jpalumickas/revolut-ruby/tree/v#{Revolut::VERSION}",
18
+ 'changelog_uri' => "https://github.com/jpalumickas/revolut-ruby/releases/tag/v#{Revolut::VERSION}"
19
+ }
15
20
 
16
21
  # Specify which files should be added to the gem when it is released.
17
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added
@@ -32,4 +37,5 @@ Gem::Specification.new do |spec|
32
37
  spec.add_development_dependency 'bundler', '~> 1.16'
33
38
  spec.add_development_dependency 'rake', '~> 10.0'
34
39
  spec.add_development_dependency 'rspec', '~> 3.7'
40
+ spec.add_development_dependency 'webmock', '~> 3.4'
35
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revolut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justas Palumickas
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
97
111
  description: Ruby gem for Revolut API
98
112
  email:
99
113
  - jpalumickas@gmail.com
@@ -114,17 +128,23 @@ files:
114
128
  - lib/revolut.rb
115
129
  - lib/revolut/client.rb
116
130
  - lib/revolut/clients/accounts.rb
131
+ - lib/revolut/clients/counterparties.rb
132
+ - lib/revolut/clients/webhooks.rb
117
133
  - lib/revolut/configuration.rb
118
134
  - lib/revolut/connection.rb
119
135
  - lib/revolut/error.rb
120
136
  - lib/revolut/mash.rb
121
137
  - lib/revolut/middleware/raise_error.rb
138
+ - lib/revolut/utils.rb
122
139
  - lib/revolut/version.rb
123
140
  - revolut.gemspec
124
141
  homepage: https://github.com/jpalumickas/revolut-ruby
125
142
  licenses:
126
143
  - MIT
127
- metadata: {}
144
+ metadata:
145
+ bug_tracker_uri: https://github.com/jpalumickas/revolut-ruby/issues
146
+ source_code_uri: https://github.com/jpalumickas/revolut-ruby/tree/v0.2.0
147
+ changelog_uri: https://github.com/jpalumickas/revolut-ruby/releases/tag/v0.2.0
128
148
  post_install_message:
129
149
  rdoc_options: []
130
150
  require_paths: