synapsis_v3 0.1.9 → 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
  SHA1:
3
- metadata.gz: f4266fcf96a04f79fae0c9260cf61586692e769e
4
- data.tar.gz: 310f3471c1d8ba5610115c825d7ff88dc659eddb
3
+ metadata.gz: 724c68fcd11ae1a462c6c00849cb46bf9fc821d4
4
+ data.tar.gz: 668d2978dbf8c66f931a699abe2396bc320d3bbc
5
5
  SHA512:
6
- metadata.gz: 6edbcc2b5f0aaec719752dd4f212254990b821d0bc1a2fbb3bb97c1effa931ca4f05185761d6fca3bfef88496f472dc794083f20aa26abaec0a3e36a3950a3f7
7
- data.tar.gz: 95a0ea90d3a9a5c8c21860aaccc230212891ca8b093bac1bd10b2bfabbe88b4eef056848d8be5628fc3859a1e7cd2c613e1f78ce638a27f5537fb918d1539a95
6
+ metadata.gz: a92724b124e96d312d10d66c3fd89873192188186d84ce8f83f3e204cb7964b9804cb8d3722d4bf37f03b3bf55f966b9e3444693ad4a912b03dff3b19d97531d
7
+ data.tar.gz: f337994e970ef538506e720d1cceac3ccace529b320b82fd5c0837db6072bbef2e1d76ff93943849363f0e7bbe2c72a6a7eefe6c44a8409d9a39eca420d70d7f
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /spec/config.yml
11
+ /spec/config-test.yml
12
+ /spec/config-production.yml
data/README.md CHANGED
@@ -1,39 +1,16 @@
1
1
  # SynapsisV3
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/synapsis_v3`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Ruby wrapper to the SynapsePay API
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Running the Gem
6
6
 
7
- ## Installation
7
+ Synapsis.configure do |config|
8
+ config.client_id = 'YOUR CLIENT ID'
9
+ config.client_secret = 'YOUR CLIENT SECRET'
10
+ config.environment = 'YOUR ENVIRONMENT--defaults to test, set to "production" to access the production URL'
11
+ config.logging = true # false by default, logs request and response data when set to true
12
+ end
8
13
 
9
- Add this line to your application's Gemfile:
14
+ ## Running the tests
10
15
 
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
16
+ To run tests, sign up for a SynapsePay account, and create a spec/config-test.yml with a client_id and a client_secret.
@@ -1,8 +1,17 @@
1
1
  class Synapsis::APIResource
2
- def self.request(method = :post, url, params)
3
-
2
+ def self.request(method, url, params, oauth_key: nil, fingerprint: nil, ip_address: nil)
4
3
  Synapsis.connection.send(method) do |req|
5
4
  req.headers['Content-Type'] = 'application/json'
5
+ req.headers['X-SP-GATEWAY'] = "#{Synapsis.client_id}|#{Synapsis.client_secret}"
6
+
7
+ if oauth_key && fingerprint
8
+ req.headers['X-SP-USER'] = "#{oauth_key}|#{fingerprint}"
9
+ end
10
+
11
+ if ip_address
12
+ req.headers['X-SP-USER-IP'] = ip_address
13
+ end
14
+
6
15
  req.url url
7
16
  req.body = JSON.generate(params)
8
17
  end
@@ -4,6 +4,16 @@ require 'base64'
4
4
  class Synapsis::User < Synapsis::APIResource
5
5
  extend Synapsis::APIOperations::Create
6
6
 
7
+ module DocumentStatus
8
+ MISSING_INVALID = 'MISSING|INVALID'
9
+ RESUBMIT_INVALID = 'RESUBMIT|INVALID'
10
+ SUBMITTED = 'SUBMITTED'
11
+ SUBMITTED_REVIEWING = 'SUBMITTED|REVIEWING'
12
+ SUBMITTED_MFA_PENDING = 'SUBMITTED|MFA_PENDING'
13
+ SUBMITTED_INVALID = 'SUBMITTED|INVALID'
14
+ SUBMITTED_VALID = 'SUBMITTED|VALID'
15
+ end
16
+
7
17
  def self.create(params)
8
18
  payload = params.merge(client_credentials)
9
19
 
@@ -1,3 +1,3 @@
1
1
  module SynapsisV3
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/synapsis_v3.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'faraday/detailed_logger'
2
3
  require 'ostruct'
3
4
 
4
5
  # Namespacing
@@ -20,14 +21,19 @@ API_V3_PATH = 'api/v3/'
20
21
 
21
22
  module Synapsis
22
23
  class << self
23
- attr_accessor :client_id, :client_secret, :environment
24
+ attr_accessor :client_id, :client_secret, :environment, :logging
24
25
 
25
26
  def connection
26
27
  @connection ||= Faraday.new(url: synapse_url) do |faraday|
27
- faraday.request :multipart # form-encode POST params
28
- faraday.request :url_encoded # form-encode POST params
29
- faraday.response :logger # log requests to STDOUT
30
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
28
+ faraday.request :multipart # form-encode POST params
29
+
30
+ if Synapsis.logging
31
+ faraday.response :detailed_logger # form-encode POST params
32
+ end
33
+
34
+ faraday.request :url_encoded # form-encode POST params
35
+ faraday.response :logger # log requests to STDOUT
36
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
31
37
  end
32
38
  end
33
39
 
data/synapsis_v3.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "pry"
28
28
  spec.add_development_dependency "rspec"
29
29
  spec.add_development_dependency "codeclimate-test-reporter"
30
+ spec.add_development_dependency "faraday-detailed_logger"
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapsis_v3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daryll Santos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faraday-detailed_logger
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: Ruby interface to the SynapsePayments API (v3)
126
140
  email:
127
141
  - daryll.santos@gmail.com