-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial project skeleton including DotEnv, Rspec, Rubocop, VCR
- Loading branch information
0 parents
commit 7e63caa
Showing
23 changed files
with
486 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,10 @@ | ||
# see http://editorconfig.org/ | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
insert_final_newline = true |
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,6 @@ | ||
UK_CARD_EXTERNAL_ID='ABCDEFGHIJKLM123' | ||
|
||
UK_REST_API_USERNAME='username' | ||
UK_REST_API_PASSWORD='password' | ||
UK_REST_API_MERCHANT_UNIQUE_TAG='tag' | ||
UK_REST_API_PROGRAM_UNIQUE_TAG='tag' |
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 @@ | ||
.env | ||
coverage | ||
Gemfile.lock | ||
spec/vcr_cassettes |
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,5 @@ | ||
--color | ||
--fail-fast | ||
--format documentation | ||
--profile | ||
--require spec_helper |
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,74 @@ | ||
require: | ||
- rubocop-performance | ||
- rubocop-rspec | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.6.4 | ||
|
||
Layout/AlignParameters: | ||
EnforcedStyle: with_fixed_indentation | ||
|
||
Layout/DotPosition: | ||
EnforcedStyle: trailing | ||
|
||
Layout/EndAlignment: | ||
AutoCorrect: true | ||
EnforcedStyleAlignWith: variable | ||
|
||
Layout/IndentFirstArrayElement: | ||
EnforcedStyle: consistent | ||
|
||
Layout/MultilineMethodCallIndentation: | ||
EnforcedStyle: indented | ||
|
||
Layout/MultilineOperationIndentation: | ||
EnforcedStyle: indented | ||
|
||
Lint/AmbiguousBlockAssociation: | ||
Exclude: | ||
- spec/**/* | ||
|
||
RSpec/BeforeAfterAll: | ||
Enabled: false | ||
|
||
RSpec/ExampleLength: | ||
Max: 10 | ||
|
||
RSpec/MultipleExpectations: | ||
Enabled: false | ||
|
||
RSpec/NestedGroups: | ||
Max: 4 | ||
|
||
RSpec/FilePath: | ||
Enabled: false | ||
|
||
Security/Eval: | ||
Enabled: false | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Style/GuardClause: | ||
Enabled: false | ||
|
||
Style/LambdaCall: | ||
Enabled: false | ||
|
||
Style/NegatedIf: | ||
Enabled: false | ||
|
||
Style/Send: | ||
Enabled: true | ||
|
||
Style/StringLiterals: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringLiteralsInInterpolation: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/TrailingCommaInArrayLiteral: | ||
EnforcedStyleForMultiline: consistent_comma | ||
|
||
Style/TrailingCommaInHashLiteral: | ||
EnforcedStyleForMultiline: consistent_comma |
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,5 @@ | ||
# frozen_string_literal: true | ||
source "https://rubygems.org" | ||
|
||
# Declare your dependencies in eml.gemspec | ||
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,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2019- Morning Coffee Pty Ltd (https://morningcoffee.com.au) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,87 @@ | ||
# EML API integration library for Ruby | ||
|
||
The EML API integration library provides convenient access to EML's REST Web | ||
Services and Transaction Notification Service for applications written in | ||
the Ruby language. | ||
|
||
Version 1 supports the UK APIs with Australian support coming as existing code | ||
is extracted. | ||
|
||
## Installation | ||
|
||
You don't need this source code unless you want to modify the gem. If you just | ||
want to use the package, just include the following in your Gemfile: | ||
|
||
```sh | ||
gem "eml", github: "MorningCoffeeDev/eml_ruby" | ||
``` | ||
|
||
If you are debugging or developing this gem and wish to use it within the | ||
context of an existing application, modify your Gemfile to read: | ||
|
||
```sh | ||
gem "eml", path: "../path_to_gem" | ||
``` | ||
|
||
### Requirements | ||
|
||
- Ruby 2.6+ (untested in prior versions) | ||
|
||
## Usage | ||
|
||
Each geographical region is a separate module and will need to be configured | ||
with your supplied credentials. | ||
|
||
```ruby | ||
require "eml" | ||
|
||
EML::UK.configure do |config| | ||
config.username = "username" | ||
config.password = "password" | ||
config.merchant = "merchant_id" | ||
config.program = "program_id" | ||
end | ||
``` | ||
|
||
Make sure you never commit your credentials to git. If you are using Ruby on | ||
Rails, it is usually best to keep your secrets in your | ||
[credentials file]: https://edgeguides.rubyonrails.org/security.html#custom-credentials | ||
|
||
## Development | ||
|
||
Since it is necessary to authenticate with EML to test API resources, | ||
credentials and a test card ID are required. The dotenv gem is loaded when tests | ||
are run and will look for a .env file in the root directory. A .env.example file | ||
has been supplied so you copy it to .env and replace the example values: | ||
|
||
```sh | ||
cp .env.example .env | ||
``` | ||
|
||
The .env file has been added to the .gitignore list and should never been | ||
commited to the repository. | ||
|
||
Run all tests: | ||
|
||
```sh | ||
bundle exec rspec | ||
``` | ||
|
||
Run a single test suite: | ||
|
||
```sh | ||
bundle exec rspec spec/path/to/file.rb | ||
``` | ||
|
||
Run a single test, include the line number: | ||
|
||
```sh | ||
bundle exec rspec spec/path/to/file.rb:123 | ||
``` | ||
|
||
Please ensure that all changes have been run by the Rubocop before creating a | ||
pull request: | ||
|
||
```sh | ||
bundle exec rubocop | ||
``` |
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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
$LOAD_PATH.unshift(::File.join(::File.dirname(__FILE__), "lib")) | ||
|
||
require "eml/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "eml" | ||
s.version = EML::VERSION | ||
s.required_ruby_version = ">= 2.6.0" | ||
s.summary = "Ruby bindings for the EML API" | ||
s.description = "Connect to the EML payments APIs and " \ | ||
"Transaction Notification Serices" | ||
s.author = "Morning Coffee" | ||
s.email = "[email protected]" | ||
s.homepage = "https://github.com/MorningCoffeeDev/eml_ruby" | ||
s.license = "MIT" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- test/*`.split("\n") | ||
s.require_paths = ["lib"] | ||
|
||
s.add_dependency "http", "~> 4.0.0" | ||
|
||
s.add_development_dependency "rspec", "~> 3.8" | ||
s.add_development_dependency "rubocop", "~> 0.71" | ||
s.add_development_dependency "rubocop-performance" | ||
s.add_development_dependency "rubocop-rspec" | ||
s.add_development_dependency "simplecov" | ||
s.add_development_dependency "vcr" | ||
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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require "http" | ||
|
||
require "eml/version" | ||
require "eml/api_operations" | ||
require "eml/uk" | ||
|
||
module EML | ||
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
module APIOperation | ||
module Create | ||
def create(params = {}) | ||
request(:post, resource_url, params) | ||
end | ||
end | ||
end | ||
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
module APIOperation | ||
module List | ||
def list(filters = {}) | ||
request(:get, resource_url, filters) | ||
end | ||
end | ||
end | ||
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,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
module APIOperation | ||
module Request | ||
module ClassMethods | ||
def request(method, url, params = {}) | ||
end | ||
end | ||
|
||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
end | ||
end | ||
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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require "eml/api_operation/create" | ||
require "eml/api_operation/request" |
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require "eml/error/rest" | ||
|
||
module EML | ||
# Error is the base class for more specific EML errors | ||
class Error | ||
attr_reader :message | ||
|
||
def initialize(message = nil) | ||
@message = message | ||
end | ||
end | ||
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,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
class AuthenticationError < Error | ||
end | ||
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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require "eml/uk/api_resource" | ||
require "eml/uk/config" | ||
require "eml/uk/resources" | ||
|
||
module EML | ||
module UK | ||
end | ||
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
class APIResource | ||
def resource_url | ||
if id.present? | ||
"#{self::ENDPOINT_BASE}/#{id}" | ||
else | ||
self::ENDPOINT_BASE | ||
end | ||
end | ||
end | ||
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
module UK | ||
class << self | ||
def configure | ||
yield config | ||
end | ||
|
||
def config | ||
@config ||= Config.new | ||
end | ||
end | ||
|
||
class Config | ||
attr_accessor :username | ||
attr_accessor :password | ||
attr_accessor :merchant | ||
attr_accessor :program | ||
end | ||
end | ||
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,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require "eml/uk/resources/card" |
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module EML | ||
VERSION = "0.0.1" | ||
end |
Oops, something went wrong.