dfcapi 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +4 -0
 - data/.travis.yml +13 -0
 - data/Gemfile +5 -0
 - data/LICENSE +22 -0
 - data/README.md +34 -0
 - data/Rakefile +10 -0
 - data/dfcapi.gemspec +26 -0
 - data/lib/dfcapi.rb +305 -0
 - data/test/dfcapi_test.rb +110 -0
 - metadata +151 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fe8c3fc4432eee3d5d51bfc1572554490fb4e71c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2a96f2895c3b361577eb140b9b73c11c063724f1
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bbf247e298234cbb8b9e2300c66561158aa87e46147e2fee2b3bbdab4a53b035aa3dcc703bb79f1d5839858b5996fb98dea9e79da537d29c663571021925f12c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6f2d0ef46fc379cff2c2c76a8a7916ebc7e5578d4839d2cffaa39b7248c50221ca4c5a5b003373162809d5e7befb6d906f3553e468205e645eabaaaf192409da
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2014 Debit Finance Collections Plc (http://debitfinance.co.uk)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # DFCAPI for Ruby [](https://travis-ci.org/dfcplc/dfcapi-ruby)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            The DFC API is a Restful API which has been built to facilitate the ability to Setup/Ammend/Cancel & View Direct Debits with Debit Finance Collections Plc
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installing
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Requirements: **Ruby >= 2.0**
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            To utilize the DFC API Client Library, install the `dfcapi` gem:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
            gem install dfcapi
         
     | 
| 
      
 13 
     | 
    
         
            +
            ```
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            After installing the gem package you can now begin to simplifying requests by requiring `dfcapi`:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 18 
     | 
    
         
            +
            require 'dfcapi'
         
     | 
| 
      
 19 
     | 
    
         
            +
            ```
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ## Checking API Credentials
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            In order to validate your API Credentials against our API, call the `checkApiKey` method:
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 26 
     | 
    
         
            +
            dfcapi_check = Dfcapi.checkApiKey('TEST-TEST-TEST-TEST', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            dfcapi_check # API Credential Check Response (true or false)
         
     | 
| 
      
 29 
     | 
    
         
            +
            ```
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            <hr>
         
     | 
| 
      
 32 
     | 
    
         
            +
            ### Thanks
         
     | 
| 
      
 33 
     | 
    
         
            +
            Thanks go out to:
         
     | 
| 
      
 34 
     | 
    
         
            +
            * [thefosk](https://github.com/thefosk) @ [mashape.com](https://mashape.com) - Unirest Restful Library
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/dfcapi.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 2 
     | 
    
         
            +
              s.name        = 'dfcapi'
         
     | 
| 
      
 3 
     | 
    
         
            +
              s.version     = '1.0.0'
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.summary     = "DFCAPI-Ruby"
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.description = "DFC API - PHP Client Library"
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.authors     = ["Debit Finance Collections Plc"]
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.email       = 'development@debitfinance.co.uk'
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.homepage    = 'https://github.com/dfcplc/dfcapi-ruby'
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.license     = 'MIT'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            	s.add_dependency('rest-client', '~> 1.6.7')
         
     | 
| 
      
 12 
     | 
    
         
            +
            	s.add_dependency('json', '~> 1.8.1')
         
     | 
| 
      
 13 
     | 
    
         
            +
            	s.add_dependency('addressable', '~> 2.3.5')
         
     | 
| 
      
 14 
     | 
    
         
            +
                s.add_dependency('unirest', '~> 1.1.2')
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            	s.add_development_dependency('shoulda', '~> 3.5.0')
         
     | 
| 
      
 17 
     | 
    
         
            +
            	s.add_development_dependency('test-unit')
         
     | 
| 
      
 18 
     | 
    
         
            +
            	s.add_development_dependency('rake')
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            	s.required_ruby_version = '~> 2.0'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              s.files       = `git ls-files`.split("\n")
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.test_files    = `git ls-files -- test/*`.split("\n")
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.require_paths = ['lib']
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/dfcapi.rb
    ADDED
    
    | 
         @@ -0,0 +1,305 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # The MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright (c) 2014 Debit Finance Collections Plc (http://debitfinance.co.uk)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            # a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            # "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            # permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            # the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
            #
         
     | 
| 
      
 13 
     | 
    
         
            +
            # The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            # included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
            #
         
     | 
| 
      
 16 
     | 
    
         
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
| 
      
 23 
     | 
    
         
            +
            #
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 26 
     | 
    
         
            +
            require 'unirest'
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            module Dfcapi
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              @@api_url_checkkey = "https://api.debitfinance.co.uk/checkkey"
         
     | 
| 
      
 31 
     | 
    
         
            +
              @@api_url_viewdd = "https://api.debitfinance.co.uk/viewdd"
         
     | 
| 
      
 32 
     | 
    
         
            +
              @@api_url_viewddbreakdown = "https://api.debitfinance.co.uk/viewddbreakdown"
         
     | 
| 
      
 33 
     | 
    
         
            +
              @@api_url_setupdd = "https://api.debitfinance.co.uk/setupdd"
         
     | 
| 
      
 34 
     | 
    
         
            +
              @@api_url_updatedd = "https://api.debitfinance.co.uk/updatedd"
         
     | 
| 
      
 35 
     | 
    
         
            +
              @@api_url_canceldd = "https://api.debitfinance.co.uk/canceldd"
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              @@errors = {}
         
     | 
| 
      
 38 
     | 
    
         
            +
              @@response_code = false
         
     | 
| 
      
 39 
     | 
    
         
            +
              @@body = false
         
     | 
| 
      
 40 
     | 
    
         
            +
              @@raw_body = false
         
     | 
| 
      
 41 
     | 
    
         
            +
              @@headers = {}
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def self.setCheckKeyUrl(checkkey_url)
         
     | 
| 
      
 44 
     | 
    
         
            +
                @@api_url_checkkey = checkkey_url
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              def self.setViewDirectDebitUrl(viewdd_url)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @@api_url_viewdd = viewdd_url
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def self.setViewDirectDebitBreakdownUrl(viewddbreakdown_url)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @@api_url_viewddbreakdown = viewddbreakdown_url
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              def self.setCreateDirectDebitUrl(setupdd_url)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @@api_url_setupdd = setupdd_url
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              def self.setUpdateDirectDebitUrl(updatedd_url)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  @@api_url_updatedd = updatedd_url
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              def self.setCancelDirectDebitUrl(canceldd_url)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  @@api_url_canceldd = canceldd_url
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              def self.clearStoredResponse
         
     | 
| 
      
 68 
     | 
    
         
            +
                  @@errors = {}
         
     | 
| 
      
 69 
     | 
    
         
            +
                  @@response_code = false
         
     | 
| 
      
 70 
     | 
    
         
            +
                  @@body = false
         
     | 
| 
      
 71 
     | 
    
         
            +
                  @@raw_body = false
         
     | 
| 
      
 72 
     | 
    
         
            +
                  @@headers = {}
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              def self.getErrors
         
     | 
| 
      
 76 
     | 
    
         
            +
                  return @@errors
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              def self.getResponseCode
         
     | 
| 
      
 80 
     | 
    
         
            +
                  return @@response_code
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              def self.getResponseBody
         
     | 
| 
      
 84 
     | 
    
         
            +
                  return @@body
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              def self.getResponseBodyRaw
         
     | 
| 
      
 88 
     | 
    
         
            +
                  return @@raw_body
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              def self.getResponseHeaders
         
     | 
| 
      
 92 
     | 
    
         
            +
                  return @@headers
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              def self.setStoredResponse(response)
         
     | 
| 
      
 96 
     | 
    
         
            +
                  @@errors = response.body['errors']
         
     | 
| 
      
 97 
     | 
    
         
            +
                  @@response_code = response.code
         
     | 
| 
      
 98 
     | 
    
         
            +
                  @@body = response.body
         
     | 
| 
      
 99 
     | 
    
         
            +
                  @@raw_body = response.raw_body
         
     | 
| 
      
 100 
     | 
    
         
            +
                  @@headers = response.headers
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              def self.checkApiKey(api_key, api_secret)
         
     | 
| 
      
 104 
     | 
    
         
            +
                self.clearStoredResponse
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                response = Unirest.get @@api_url_checkkey, auth:{:user=>api_key, :password=>api_secret}
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                self.setStoredResponse response
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                if(response.code === 200 && response.body['status'] === 'ok')
         
     | 
| 
      
 111 
     | 
    
         
            +
                  return true
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                return false
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              def self.viewDirectDebit(api_key, api_secret, dfc_reference)
         
     | 
| 
      
 120 
     | 
    
         
            +
                  self.clearStoredResponse
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                  response = Unirest.get @@api_url_viewdd, auth:{:user=>api_key, :password=>api_secret}, parameters:{ :dfc_reference => dfc_reference }
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                  self.setStoredResponse response
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                  if(response.code === 200 && response.body['status'] === 'ok')
         
     | 
| 
      
 127 
     | 
    
         
            +
                    return response.body
         
     | 
| 
      
 128 
     | 
    
         
            +
                  end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  return false
         
     | 
| 
      
 132 
     | 
    
         
            +
              end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
              def self.viewDirectDebitBreakdown(api_key, api_secret, dfc_reference)
         
     | 
| 
      
 135 
     | 
    
         
            +
                  self.clearStoredResponse
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                  response = Unirest.get @@api_url_viewddbreakdown, auth:{:user=>api_key, :password=>api_secret}, parameters:{ :dfc_reference => dfc_reference }
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                  self.setStoredResponse response
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                  if(response.code === 200 && response.body['status'] === 'ok')
         
     | 
| 
      
 142 
     | 
    
         
            +
                    return response.body
         
     | 
| 
      
 143 
     | 
    
         
            +
                  end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                  return false
         
     | 
| 
      
 147 
     | 
    
         
            +
              end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
              def self.createDirectDebit(api_key, api_secret, client_reference, reference, title, first_name, last_name, address1, address2, address3, town, county, postcode, amounts, email, account_number, sort_code, start_from, installments, frequency_unit, frequency_type, roll_status, birth_date, mobile_number, phone_number, no_email, service_description, bacs_reference, skip_check)
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                self.clearStoredResponse
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                response = Unirest.post @@api_url_setupdd,
         
     | 
| 
      
 155 
     | 
    
         
            +
                                        headers: {
         
     | 
| 
      
 156 
     | 
    
         
            +
                                          "Content-Type" => "application/json",
         
     | 
| 
      
 157 
     | 
    
         
            +
                                          "Accept" => "application/json"
         
     | 
| 
      
 158 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 159 
     | 
    
         
            +
                                        parameters: {
         
     | 
| 
      
 160 
     | 
    
         
            +
                                          :authentication => {
         
     | 
| 
      
 161 
     | 
    
         
            +
                                            :apikey => api_key,
         
     | 
| 
      
 162 
     | 
    
         
            +
                                            :apisecret => api_secret,
         
     | 
| 
      
 163 
     | 
    
         
            +
                                            :client_ref => client_reference
         
     | 
| 
      
 164 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 165 
     | 
    
         
            +
                                          :payer => {
         
     | 
| 
      
 166 
     | 
    
         
            +
                                            :title => title,
         
     | 
| 
      
 167 
     | 
    
         
            +
                                            :first_name => first_name,
         
     | 
| 
      
 168 
     | 
    
         
            +
                                            :last_name => last_name,
         
     | 
| 
      
 169 
     | 
    
         
            +
                                            :birth_date => birth_date
         
     | 
| 
      
 170 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 171 
     | 
    
         
            +
                                          :address => {
         
     | 
| 
      
 172 
     | 
    
         
            +
                                            :address1 => address1,
         
     | 
| 
      
 173 
     | 
    
         
            +
                                            :address2 => address2,
         
     | 
| 
      
 174 
     | 
    
         
            +
                                            :address3 => address3,
         
     | 
| 
      
 175 
     | 
    
         
            +
                                            :town => town,
         
     | 
| 
      
 176 
     | 
    
         
            +
                                            :county => county,
         
     | 
| 
      
 177 
     | 
    
         
            +
                                            :postcode => postcode,
         
     | 
| 
      
 178 
     | 
    
         
            +
                                            :skip_check => skip_check
         
     | 
| 
      
 179 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 180 
     | 
    
         
            +
                                          :contact => {
         
     | 
| 
      
 181 
     | 
    
         
            +
                                            :phone => phone_number,
         
     | 
| 
      
 182 
     | 
    
         
            +
                                            :mobile => mobile_number,
         
     | 
| 
      
 183 
     | 
    
         
            +
                                            :email => email,
         
     | 
| 
      
 184 
     | 
    
         
            +
                                            :no_email => no_email
         
     | 
| 
      
 185 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 186 
     | 
    
         
            +
                                          :bank => {
         
     | 
| 
      
 187 
     | 
    
         
            +
                                            :account_number => account_number,
         
     | 
| 
      
 188 
     | 
    
         
            +
                                            :sort_code => sort_code
         
     | 
| 
      
 189 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 190 
     | 
    
         
            +
                                          :subscription => {
         
     | 
| 
      
 191 
     | 
    
         
            +
                                            :reference => reference,
         
     | 
| 
      
 192 
     | 
    
         
            +
                                            :description => service_description,
         
     | 
| 
      
 193 
     | 
    
         
            +
                                            :amounts => amounts,
         
     | 
| 
      
 194 
     | 
    
         
            +
                                            :interval => {
         
     | 
| 
      
 195 
     | 
    
         
            +
                                              :unit => frequency_unit,
         
     | 
| 
      
 196 
     | 
    
         
            +
                                              :frequency => frequency_type
         
     | 
| 
      
 197 
     | 
    
         
            +
                                            },
         
     | 
| 
      
 198 
     | 
    
         
            +
                                            :start_from => start_from,
         
     | 
| 
      
 199 
     | 
    
         
            +
                                            :installments => installments,
         
     | 
| 
      
 200 
     | 
    
         
            +
                                            :bacs_reference => bacs_reference,
         
     | 
| 
      
 201 
     | 
    
         
            +
                                            :roll_status => roll_status
         
     | 
| 
      
 202 
     | 
    
         
            +
                                          }
         
     | 
| 
      
 203 
     | 
    
         
            +
                                        }.to_json
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                self.setStoredResponse response
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                if(response.code === 200 && response.body['status'] === 'ok')
         
     | 
| 
      
 208 
     | 
    
         
            +
                  return true
         
     | 
| 
      
 209 
     | 
    
         
            +
                end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                return false
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
              end
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
              def self.updateDirectDebit(api_key, api_secret, dfc_reference, reference, title, first_name, last_name, address1, address2, address3, town, county, postcode, email, account_number, sort_code, birth_date, mobile_number, phone_number, paymentdate, applyfrom_paydate, installmentduedate, installmentamount, latepayment, applyfrom, newamount)
         
     | 
| 
      
 217 
     | 
    
         
            +
                self.clearStoredResponse
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
                response = Unirest.post @@api_url_updatedd,
         
     | 
| 
      
 220 
     | 
    
         
            +
                                        headers: {
         
     | 
| 
      
 221 
     | 
    
         
            +
                                          "Content-Type" => "application/json",
         
     | 
| 
      
 222 
     | 
    
         
            +
                                          "Accept" => "application/json"
         
     | 
| 
      
 223 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 224 
     | 
    
         
            +
                                        parameters: {
         
     | 
| 
      
 225 
     | 
    
         
            +
                                          :authentication => {
         
     | 
| 
      
 226 
     | 
    
         
            +
                                            :apikey => api_key,
         
     | 
| 
      
 227 
     | 
    
         
            +
                                            :apisecret => api_secret,
         
     | 
| 
      
 228 
     | 
    
         
            +
                                            :dfc_ref => dfc_reference
         
     | 
| 
      
 229 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 230 
     | 
    
         
            +
                                          :payer => {
         
     | 
| 
      
 231 
     | 
    
         
            +
                                            :title => title,
         
     | 
| 
      
 232 
     | 
    
         
            +
                                            :first_name => first_name,
         
     | 
| 
      
 233 
     | 
    
         
            +
                                            :last_name => last_name,
         
     | 
| 
      
 234 
     | 
    
         
            +
                                            :birth_date => birth_date
         
     | 
| 
      
 235 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 236 
     | 
    
         
            +
                                          :address => {
         
     | 
| 
      
 237 
     | 
    
         
            +
                                            :address1 => address1,
         
     | 
| 
      
 238 
     | 
    
         
            +
                                            :address2 => address2,
         
     | 
| 
      
 239 
     | 
    
         
            +
                                            :address3 => address3,
         
     | 
| 
      
 240 
     | 
    
         
            +
                                            :town => town,
         
     | 
| 
      
 241 
     | 
    
         
            +
                                            :county => county,
         
     | 
| 
      
 242 
     | 
    
         
            +
                                            :postcode => postcode
         
     | 
| 
      
 243 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 244 
     | 
    
         
            +
                                          :contact => {
         
     | 
| 
      
 245 
     | 
    
         
            +
                                            :phone => phone_number,
         
     | 
| 
      
 246 
     | 
    
         
            +
                                            :mobile => mobile_number,
         
     | 
| 
      
 247 
     | 
    
         
            +
                                            :email => email
         
     | 
| 
      
 248 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 249 
     | 
    
         
            +
                                          :bank => {
         
     | 
| 
      
 250 
     | 
    
         
            +
                                            :account_number => account_number,
         
     | 
| 
      
 251 
     | 
    
         
            +
                                            :sort_code => sort_code
         
     | 
| 
      
 252 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 253 
     | 
    
         
            +
                                          :general => {
         
     | 
| 
      
 254 
     | 
    
         
            +
                                            :yourref => reference,
         
     | 
| 
      
 255 
     | 
    
         
            +
                                            :paymentdate => paymentdate,
         
     | 
| 
      
 256 
     | 
    
         
            +
                                            :installmentduedate => installmentduedate,
         
     | 
| 
      
 257 
     | 
    
         
            +
                                            :installmentamount => installmentamount,
         
     | 
| 
      
 258 
     | 
    
         
            +
                                            :latepayment => latepayment,
         
     | 
| 
      
 259 
     | 
    
         
            +
                                            :applyfrom => applyfrom,
         
     | 
| 
      
 260 
     | 
    
         
            +
                                            :applyfrom_paydate => applyfrom_paydate,
         
     | 
| 
      
 261 
     | 
    
         
            +
                                            :newamount => newamount
         
     | 
| 
      
 262 
     | 
    
         
            +
                                          }
         
     | 
| 
      
 263 
     | 
    
         
            +
                                        }.to_json
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
                self.setStoredResponse response
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 267 
     | 
    
         
            +
                if(response.code === 200 && response.body['status'] === 'ok')
         
     | 
| 
      
 268 
     | 
    
         
            +
                  return true
         
     | 
| 
      
 269 
     | 
    
         
            +
                end
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
                return false
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
              end
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
              def self.cancelDirectDebit(api_key, api_secret, dfc_reference, cancel_date)
         
     | 
| 
      
 277 
     | 
    
         
            +
                self.clearStoredResponse
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                response = Unirest.post @@api_url_canceldd,
         
     | 
| 
      
 280 
     | 
    
         
            +
                                        headers: {
         
     | 
| 
      
 281 
     | 
    
         
            +
                                          "Content-Type" => "application/json",
         
     | 
| 
      
 282 
     | 
    
         
            +
                                          "Accept" => "application/json"
         
     | 
| 
      
 283 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 284 
     | 
    
         
            +
                                        parameters: {
         
     | 
| 
      
 285 
     | 
    
         
            +
                                          :authentication => {
         
     | 
| 
      
 286 
     | 
    
         
            +
                                            :apikey => api_key,
         
     | 
| 
      
 287 
     | 
    
         
            +
                                            :apisecret => api_secret,
         
     | 
| 
      
 288 
     | 
    
         
            +
                                            :dfc_ref => dfc_reference
         
     | 
| 
      
 289 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 290 
     | 
    
         
            +
                                          :cancel => {
         
     | 
| 
      
 291 
     | 
    
         
            +
                                            :apply_from => cancel_date
         
     | 
| 
      
 292 
     | 
    
         
            +
                                          }
         
     | 
| 
      
 293 
     | 
    
         
            +
                                        }.to_json
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
                self.setStoredResponse response
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
                if(response.code === 200 && response.body['status'] === 'ok')
         
     | 
| 
      
 298 
     | 
    
         
            +
                  return true
         
     | 
| 
      
 299 
     | 
    
         
            +
                end
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
                return false
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
              end
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
            end
         
     | 
    
        data/test/dfcapi_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,110 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # The MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright (c) 2014 Debit Finance Collections Plc (http://debitfinance.co.uk)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            # a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            # "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            # permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            # the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
            #
         
     | 
| 
      
 13 
     | 
    
         
            +
            # The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            # included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
            #
         
     | 
| 
      
 16 
     | 
    
         
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
| 
      
 23 
     | 
    
         
            +
            #
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            require_relative '../lib/dfcapi'
         
     | 
| 
      
 26 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 27 
     | 
    
         
            +
            require 'shoulda'
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            module Dfcapi
         
     | 
| 
      
 30 
     | 
    
         
            +
              class ApiTest < Test::Unit::TestCase
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                should "Check API Key" do
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  Dfcapi.setCheckKeyUrl('http://httpbin.org/get')
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  Dfcapi.checkApiKey('TEST-TEST-TEST-TEST', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  assert Dfcapi.getResponseCode() == 200
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  headers = Dfcapi.getResponseBody()['headers']
         
     | 
| 
      
 41 
     | 
    
         
            +
                  assert headers['Authorization'] == "Basic VEVTVC1URVNULVRFU1QtVEVTVDphOTRhOGZlNWNjYjE5YmE2MWM0YzA4NzNkMzkxZTk4Nzk4MmZiYmQz"
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                should "View Direct Debit" do
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    Dfcapi.setViewDirectDebitUrl('http://httpbin.org/get')
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    Dfcapi.viewDirectDebit('TEST-TEST-TEST-TEST', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', '000101AA0001')
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    assert Dfcapi.getResponseCode() == 200
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    headers = Dfcapi.getResponseBody()['headers']
         
     | 
| 
      
 54 
     | 
    
         
            +
                    assert headers['Authorization'] == "Basic VEVTVC1URVNULVRFU1QtVEVTVDphOTRhOGZlNWNjYjE5YmE2MWM0YzA4NzNkMzkxZTk4Nzk4MmZiYmQz"
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    assert Dfcapi.getResponseBody()['args']['dfc_reference'] == "000101AA0001"
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                should "View Direct Debit Breakdown" do
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                    Dfcapi.setViewDirectDebitBreakdownUrl('http://httpbin.org/get')
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                    Dfcapi.viewDirectDebitBreakdown('TEST-TEST-TEST-TEST', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', '000101AA0001')
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                    assert Dfcapi.getResponseCode() == 200
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    headers = Dfcapi.getResponseBody()['headers']
         
     | 
| 
      
 69 
     | 
    
         
            +
                    assert headers['Authorization'] == "Basic VEVTVC1URVNULVRFU1QtVEVTVDphOTRhOGZlNWNjYjE5YmE2MWM0YzA4NzNkMzkxZTk4Nzk4MmZiYmQz"
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                    assert Dfcapi.getResponseBody()['args']['dfc_reference'] == "000101AA0001"
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                should "Setup Direct Debit" do
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                    Dfcapi.setCreateDirectDebitUrl('http://httpbin.org/post')
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                    Dfcapi.createDirectDebit('TEST-TEST-TEST-TEST','fee78bd3bf59bfb36238b3f67de0a6ea103de130','0001','ABC00001','Mr','Joe','Bloggs','1 Park Lane','','','London','','E15 2JG',[10,10,10,10,10,10,10,10,10,10,10,10],'joebloggs@email.com','00000000','000000','2015-01-01',12,1,'MONTH','Y','1970-01-01','01234567890','07777777777','Y','Gym Membership','', false)
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                    assert Dfcapi.getResponseCode() == 200
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                    assert Dfcapi.getResponseBody()['data'] == '{"authentication":{"apikey":"TEST-TEST-TEST-TEST","apisecret":"fee78bd3bf59bfb36238b3f67de0a6ea103de130","client_ref":"0001"},"payer":{"title":"Mr","first_name":"Joe","last_name":"Bloggs","birth_date":"1970-01-01"},"address":{"address1":"1 Park Lane","address2":"","address3":"","town":"London","county":"","postcode":"E15 2JG","skip_check":false},"contact":{"phone":"07777777777","mobile":"01234567890","email":"joebloggs@email.com","no_email":"Y"},"bank":{"account_number":"00000000","sort_code":"000000"},"subscription":{"reference":"ABC00001","description":"Gym Membership","amounts":[10,10,10,10,10,10,10,10,10,10,10,10],"interval":{"unit":1,"frequency":"MONTH"},"start_from":"2015-01-01","installments":12,"bacs_reference":"","roll_status":"Y"}}'
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                should "Update Direct Debit" do
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                    Dfcapi.setUpdateDirectDebitUrl('http://httpbin.org/post')
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                    Dfcapi.updateDirectDebit('TEST-TEST-TEST-TEST','fee78bd3bf59bfb36238b3f67de0a6ea103de130','000101AA0001','','','','','','','','','','','','','','','','','15','012015','','','','','')
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                    assert Dfcapi.getResponseCode() == 200
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                    assert Dfcapi.getResponseBody()['data'] == '{"authentication":{"apikey":"TEST-TEST-TEST-TEST","apisecret":"fee78bd3bf59bfb36238b3f67de0a6ea103de130","dfc_ref":"000101AA0001"},"payer":{"title":"","first_name":"","last_name":"","birth_date":""},"address":{"address1":"","address2":"","address3":"","town":"","county":"","postcode":""},"contact":{"phone":"","mobile":"","email":""},"bank":{"account_number":"","sort_code":""},"general":{"yourref":"","paymentdate":"15","installmentduedate":"","installmentamount":"","latepayment":"","applyfrom":"","applyfrom_paydate":"012015","newamount":""}}'
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                should "Cancel Direct Debit" do
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                    Dfcapi.setCancelDirectDebitUrl('http://httpbin.org/post')
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                    Dfcapi.cancelDirectDebit('TEST-TEST-TEST-TEST', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', '000101AA0001', '2015-01-01')
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                    assert Dfcapi.getResponseCode() == 200
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                    assert Dfcapi.getResponseBody()['data'] == '{"authentication":{"apikey":"TEST-TEST-TEST-TEST","apisecret":"a94a8fe5ccb19ba61c4c0873d391e987982fbbd3","dfc_ref":"000101AA0001"},"cancel":{"apply_from":"2015-01-01"}}'
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,151 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: dfcapi
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Debit Finance Collections Plc
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-04-11 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: rest-client
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 1.6.7
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 1.6.7
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: json
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 1.8.1
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: 1.8.1
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: addressable
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: 2.3.5
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: 2.3.5
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: unirest
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: 1.1.2
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: 1.1.2
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: shoulda
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: 3.5.0
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: 3.5.0
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: test-unit
         
     | 
| 
      
 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 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 111 
     | 
    
         
            +
            description: DFC API - PHP Client Library
         
     | 
| 
      
 112 
     | 
    
         
            +
            email: development@debitfinance.co.uk
         
     | 
| 
      
 113 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 114 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 115 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 116 
     | 
    
         
            +
            files:
         
     | 
| 
      
 117 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 118 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 119 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 120 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 121 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 122 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 123 
     | 
    
         
            +
            - dfcapi.gemspec
         
     | 
| 
      
 124 
     | 
    
         
            +
            - lib/dfcapi.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            - test/dfcapi_test.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
            homepage: https://github.com/dfcplc/dfcapi-ruby
         
     | 
| 
      
 127 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 128 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 129 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 130 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 131 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 132 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 133 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 134 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 135 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 136 
     | 
    
         
            +
              - - "~>"
         
     | 
| 
      
 137 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 138 
     | 
    
         
            +
                  version: '2.0'
         
     | 
| 
      
 139 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 140 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 141 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 142 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 143 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 144 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 145 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 146 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
      
 147 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 148 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 149 
     | 
    
         
            +
            summary: DFCAPI-Ruby
         
     | 
| 
      
 150 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 151 
     | 
    
         
            +
            - test/dfcapi_test.rb
         
     |