paypal-sdk-rest 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,39 +1,39 @@
1
- module PayPal
2
- module SDK
3
- module REST
4
- class ErrorHash < Core::Util::OrderedHash
5
- def self.convert(hash)
6
- error_hash = new
7
- hash.each{|key, value|
8
- error_hash[key] = value
9
- }
10
- error_hash
11
- end
12
-
13
- def []=(key, value)
14
- value =
15
- if value.is_a? Hash
16
- ErrorHash.convert(hash)
17
- elsif value.is_a? Array and value[0].is_a? Hash
18
- value.map{|array_value| ErrorHash.convert(array_value) }
19
- else
20
- value
21
- end
22
- super(key, value)
23
- end
24
-
25
- def [](name)
26
- super(name.to_s) || super(name.to_sym)
27
- end
28
-
29
- def method_missing(name, *args)
30
- if keys.include?(name) or keys.include?(name.to_s)
31
- self[name]
32
- else
33
- super
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ class ErrorHash < Core::Util::OrderedHash
5
+ def self.convert(hash)
6
+ error_hash = new
7
+ hash.each{|key, value|
8
+ error_hash[key] = value
9
+ }
10
+ error_hash
11
+ end
12
+
13
+ def []=(key, value)
14
+ value =
15
+ if value.is_a? Hash
16
+ ErrorHash.convert(hash)
17
+ elsif value.is_a? Array and value[0].is_a? Hash
18
+ value.map{|array_value| ErrorHash.convert(array_value) }
19
+ else
20
+ value
21
+ end
22
+ super(key, value)
23
+ end
24
+
25
+ def [](name)
26
+ super(name.to_s) || super(name.to_sym)
27
+ end
28
+
29
+ def method_missing(name, *args)
30
+ if keys.include?(name) or keys.include?(name.to_s)
31
+ self[name]
32
+ else
33
+ super
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,20 +1,20 @@
1
- module PayPal
2
- module SDK
3
- module REST
4
- module GetAPI
5
- # Get API object
6
- # === Example
7
- # Payment.api
8
- # payment.api
9
- def api
10
- @api || parent_api
11
- end
12
-
13
- # Parent API object
14
- def parent_api
15
- superclass.respond_to?(:api) ? superclass.api : RequestDataType.api
16
- end
17
- end
18
- end
19
- end
20
- end
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ module GetAPI
5
+ # Get API object
6
+ # === Example
7
+ # Payment.api
8
+ # payment.api
9
+ def api
10
+ @api || parent_api
11
+ end
12
+
13
+ # Parent API object
14
+ def parent_api
15
+ superclass.respond_to?(:api) ? superclass.api : RequestDataType.api
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,56 +1,56 @@
1
- module PayPal
2
- module SDK
3
- module REST
4
-
5
- module RequestDataType
6
-
7
- # Get a local API object or Class level API object
8
- def api
9
- @api || self.class.api
10
- end
11
-
12
- # Convert Hash object to ErrorHash object
13
- def error=(hash)
14
- @error =
15
- if hash.is_a? Hash
16
- ErrorHash.convert(hash)
17
- else
18
- hash
19
- end
20
- end
21
-
22
- class << self
23
- # Global API object
24
- # === Example
25
- # RequestDataType.api
26
- def api
27
- @api ||= API.new
28
- end
29
-
30
- # Setter for RequestDataType.api
31
- # === Example
32
- # RequestDataType.set_config(..)
33
- include SetAPI
34
-
35
- # Configure depended module, when RequestDataType is include.
36
- # === Example
37
- # class Payment < DataTypes
38
- # include RequestDataType
39
- # end
40
- # Payment.set_config(..)
41
- # payment.set_config(..)
42
- # Payment.api
43
- # payment.api
44
- def included(klass)
45
- klass.class_eval do
46
- extend GetAPI
47
- extend SetAPI
48
- include SetAPI
49
- end
50
- end
51
- end
52
- end
53
-
54
- end
55
- end
56
- end
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+
5
+ module RequestDataType
6
+
7
+ # Get a local API object or Class level API object
8
+ def api
9
+ @api || self.class.api
10
+ end
11
+
12
+ # Convert Hash object to ErrorHash object
13
+ def error=(hash)
14
+ @error =
15
+ if hash.is_a? Hash
16
+ ErrorHash.convert(hash)
17
+ else
18
+ hash
19
+ end
20
+ end
21
+
22
+ class << self
23
+ # Global API object
24
+ # === Example
25
+ # RequestDataType.api
26
+ def api
27
+ @api ||= API.new
28
+ end
29
+
30
+ # Setter for RequestDataType.api
31
+ # === Example
32
+ # RequestDataType.set_config(..)
33
+ include SetAPI
34
+
35
+ # Configure depended module, when RequestDataType is include.
36
+ # === Example
37
+ # class Payment < DataTypes
38
+ # include RequestDataType
39
+ # end
40
+ # Payment.set_config(..)
41
+ # payment.set_config(..)
42
+ # Payment.api
43
+ # payment.api
44
+ def included(klass)
45
+ klass.class_eval do
46
+ extend GetAPI
47
+ extend SetAPI
48
+ include SetAPI
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -1,42 +1,42 @@
1
- module PayPal
2
- module SDK
3
- module REST
4
- module SetAPI
5
- # Set new api
6
- # === Examples
7
- # payment.set_config(:development)
8
- # payment.set_config(:client_id => "XYZ", :client_secret => "SECRET")
9
- # payment.set_config
10
- # payment.api = API.new(:development)
11
- def set_config(*args)
12
- if args[0].is_a?(API)
13
- @api = args[0]
14
- else
15
- @api ||= API.new({})
16
- @api.set_config(*args) # Just override the configuration and Not
17
- @api
18
- end
19
- end
20
- alias_method :config=, :set_config
21
- alias_method :set_api, :set_config
22
- alias_method :api=, :set_config
23
-
24
- # Override token
25
- def token=(token)
26
- set_config( :client_id => nil, :client_secret => nil ).token = token
27
- end
28
- alias_method :"auth=", :"token="
29
-
30
- # Override client id
31
- def client_id=(client_id)
32
- set_config(:client_id => client_id).token = nil
33
- end
34
-
35
- # Override client secret
36
- def client_secret=(client_secret)
37
- set_config(:client_secret => client_secret).token = nil
38
- end
39
- end
40
- end
41
- end
42
- end
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ module SetAPI
5
+ # Set new api
6
+ # === Examples
7
+ # payment.set_config(:development)
8
+ # payment.set_config(:client_id => "XYZ", :client_secret => "SECRET")
9
+ # payment.set_config
10
+ # payment.api = API.new(:development)
11
+ def set_config(*args)
12
+ if args[0].is_a?(API)
13
+ @api = args[0]
14
+ else
15
+ @api ||= API.new({})
16
+ @api.set_config(*args) # Just override the configuration and Not
17
+ @api
18
+ end
19
+ end
20
+ alias_method :config=, :set_config
21
+ alias_method :set_api, :set_config
22
+ alias_method :api=, :set_config
23
+
24
+ # Override token
25
+ def token=(token)
26
+ set_config( :client_id => nil, :client_secret => nil ).token = token
27
+ end
28
+ alias_method :"auth=", :"token="
29
+
30
+ # Override client id
31
+ def client_id=(client_id)
32
+ set_config(:client_id => client_id).token = nil
33
+ end
34
+
35
+ # Override client secret
36
+ def client_secret=(client_secret)
37
+ set_config(:client_secret => client_secret).token = nil
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,7 +1,7 @@
1
- module PayPal
2
- module SDK
3
- module REST
4
- VERSION = "0.5.2"
5
- end
6
- end
7
- end
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ VERSION = "0.6.0"
5
+ end
6
+ end
7
+ end
@@ -1,38 +1,38 @@
1
- require 'paypal-sdk-core'
2
-
3
- module PayPal
4
- module SDK
5
- module REST
6
- autoload :VERSION, "paypal-sdk/rest/version"
7
- autoload :DataTypes, "paypal-sdk/rest/data_types"
8
- autoload :API, "paypal-sdk/rest/api"
9
- autoload :RequestDataType, "paypal-sdk/rest/request_data_type"
10
- autoload :SetAPI, "paypal-sdk/rest/set_api"
11
- autoload :GetAPI, "paypal-sdk/rest/get_api"
12
- autoload :ErrorHash, "paypal-sdk/rest/error_hash"
13
-
14
- include DataTypes
15
- include Core::Exceptions
16
-
17
- module ClassMethods
18
- def method_missing(name, *args)
19
- RequestDataType.send(name, *args)
20
- end
21
- end
22
-
23
- class << self
24
- def new(*args)
25
- API.new(*args)
26
- end
27
- include ClassMethods
28
-
29
- def included(klass)
30
- if klass.is_a? Module
31
- klass.extend(ClassMethods)
32
- end
33
- end
34
- end
35
-
36
- end
37
- end
38
- end
1
+ require 'paypal-sdk-core'
2
+
3
+ module PayPal
4
+ module SDK
5
+ module REST
6
+ autoload :VERSION, "paypal-sdk/rest/version"
7
+ autoload :DataTypes, "paypal-sdk/rest/data_types"
8
+ autoload :API, "paypal-sdk/rest/api"
9
+ autoload :RequestDataType, "paypal-sdk/rest/request_data_type"
10
+ autoload :SetAPI, "paypal-sdk/rest/set_api"
11
+ autoload :GetAPI, "paypal-sdk/rest/get_api"
12
+ autoload :ErrorHash, "paypal-sdk/rest/error_hash"
13
+
14
+ include DataTypes
15
+ include Core::Exceptions
16
+
17
+ module ClassMethods
18
+ def method_missing(name, *args)
19
+ RequestDataType.send(name, *args)
20
+ end
21
+ end
22
+
23
+ class << self
24
+ def new(*args)
25
+ API.new(*args)
26
+ end
27
+ include ClassMethods
28
+
29
+ def included(klass)
30
+ if klass.is_a? Module
31
+ klass.extend(ClassMethods)
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -1,2 +1,2 @@
1
- require "paypal-sdk/rest"
2
-
1
+ require "paypal-sdk/rest"
2
+