payson_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,8 +2,7 @@ source :rubygems
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'require_all'
6
- gem 'rest-client'
5
+ gem 'httpclient'
7
6
 
8
7
  group :test, :development do
9
8
  gem 'guard-test'
data/lib/payson_api.rb CHANGED
@@ -1,2 +1,10 @@
1
- require 'require_all'
2
- require_rel 'payson_api'
1
+ require 'payson_api/config'
2
+ require 'payson_api/client'
3
+ require 'payson_api/errors/payson_api_error'
4
+ require 'payson_api/errors/remote_error'
5
+ require 'payson_api/order_item'
6
+ require 'payson_api/pay_data'
7
+ require 'payson_api/receiver'
8
+ require 'payson_api/response'
9
+ require 'payson_api/sender'
10
+ require 'payson_api/version'
@@ -1,18 +1,22 @@
1
- require 'rest_client'
1
+ require 'httpclient'
2
2
 
3
3
  module PaysonAPI
4
4
  class Client
5
5
  def self.pay(pay_data)
6
6
  action = '/%s/%s/' % [PAYSON_API_VERSION, PAYSON_API_PAY_ACTION]
7
+ response = post(PAYSON_API_ENDPOINT + action, pay_data.to_hash)
8
+ Response.new(response.body)
9
+ end
10
+
11
+ private
12
+
13
+ def self.post(url, data)
7
14
  headers = {
8
- "PAYSON-SECURITY-USERID" => PaysonAPI.config.api_user,
9
- "PAYSON-SECURITY-PASSWORD" => PaysonAPI.config.api_key
15
+ 'PAYSON-SECURITY-USERID' => PaysonAPI.config.api_user_id,
16
+ 'PAYSON-SECURITY-PASSWORD' => PaysonAPI.config.api_password,
17
+ 'Content-Type' => 'application/x-www-form-urlencoded'
10
18
  }
11
- response = RestClient.post(PAYSON_API_ENDPOINT + action,
12
- pay_data.to_hash,
13
- headers
14
- )
15
- Response.new(response)
19
+ HTTPClient.post(url, :body => data, :header => headers)
16
20
  end
17
21
  end
18
22
  end
@@ -1,6 +1,5 @@
1
1
  module PaysonAPI
2
-
3
- # Some hard constants
2
+ extend self
4
3
 
5
4
  PAYSON_WWW_HOST = "https://www.payson.se"
6
5
  PAYSON_WWW_PAY_FORWARD_URL = "/paysecure/?token=%s"
@@ -19,21 +18,21 @@ module PaysonAPI
19
18
  # PaysonAPI.configure do |config|
20
19
  # config.api_user = 12345
21
20
  # end
22
- def self.configure(&block)
23
- yield @config ||= PaysonAPI::Configuration.new
21
+ def configure(&block)
22
+ yield @config ||= Configuration.new
24
23
  end
25
24
 
26
- def self.config
25
+ def config
27
26
  @config
28
27
  end
29
28
 
30
29
  class Configuration
31
- attr_accessor :api_user, :api_key
30
+ attr_accessor :api_user_id, :api_password
32
31
  end
33
32
 
34
33
  configure do |config|
35
- config.api_user = 'XXXX'
36
- config.api_key = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
34
+ config.api_user_id = 'XXXX'
35
+ config.api_password = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
37
36
  end
38
37
 
39
38
  end
@@ -1,3 +1,3 @@
1
1
  module PaysonAPI
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/payson_api.gemspec CHANGED
@@ -17,10 +17,9 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency 'require_all'
21
- s.add_dependency 'rest-client'
20
+ s.add_dependency 'httpclient'
22
21
 
23
22
  # specify any dependencies here; for example:
24
23
  # s.add_development_dependency "rspec"
25
- # s.add_runtime_dependency "rest-client"
24
+ # s.add_runtime_dependency "httpclient"
26
25
  end
metadata CHANGED
@@ -1,52 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: payson_api
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Christopher Svensson
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-24 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: require_all
16
- requirement: &70104901674140 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
17
+
18
+ date: 2012-07-25 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: httpclient
23
22
  prerelease: false
24
- version_requirements: *70104901674140
25
- - !ruby/object:Gem::Dependency
26
- name: rest-client
27
- requirement: &70104901657500 !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
28
24
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
33
32
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70104901657500
33
+ version_requirements: *id001
36
34
  description: Client that enables access to the Payson payment gateway API.
37
- email:
35
+ email:
38
36
  - stoffus@stoffus.com
39
37
  executables: []
38
+
40
39
  extensions: []
40
+
41
41
  extra_rdoc_files: []
42
- files:
42
+
43
+ files:
43
44
  - .gitignore
44
45
  - Gemfile
45
46
  - README.rdoc
46
47
  - lib/payson_api.rb
47
48
  - lib/payson_api/client.rb
48
49
  - lib/payson_api/config.rb
49
- - lib/payson_api/errors/config_error.rb
50
50
  - lib/payson_api/errors/payson_api_error.rb
51
51
  - lib/payson_api/errors/remote_error.rb
52
52
  - lib/payson_api/order_item.rb
@@ -58,26 +58,36 @@ files:
58
58
  - payson_api.gemspec
59
59
  homepage: https://github.com/stoffus/payson_api
60
60
  licenses: []
61
+
61
62
  post_install_message:
62
63
  rdoc_options: []
63
- require_paths:
64
+
65
+ require_paths:
64
66
  - lib
65
- required_ruby_version: !ruby/object:Gem::Requirement
67
+ required_ruby_version: !ruby/object:Gem::Requirement
66
68
  none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: '0'
71
- required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
77
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
77
85
  requirements: []
86
+
78
87
  rubyforge_project:
79
- rubygems_version: 1.8.17
88
+ rubygems_version: 1.8.15
80
89
  signing_key:
81
90
  specification_version: 3
82
91
  summary: Client for Payson API
83
92
  test_files: []
93
+
@@ -1,13 +0,0 @@
1
- module PaysonAPI
2
- module Errors
3
- class ConfigError < PaysonAPIError
4
- def initialize(msg)
5
- @msg = msg
6
- end
7
-
8
- def to_s
9
- @msg
10
- end
11
- end
12
- end
13
- end