PaytmSeller 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f759056bdc73a0f21244c3eaf10e637d1ddd9a46
4
- data.tar.gz: b6a7e749f3e27cf3fc083a00c6257af6549c7ea5
3
+ metadata.gz: 01f5da3a6847e96712d870f831b94dd3f18208ce
4
+ data.tar.gz: 32145d413565e6b4b4e290120299d4961045cd36
5
5
  SHA512:
6
- metadata.gz: 167b2dee020431944b1e8229bd435556a0e7557c2da2d4501986207a61fb3c9ca82ada2520f8ac41945f18c2cf4d7b37ff56f427d0a795fd1779903c1a1b8608
7
- data.tar.gz: a1c27a63644496819373f097bea9d309a0f4024d979fdfba5d3acd63a8ade48f45be6546996811ff96beeffa90f235f511d31803ca83886c142f28dd303bd86e
6
+ metadata.gz: fe42207033fd8a6acd5b2058813ec20e66c9f9a16a098843f138f361eb00da0c569dac36bc9eacd676894b9cd9a2aeb922967979b601c67a908b13d8e88f8003
7
+ data.tar.gz: 5de456f6c8fcbc5fc3e533ba4ce9883d0b96a7c82154679cd097680390a833e8ac02f2bcae53266e413cf8b3ce56416a49258c8cf0969f06e3c6f1c20e3a392a
data/lib/PaytmSeller.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "PaytmSeller/version"
2
+ require "PaytmSeller/exception"
3
+ require "PaytmSeller/product"
2
4
  require "PaytmSeller/order"
3
5
  require "PaytmSeller/base"
4
6
  require "PaytmSeller/client"
@@ -1,7 +1,7 @@
1
1
  module PaytmSeller
2
2
  class Base
3
3
  include Order
4
- # include Product
4
+ include Product
5
5
  attr_reader :access_token
6
6
  attr_reader :environemnt
7
7
  attr_reader :base_url
@@ -0,0 +1,27 @@
1
+ module PaytmSeller
2
+
3
+ class StandardException < StandardError; end
4
+
5
+ class Exception < StandardError
6
+ attr_reader :response
7
+
8
+ def initialize(response)
9
+ @response = response
10
+ end
11
+
12
+ end
13
+
14
+ #for 412 response
15
+ class InvalidDataException < Exception
16
+ def initialize(response)
17
+ super(response)
18
+ end
19
+ end
20
+
21
+ class OtherException < Exception
22
+ def initialize(response)
23
+ super(response)
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,24 @@
1
+ module PaytmSeller
2
+ module Product
3
+
4
+ def update_products(data)
5
+ begin
6
+ url = @environment.eql?(:production) ? "https://catalogadmin.paytm.com/v1/merchant/#{@merchant_id}/product.json" : "https://catalogadmin-staging.paytm.com/v1/merchant/#{@merchant_id}/product.json"
7
+
8
+ response = RestClient::Request.execute(method: :post, url: url,timeout: 10, headers: {:content_type => 'application/json', params: {"authtoken" => @access_token}}, payload: data.to_json)
9
+
10
+ response_data = JSON.parse(response.body)
11
+
12
+ return response_data
13
+ rescue RestClient::ExceptionWithResponse => e
14
+ raise StandardException.new if e.response.blank?
15
+
16
+ if e.response.code.present? && 412 == e.response.code
17
+ raise InvalidDataException.new(e.response), e.message
18
+ else
19
+ raise OtherException.new(e.response), e.message
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module PaytmSeller
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PaytmSeller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-05-05 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,7 +88,9 @@ files:
88
88
  - lib/PaytmSeller.rb
89
89
  - lib/PaytmSeller/base.rb
90
90
  - lib/PaytmSeller/client.rb
91
+ - lib/PaytmSeller/exception.rb
91
92
  - lib/PaytmSeller/order.rb
93
+ - lib/PaytmSeller/product.rb
92
94
  - lib/PaytmSeller/version.rb
93
95
  homepage: https://github.com/atish-sahoo/PaytmSeller
94
96
  licenses: