paypal_fx 0.1.0 → 0.1.1

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.
data/README.rdoc CHANGED
@@ -1,12 +1,11 @@
1
1
  = paypal_fx
2
2
 
3
- fx = Devmask::PaypalFx.new(user_id: 'user',
3
+ fx = PaypalFx.new(user_id: 'user',
4
4
  password: 'password',
5
5
  signature: 'sign',
6
6
  app_id: 'appid',
7
7
  test: true)
8
-
9
- puts fx.convert "1.0","USD", "MXN"
8
+ puts fx.convert "1.0","USD", "MXN"
10
9
 
11
10
  == Contributing to paypal_fx
12
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/paypal_fx.rb CHANGED
@@ -6,10 +6,10 @@ require 'uri'
6
6
 
7
7
  class PaypalFx
8
8
 
9
- SERVER = "svcs.sandbox.paypal.com"
10
- SANDBOX = "svcs.sandbox.paypal.com"
9
+ SERVER = 'svcs.paypal.com'
10
+ SANDBOX = 'svcs.sandbox.paypal.com'
11
11
 
12
- CLIENT_INFO = { VERSION: "60.0", SOURCE: "PayPalRubySDKV1.2.0" }
12
+ CLIENT_INFO = { VERSION: '60.0', SOURCE: 'PayPalRubySDKV1.2.0' }
13
13
 
14
14
  attr_accessor :params
15
15
 
@@ -26,15 +26,19 @@ class PaypalFx
26
26
  end
27
27
 
28
28
  # Converts an amount from origin currency to destination
29
+ #
30
+ # @param amount [Float] amount
31
+ # @param origin [String] ISO Currency code
32
+ # @param destination [String] ISO Currency code
29
33
  def convert(amount, origin, destination)
30
34
  request = {
31
- "requestEnvelope.errorLanguage" => "en_US",
32
- "baseAmountList.currency(0).amount" => amount,
33
- "baseAmountList.currency(0).code" => origin,
34
- "convertToCurrencyList.currencyCode(0)" => destination
35
+ 'requestEnvelope.errorLanguage' => 'en_US',
36
+ 'baseAmountList.currency(0).amount' => amount,
37
+ 'baseAmountList.currency(0).code' => origin,
38
+ 'convertToCurrencyList.currencyCode(0)' => destination
35
39
  }
36
40
 
37
- commit "/AdaptivePayments/ConvertCurrency", request
41
+ commit '/AdaptivePayments/ConvertCurrency', request
38
42
  end
39
43
 
40
44
  # Sends the request to specified end point for paypal SANDBOX or SERVER
@@ -44,18 +48,18 @@ class PaypalFx
44
48
  # @return [Hash] with the responce parameters
45
49
  def commit(endpoint, request)
46
50
 
47
- headers = {"Content-Type" => "html/text",
48
- "X-PAYPAL-SERVICE-VERSION" => "1.0.0",
49
- "X-PAYPAL-SECURITY-USERID" => self.params[:user_id],
50
- "X-PAYPAL-SECURITY-PASSWORD" => self.params[:password],
51
- "X-PAYPAL-SECURITY-SIGNATURE" => self.params[:signature],
52
- "X-PAYPAL-APPLICATION-ID" => self.params[:app_id],
53
- "X-PAYPAL-DEVICE-IPADDRESS" => self.params[:ip_address] || "",
54
- "X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
55
- "X-PAYPAL-RESPONSE-DATA-FORMAT" => "NV"}
51
+ headers = {'Content-Type' => 'html/text',
52
+ 'X-PAYPAL-SERVICE-VERSION' => '1.0.0',
53
+ 'X-PAYPAL-SECURITY-USERID' => self.params[:user_id],
54
+ 'X-PAYPAL-SECURITY-PASSWORD' => self.params[:password],
55
+ 'X-PAYPAL-SECURITY-SIGNATURE' => self.params[:signature],
56
+ 'X-PAYPAL-APPLICATION-ID' => self.params[:app_id],
57
+ 'X-PAYPAL-DEVICE-IPADDRESS' => self.params[:ip_address] || '',
58
+ 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV',
59
+ 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV'}
56
60
 
57
61
 
58
- request_params = request.merge(CLIENT_INFO).map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&")
62
+ request_params = request.merge(CLIENT_INFO).map { |k, v| "#{k}=#{CGI.escape(v)}" }.join('&')
59
63
 
60
64
  http = Net::HTTP.new(params[:test] ? SANDBOX : SERVER, 443)
61
65
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -68,12 +72,15 @@ class PaypalFx
68
72
  end
69
73
 
70
74
  protected
75
+ # Cleans the named spaced returns and converts the keys to symlinks
76
+ #
77
+ # @param hash [Hash] Paypal return hash
71
78
  def clean_namespace(hash)
72
79
  #i hate my self for this
73
80
  h = {}
74
81
  hash.each do |k, v|
75
- val = k.split(".").map { |k| k.tr('^A-Za-z0-9', '') }
76
- key = val.count == 2 ? val[1] : val[val.count-2..val.count-1].join("_")
82
+ val = k.split('.').map { |s| s.tr('^A-Za-z0-9', '') }
83
+ key = val.count == 2 ? val[1] : val[val.count-2..val.count-1].join('_')
77
84
  h[key.to_sym] = v[0]
78
85
  end
79
86
  h
data/paypal_fx.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "paypal_fx"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jonathan Garay"]
12
- s.date = "2012-02-15"
12
+ s.date = "2012-02-16"
13
13
  s.description = " Paypal Currency Exchange Library"
14
14
  s.email = "jonathan@devmask.net"
15
15
  s.extra_rdoc_files = [
@@ -2,4 +2,13 @@ require 'helper'
2
2
 
3
3
  class TestPaypalFx < Test::Unit::TestCase
4
4
 
5
+ should "have commit method" do
6
+ assert PaypalFx.new({}).respond_to? :commit
7
+ end
8
+
9
+ should "have convert method" do
10
+ assert PaypalFx.new({}).respond_to? :convert
11
+ end
12
+
13
+
5
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal_fx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-15 00:00:00.000000000 Z
12
+ date: 2012-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &70229449754540 !ruby/object:Gem::Requirement
16
+ requirement: &70186707729020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70229449754540
24
+ version_requirements: *70186707729020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70229449769640 !ruby/object:Gem::Requirement
27
+ requirement: &70186707727760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70229449769640
35
+ version_requirements: *70186707727760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70229449769080 !ruby/object:Gem::Requirement
38
+ requirement: &70186707726720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70229449769080
46
+ version_requirements: *70186707726720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70229449767560 !ruby/object:Gem::Requirement
49
+ requirement: &70186707725120 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70229449767560
57
+ version_requirements: *70186707725120
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &70229449766460 !ruby/object:Gem::Requirement
60
+ requirement: &70186707712260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70229449766460
68
+ version_requirements: *70186707712260
69
69
  description: ! ' Paypal Currency Exchange Library'
70
70
  email: jonathan@devmask.net
71
71
  executables: []
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: -587940227317013269
103
+ hash: 1388245334991938184
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements: