FlipkartSeller 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7716d42278546c5a9f8e1c00feab935e6bf3d19f
4
- data.tar.gz: e05026b70d6319558e9280f1b54578fb77b143ed
3
+ metadata.gz: 2a33812e9a69b71227cbafe2ffda7a30941d4080
4
+ data.tar.gz: e59dbd17a12431448bef6156a6ee15d75e3ce97b
5
5
  SHA512:
6
- metadata.gz: 04b05e08c25fbc24a3088ba0829ac3121bbf58792cdfbdfe0040ec299d0ec2a397810bf2766c5e731d19a8cd99e427a572d2130008343763865f1c3423e8791b
7
- data.tar.gz: f17484b4f96ee50878a2c32965c7d138b1b52984768c163424b3d3186cb1d970da1c11ee8b3df08e2bbc3bcf09b83a260c7448d87c97dba794b9f91ebf49ac0e
6
+ metadata.gz: 34a85dc412526b0247460e3524d244f4844346f07498f752f7f087ae327604eeed6ca7514528befe316c8cf23a21bb434bcddb4ac13883461e7d9ebab2213a0d
7
+ data.tar.gz: 517c947ca7a9a29842fe6c6aee7e0434744739ba6e8a7cb04f81c3025859c2b617f05012340466b350eca7578f74c1fa7014fa820eb265c8aea6fb7aa2a06b4b
@@ -1,5 +1,6 @@
1
1
  module FlipkartSeller
2
-
2
+
3
+ class StandardException < StandardError; end
3
4
  class Exception < StandardError
4
5
  attr_reader :response
5
6
 
@@ -48,6 +49,12 @@ module FlipkartSeller
48
49
  def initialize(response)
49
50
  super(response)
50
51
  end
52
+ end
53
+
54
+ class OtherException < Exception
55
+ def initialize(response)
56
+ super(response)
57
+ end
51
58
  end
52
59
 
53
60
  end
@@ -11,31 +11,36 @@ module FlipkartSeller
11
11
  :headers => {'Authorization' => 'Bearer ' + @access_token, :content_type => 'application/json'}
12
12
  )
13
13
 
14
- if response.code == 200
15
- response_data = JSON.parse(response.body)
16
- return response_data
17
- end
14
+ response_data = JSON.parse(response.body)
15
+ return response_data
18
16
 
19
- rescue RestClient::Unauthorized, RestClient::Forbidden => e
20
-
21
- raise Forbidden.new(e.response), e.message
22
17
 
23
18
  rescue RestClient::ExceptionWithResponse => e
24
- case e.response.code
25
- when 400
26
- raise BadRequest.new(e.response), e.message
27
- when 403
28
- raise Forbidden.new(e.response), e.message
29
- when 404
30
- raise NotFound.new(e.response), e.message
31
- when 500
32
- raise InternalServerError.new(e.response), e.message
33
- when 503
34
- raise ServiceUnavailable.new(e.response), e.message
35
- when 599
36
- raise ConnectionTimedOut.new(e.response), e.message
37
- end
38
- end
19
+ raise StandardException.new if e.response.blank?
20
+
21
+ if e.response.code.present? && [400,403,404,500,503,599].include?(e.response.code)
22
+ case e.response.code
23
+ when 400
24
+ raise BadRequest.new(e.response), e.message
25
+ when 403
26
+ raise Forbidden.new(e.response), e.message
27
+ when 404
28
+ raise NotFound.new(e.response), e.message
29
+ when 500
30
+ raise InternalServerError.new(e.response), e.message
31
+ when 503
32
+ raise ServiceUnavailable.new(e.response), e.message
33
+ when 599
34
+ raise ConnectionTimedOut.new(e.response), e.message
35
+ else
36
+ raise OtherException.new(e.response), e.message
37
+ end
38
+ else
39
+ raise OtherException.new(e.response), e.message
40
+ end
41
+ rescue Exception => e
42
+ raise StandardException.new
43
+ end
39
44
 
40
45
  end
41
46
 
@@ -73,15 +78,36 @@ module FlipkartSeller
73
78
  :payload=> "#{data.to_json}"
74
79
  )
75
80
 
76
- if response.code == 200
77
- response_data = JSON.parse(response.body)
81
+ response_data = JSON.parse(response.body)
78
82
 
79
- return response_data
80
- end
83
+ return response_data
81
84
 
82
- rescue Exception => e
83
- Rails.logger.error e.message
85
+ rescue RestClient::ExceptionWithResponse => e
86
+ raise StandardException.new if e.response.blank?
87
+
88
+ if e.response.code.present? && [400,403,404,500,503,599].include?(e.response.code)
89
+ case e.response.code
90
+ when 400
91
+ raise BadRequest.new(e.response), e.message
92
+ when 403
93
+ raise Forbidden.new(e.response), e.message
94
+ when 404
95
+ raise NotFound.new(e.response), e.message
96
+ when 500
97
+ raise InternalServerError.new(e.response), e.message
98
+ when 503
99
+ raise ServiceUnavailable.new(e.response), e.message
100
+ when 599
101
+ raise ConnectionTimedOut.new(e.response), e.message
102
+ else
103
+ raise OtherException.new(e.response), e.message
84
104
  end
105
+ else
106
+ raise OtherException.new(e.response), e.message
107
+ end
108
+ rescue Exception => e
109
+ raise StandardException.new
110
+ end
85
111
 
86
112
  end
87
113
  end
@@ -1,3 +1,3 @@
1
1
  module FlipkartSeller
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: FlipkartSeller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atish Kumar Sahoo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-22 00:00:00.000000000 Z
11
+ date: 2017-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler