synapsis_v3 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e9cb2b334699ec8e027efc7ade05d95601aabeed
4
+ data.tar.gz: 97fe6e1fcdebcc9f0599b69fd9aedbaf4378df19
5
+ SHA512:
6
+ metadata.gz: 8b3d24d06b86fc799b50b964ab6f78d148cc5ee2e65789e47669b9ea32df8f0b7bf54c8ae3d5e814f47a655b2b784b04965e558c0ac3ad892c3afb13307029f5
7
+ data.tar.gz: 0310e156e4742dbd60ba84ba5c330677f555159b12cf2a13d84aef20606e201267c21e09ef4f4c10b9365dd5204b2a92a2ddc9063f244f82cfccbcf638b7ef0d
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/config.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.1
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in synapsis_v3.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Daryll Santos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # SynapsisV3
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/synapsis_v3`. 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
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'synapsis_v3'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install synapsis_v3
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/synapsis_v3/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "synapsis_v3"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ require 'faraday'
2
+ require 'ostruct'
3
+
4
+ # Namespacing
5
+ module Synapsis
6
+ module APIOperations; end
7
+ end
8
+
9
+ require "synapsis_v3/version"
10
+ require "synapsis_v3/api_resource"
11
+ require "synapsis_v3/api_operations/create"
12
+ require "synapsis_v3/error"
13
+ require "synapsis_v3/user"
14
+ require "synapsis_v3/node"
15
+ require "synapsis_v3/transaction"
16
+
17
+ API_V3_PATH = 'api/v3/'
18
+
19
+ module Synapsis
20
+ class << self
21
+ attr_accessor :client_id, :client_secret, :environment
22
+
23
+ def connection
24
+ @connection ||= Faraday.new(url: synapse_url) do |faraday|
25
+ faraday.request :multipart # form-encode POST params
26
+ faraday.request :url_encoded # form-encode POST params
27
+ faraday.response :logger # log requests to STDOUT
28
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
29
+ end
30
+ end
31
+
32
+ def synapse_url
33
+ if environment == 'production'
34
+ 'https://synapsepay.com/'
35
+ else
36
+ 'https://sandbox.synapsepay.com/'
37
+ end
38
+ end
39
+
40
+ def configure(&params)
41
+ yield(self)
42
+ end
43
+ end
44
+
45
+ class Response < OpenStruct; end
46
+ end
@@ -0,0 +1,10 @@
1
+ module Synapsis::APIOperations::Create
2
+ def create_request(params)
3
+ request(:post, create_url, params)
4
+ end
5
+
6
+ def create_url
7
+ "#{API_V3_PATH}#{class_name}/create"
8
+ end
9
+ end
10
+
@@ -0,0 +1,43 @@
1
+ class Synapsis::APIResource
2
+ def self.request(method = :post, url, params)
3
+
4
+ Synapsis.connection.send(method) do |req|
5
+ req.headers['Content-Type'] = 'application/json'
6
+ req.url url
7
+ req.body = JSON.generate(params)
8
+ end
9
+ end
10
+
11
+ def self.class_name
12
+ name.partition('::').last.downcase
13
+ end
14
+
15
+ def class_name
16
+ self.class.name.partition('::').last.downcase
17
+ end
18
+
19
+ def self.return_response(response)
20
+ parsed_response = JSON.parse(response.body, object_class: Synapsis::Response)
21
+
22
+ if response.success?
23
+ return parsed_response
24
+ else
25
+ raise Synapsis::Error, parsed_response[class_name] || parsed_response['reason'] || parsed_response['error']['en']
26
+ end
27
+ end
28
+
29
+ def self.parse_as_synapse_resource(response)
30
+ return JSON.parse(response.body, object_class: Synapsis::Response)
31
+ end
32
+
33
+ protected
34
+
35
+ def self.client_credentials
36
+ {
37
+ "client" => {
38
+ "client_id" => Synapsis.client_id,
39
+ "client_secret" => Synapsis.client_secret
40
+ }
41
+ }
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ class Synapsis::Error < StandardError; end
@@ -0,0 +1,36 @@
1
+ class Synapsis::Node < Synapsis::APIResource
2
+ module AccountType
3
+ PERSONAL = 'PERSONAL'
4
+ BUSINESS = 'BUSINESS'
5
+ end
6
+
7
+ module AccountClass
8
+ CHECKING = 'CHECKING'
9
+ SAVINGS = 'SAVINGS'
10
+ end
11
+
12
+ # Synapse uses the same endpoint for other Synapse accounts, Account/Routing number, Bank Login, Wire-US, Wire-INT
13
+ # Add via bank username/password
14
+ # <Synapsis::Response nodes=[#<Synapsis::Response _id=#<Synapsis::Response $oid="55bf217b86c2734342eccfe3">, allowed="CREDIT-AND-DEBIT", extra=#<Synapsis::Response supp_id=nil>, info=#<Synapsis::Response access_token="not_found", account_num="6789", balance=#<Synapsis::Response amount="70.69", currency="USD">, bank_name="bofa", class="CHECKING", name_on_account="Sample User", nickname="LIFEGREEN CHECKING F", routing_num="0017", type="PERSONAL">, is_active=true, type="ACH-US">], success=true>
15
+ # Add via account number/routing number
16
+ # <Synapsis::Response nodes=[#<Synapsis::Response _id=#<Synapsis::Response $oid="55bf275586c2734342eccfed">, allowed="CREDIT", extra=#<Synapsis::Response supp_id="123sa">, info=#<Synapsis::Response account_num="7443", class="CHECKING", name_on_account="Sankaet Pathak", nickname="Savings Account", routing_num="0017", type="PERSONAL">, is_active=true, type="ACH-US">], success=true>
17
+
18
+ def self.add(params)
19
+ add_node_url = "#{API_V3_PATH}node/add"
20
+
21
+ response = request(:post, add_node_url, params)
22
+ return_response(response)
23
+ end
24
+
25
+ # Verify via MFA
26
+ # <Synapsis::Response nodes=[#<Synapsis::Response _id=#<Synapsis::Response $oid="55bf34aa86c27361bed754ab">, allowed="CREDIT-AND-DEBIT", extra=#<Synapsis::Response supp_id=nil>, info=#<Synapsis::Response access_token="not_found", account_num="6789", balance=#<Synapsis::Response amount="70.69", currency="USD">, bank_name="bofa", class="CHECKING", name_on_account="Sample User", nickname="LIFEGREEN CHECKING F", routing_num="0017", type="PERSONAL">, is_active=true, type="ACH-US">], success=true>
27
+ # Verify via account number/routing number
28
+ # Synapsis::Response nodes=[#<Synapsis::Response _id=#<Synapsis::Response $oid="55bf327d86c27361bed754a9">, allowed="CREDIT-AND-DEBIT", extra=#<Synapsis::Response supp_id="123sa">, info=#<Synapsis::Response account_num="7443", class="CHECKING", name_on_account="Sankaet Pathak", nickname="Savings Account", routing_num="0017", type="PERSONAL">, is_active=true, type="ACH-US">], success=true>
29
+ def self.verify(params)
30
+ verify_node_url = "#{API_V3_PATH}node/verify"
31
+
32
+ response = request(:post, verify_node_url, params)
33
+ return_response(response)
34
+ end
35
+ end
36
+
@@ -0,0 +1,16 @@
1
+ class Synapsis::Transaction < Synapsis::APIResource
2
+
3
+ # Synapse uses the same endpoint for other Synapse accounts, Account/Routing number, Bank Login, Wire-US, Wire-INT
4
+ # Add via bank username/password
5
+ # <Synapsis::Response nodes=[#<Synapsis::Response _id=#<Synapsis::Response $oid="55bf217b86c2734342eccfe3">, allowed="CREDIT-AND-DEBIT", extra=#<Synapsis::Response supp_id=nil>, info=#<Synapsis::Response access_token="not_found", account_num="6789", balance=#<Synapsis::Response amount="70.69", currency="USD">, bank_name="bofa", class="CHECKING", name_on_account="Sample User", nickname="LIFEGREEN CHECKING F", routing_num="0017", type="PERSONAL">, is_active=true, type="ACH-US">], success=true>
6
+ # Add via account number/routing number
7
+ # <Synapsis::Response nodes=[#<Synapsis::Response _id=#<Synapsis::Response $oid="55bf275586c2734342eccfed">, allowed="CREDIT", extra=#<Synapsis::Response supp_id="123sa">, info=#<Synapsis::Response account_num="7443", class="CHECKING", name_on_account="Sankaet Pathak", nickname="Savings Account", routing_num="0017", type="PERSONAL">, is_active=true, type="ACH-US">], success=true>
8
+
9
+ def self.add(params)
10
+ add_transaction_url = "#{API_V3_PATH}trans/add"
11
+
12
+ response = request(:post, add_transaction_url, params)
13
+ return_response(response)
14
+ end
15
+ end
16
+
@@ -0,0 +1,41 @@
1
+ class Synapsis::User < Synapsis::APIResource
2
+ extend Synapsis::APIOperations::Create
3
+
4
+ def self.create(params)
5
+ payload = params.merge(client_credentials)
6
+
7
+ response = create_request(payload)
8
+ return_response(response)
9
+ end
10
+
11
+ def self.sign_in(params)
12
+ sign_in_url = "#{API_V3_PATH}#{class_name}/signin"
13
+
14
+ payload = params.merge(client_credentials)
15
+
16
+ response = request(:post, sign_in_url, payload)
17
+ return_response(response)
18
+ end
19
+
20
+ def self.add_kyc(params)
21
+ add_kyc_url = "#{API_V3_PATH}#{class_name}/doc/add"
22
+
23
+ response = request(:post, add_kyc_url, params)
24
+ return_response(response)
25
+ end
26
+
27
+ def self.verify_kyc(params)
28
+ verify_kyc_url = "#{API_V3_PATH}#{class_name}/doc/verify"
29
+
30
+ response = request(:post, verify_kyc_url, params)
31
+ return_response(response)
32
+ end
33
+
34
+ def self.add_document(params)
35
+ add_document_url = "#{API_V3_PATH}user/doc/attachments/add"
36
+
37
+ response = request(:post, add_document_url, params)
38
+ return_response(response)
39
+ end
40
+ end
41
+
@@ -0,0 +1,3 @@
1
+ module SynapsisV3
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'synapsis_v3/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "synapsis_v3"
8
+ spec.version = SynapsisV3::VERSION
9
+ spec.authors = ["Daryll Santos"]
10
+ spec.email = ["daryll.santos@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby interface to the SynapsePayments API (v3)}
13
+ spec.description = %q{Ruby interface to the SynapsePayments API (v3)}
14
+ spec.homepage = "http://github.com/sourcepad/synapsis_v3"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "faraday", "0.9.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "faker", "~> 1.4.3"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "rspec"
28
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: synapsis_v3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daryll Santos
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faker
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.4.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.4.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby interface to the SynapsePayments API (v3)
98
+ email:
99
+ - daryll.santos@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".ruby-version"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - lib/synapsis_v3.rb
116
+ - lib/synapsis_v3/api_operations/create.rb
117
+ - lib/synapsis_v3/api_resource.rb
118
+ - lib/synapsis_v3/error.rb
119
+ - lib/synapsis_v3/node.rb
120
+ - lib/synapsis_v3/transaction.rb
121
+ - lib/synapsis_v3/user.rb
122
+ - lib/synapsis_v3/version.rb
123
+ - synapsis_v3.gemspec
124
+ homepage: http://github.com/sourcepad/synapsis_v3
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.4.5
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Ruby interface to the SynapsePayments API (v3)
148
+ test_files: []