-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WorldlineConnect
committed
Mar 19, 2024
1 parent
07f0f37
commit a592380
Showing
643 changed files
with
34,653 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
|
||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
tags: ['[0-9]+.[0-9]+*'] | ||
|
||
env: | ||
SDK_VERSION: ${{ github.ref_name }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '2.6' | ||
rubygems: latest | ||
bundler-cache: true | ||
- name: Build | ||
run: gem build connect-sdk-ruby.gemspec | ||
- name: Deploy | ||
run: | | ||
mkdir -p ~/.gem | ||
echo --- > ~/.gem/credentials | ||
echo :rubygems_api_key: ${RUBYGEMS_API_KEY} >> ~/.gem/credentials | ||
chmod 0600 ~/.gem/credentials | ||
gem push connect-sdk-ruby-${SDK_VERSION}.gem | ||
env: | ||
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.idea/ | ||
.settings/ | ||
.project | ||
.buildpath | ||
|
||
*.gem | ||
*.rbc | ||
/.config | ||
/coverage/ | ||
/InstalledFiles | ||
/pkg/ | ||
/spec/reports/ | ||
/spec/examples.txt | ||
/test/tmp/ | ||
/test/version_tmp/ | ||
/tmp/ | ||
|
||
# Used by dotenv library to load environment variables. | ||
# .env | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
build/ | ||
*.bridgesupport | ||
build-iPhoneOS/ | ||
build-iPhoneSimulator/ | ||
|
||
## Specific to RubyMotion (use of CocoaPods): | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# vendor/Pods/ | ||
|
||
## Documentation cache and generated files: | ||
/.yardoc/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
|
||
## Environment normalization: | ||
/.bundle/ | ||
/vendor/bundle | ||
/lib/bundler/man/ | ||
|
||
# for a library or gem, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
Gemfile.lock | ||
.ruby-version | ||
.ruby-gemset | ||
|
||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: | ||
.rvmrc | ||
|
||
# ignore files from rubymine: | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# Worldline Connect Ruby SDK | ||
|
||
## Introduction | ||
|
||
The Ruby SDK helps you to communicate with the [Worldline Connect](https://docs.connect.worldline-solutions.com/) Server API. Its primary features are: | ||
|
||
* convenient Ruby library for the API calls and responses | ||
* marshalls Ruby request objects to HTTP requests | ||
* unmarshalls HTTP responses to Ruby response objects or Ruby exceptions | ||
* handling of all the details concerning authentication | ||
* handling of required metadata | ||
|
||
Its use is demonstrated by an example for each possible call. The examples execute a call using the provided API keys. | ||
|
||
See the [Worldline Connect Developer Hub](https://docs.connect.worldline-solutions.com/documentation/sdk/server/ruby/) for more information on how to use the SDK. | ||
|
||
## Structure of this repository | ||
|
||
This repository consists out of four main components: | ||
|
||
1. The source code of the SDK itself: `/lib/worldline/connect/sdk/` | ||
2. The source code of the SDK unit tests: `/spec/lib/` | ||
3. The source code of the SDK integration tests: `/spec/integration/` | ||
4. Usage examples: `/examples/` | ||
|
||
Note that the source code of the unit tests, integration tests and the examples can only be found on GitHub. | ||
|
||
## Requirements | ||
|
||
Ruby 2.3 or higher is required. | ||
As for JRuby, version 9.0.0.0 and higher are supported. | ||
In addition, the following packages are required: | ||
|
||
* [httpclient](https://github.com/nahi/httpclient) 2.8 or higher | ||
* [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby) 1.0 or higher | ||
|
||
## Installation | ||
|
||
### Using RubyGems | ||
|
||
To install the SDK using `gem`, execute the following command: | ||
|
||
gem install connect-sdk-ruby | ||
|
||
### Using a pre-built gem | ||
|
||
1. Download the latest version of the Ruby SDK from GitHub. Choose the `connect-sdk-ruby-x.y.z.gem` file from the [releases](https://github.com/Worldline-Global-Collect/connect-sdk-ruby/releases) page, where `x.y.z` is the version number. | ||
2. Navigate into the folder where the gem file is downloaded to, and execute the following command: | ||
|
||
``` | ||
gem install connect-sdk-ruby-x.y.z.gem | ||
``` | ||
3. Feel free to delete the gem file at this point, it is no longer required. | ||
### From source | ||
1. Download the latest version of the Ruby SDK from GitHub. Choose the `connect-sdk-ruby-x.y.z.zip` file from the [releases](https://github.com/Worldline-Global-Collect/connect-sdk-ruby/releases) page, where `x.y.z` is the version number. | ||
2. Unzip the file, navigate into the folder where the file is unzipped to, and execute the following commands: | ||
``` | ||
gem build connect-sdk-ruby.gemspec | ||
gem install connect-sdk-ruby-x.y.z.gem | ||
``` | ||
3. Feel free to delete the unzipped archive, the zip file and the gem file at this point, they are no longer required. | ||
## Uninstalling | ||
After the Ruby SDK has been installed, it can be uninstalled using the | ||
following command: | ||
gem uninstall connect-sdk-ruby | ||
The required packages can be uninstalled in the same way. | ||
## Usage | ||
After the Ruby SDK has been installed, it can be required in Ruby program as follows: | ||
require 'worldline/connect/sdk' | ||
## Running tests | ||
There are two types of tests: unit tests and integration tests. The unit tests will work out-of-the-box; for the integration tests some configuration is required. | ||
First, some environment variables need to be set: | ||
* `connect_api_apiKeyId` for the API key id to use. This can be retrieved from the Configuration Center. | ||
* `connect_api_secretApiKey` for the secret API key to use. This can be retrieved from the Configuration Center. | ||
* `connect_api_merchantId` for your merchant ID. | ||
In addition, to run the proxy integration tests, the proxy URI, username and password should be set in the `spec/fixtures/resources/properties.proxy.yml` file. | ||
In order to run the unit and integration tests, some additional dependencies are required: | ||
* [rake](https://ruby.github.io/rake/) 12.3.3 or higher | ||
* [rspec](https://github.com/rspec/rspec) 3.5 or higher | ||
* [webmock](https://github.com/bblimke/webmock) 2.1 or higher | ||
* [sinatra](https://github.com/sinatra/sinatra) 2.1 or higher | ||
* [webrick](https://github.com/ruby/webrick) 1.7 or higher | ||
They can be installed using the following command: | ||
gem install rake rspec webmock sinatra | ||
*Note: if rake is already installed as part of the Ruby installation, this will cause a conflict error. This can safely be ignored.* | ||
The following commands can now be executed from the root directory of the SDK folder (/) to execute the tests: | ||
* Unit tests: | ||
``` | ||
rake unit | ||
``` | ||
* Integration tests: | ||
``` | ||
rake integration | ||
``` | ||
* Both unit and integration tests: | ||
``` | ||
rake spec | ||
``` | ||
## Generating documentation | ||
Documentation can be generated with YARD. YARD can be installed as a gem. The gems required to generate documentation are: | ||
* [rake](https://ruby.github.io/rake/) 12.3.3 or higher | ||
* [yard](https://github.com/lsegal/yard) 0.9.5 or higher | ||
They can be installed using the following command: | ||
gem install rake yard | ||
*Note: if rake is already installed as part of the Ruby installation, this will cause a conflict error. This can safely be ignored.* | ||
Once YARD and rake are installed, documentation can be generated with the following command (ran from the root folder): | ||
rake yard | ||
Documentation will be generated in the `/doc` folder. The file `/doc/index.html` is the main documentation file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
begin | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) do |t| # supports automated testing using the command *rake* *spec* | ||
t.rspec_opts = '--color --format documentation' | ||
end | ||
|
||
RSpec::Core::RakeTask.new(:unit) do |t| # supports automated testing using unit tests using the command *rake* *unit* | ||
t.rspec_opts = '--color --format documentation' | ||
t.exclude_pattern = 'spec/integration/**' | ||
end | ||
|
||
RSpec::Core::RakeTask.new(:integration) do |t| # supports automated testing of integration using the command *rake* *integration* | ||
t.rspec_opts = '--color --format documentation' | ||
t.pattern = 'spec/integration/**_spec.rb' | ||
end | ||
|
||
task :default => :spec | ||
rescue LoadError | ||
puts '[*] error -- development dependency is not installed' | ||
end | ||
|
||
begin | ||
require 'yard' | ||
|
||
YARD::Rake::YardocTask.new(:yard) do |t| # supports generating documentation using the command *rake* *yard* | ||
# t.files = ['lib/**/*.rb', OTHER_PATHS] # optional | ||
t.options = ['--no-private'] | ||
end | ||
|
||
task :doc => :yard # alternative alias to generate documentation | ||
rescue LoadError | ||
puts '[*] error -- development dependency is not installed' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Gem::Specification.new do |spec| | ||
spec.name = 'connect-sdk-ruby' | ||
spec.version = '3.0.0' | ||
spec.authors = ['Worldline Global Collect'] | ||
spec.email = ['[email protected]'] | ||
spec.summary = %q{SDK to communicate with the Worldline Global Collect platform using the Worldline Connect Server API} | ||
spec.description = %q{SDK to communicate with the Worldline Global Collect platform using the Worldline Connect Server API} | ||
spec.homepage = %q{https://github.com/Worldline-Global-Collect/connect-sdk-ruby} | ||
spec.license = 'MIT' | ||
|
||
# exclude hidden files like .gitignore | ||
spec.files = Dir['lib/**/*'] + Dir['examples/**/*'] + Dir['spec/**/*'] + | ||
['connect-sdk-ruby.gemspec', 'Gemfile', 'LICENSE.txt', 'Rakefile', 'README.md'] | ||
spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)\/}) | ||
spec.require_paths = ['lib'] | ||
|
||
spec.required_ruby_version = '>= 2.0' | ||
|
||
spec.add_dependency 'httpclient', '~> 2.8' | ||
spec.add_dependency 'concurrent-ruby', '~>1.0' | ||
|
||
spec.add_development_dependency 'yard', '~> 0.9' | ||
spec.add_development_dependency 'rspec', '~> 3.5' | ||
spec.add_development_dependency 'webmock', '~> 2.1' | ||
spec.add_development_dependency 'sinatra', '~> 2.1' | ||
spec.add_development_dependency 'webrick', '~> 1.7' | ||
spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3' | ||
# spec.metadata['yard.run'] = 'yri' # compiles yard doc on install | ||
end |
Oops, something went wrong.