flipkart_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/flipkart_api.rb +45 -0
  3. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfdcfc98743a0e17e28f182ee90ceb022fdf75a7
4
+ data.tar.gz: cb709b62d0298a269b3a82b998dfee165978c524
5
+ SHA512:
6
+ metadata.gz: acd1c1b250aaf7d32ce5dd050fd98f1d52b422a722f08c10f6ecfb78dd11b0cad1280121a6ff7c71e17889569b91ce156e542ca8e9ed291efa397e96af0e51a9
7
+ data.tar.gz: 71b6b3c29b530d7a99b9c22f179fa0228803086de1c222dd6f223f596b0ca15d9aea8b39cdfc2447c06a2af4848c6b79e034abb06ffbf6adad336e940cd7b988
@@ -0,0 +1,45 @@
1
+ require "rest-client"
2
+
3
+ class FlipkartApi
4
+ def initialize(fk_userid, fk_token)
5
+ @api = "https://affiliate-api.flipkart.net/affiliate"
6
+ @header = {"Fk-Affiliate-Id" => fk_userid, "Fk-Affiliate-Token" => fk_token}
7
+ end
8
+
9
+ def get_categories
10
+ format="json"
11
+ rest_url="#{@api}/api/#{@header['Fk-Affiliate-Token']}.#{format}"
12
+ RestClient.get rest_url
13
+ end
14
+
15
+ def get_products_by_category(category)
16
+ rest_url = JSON.parse(get_categories)["apiGroups"]["affiliate"]["apiListings"][category]["availableVariants"]["v0.1.0"]["get"]
17
+ get_all_products(rest_url)
18
+ end
19
+
20
+ def get_all_products(rest_url)
21
+ rest_output = RestClient.get rest_url, @header
22
+ all_products = [rest_output]
23
+ json_data = JSON.parse(rest_output)
24
+ while json_data["nextUrl"]
25
+ rest_output = RestClient.get json_data["nextUrl"], @header
26
+ all_products<<[rest_output]
27
+ json_data = JSON.parse(rest_output)
28
+ end
29
+ end
30
+
31
+ def get_dotd_offers(format)
32
+ rest_url = "#{@api}/offers/v1/dotd/#{format}"
33
+ RestClient.get rest_url, @header
34
+ end
35
+
36
+ def get_top_offers(format)
37
+ rest_url = "#{@api}/offers/v1/top/#{format}"
38
+ RestClient.get rest_url, @header
39
+ end
40
+
41
+ def get_product_by_id(product_id)
42
+ rest_url = "#{@api}/product/json?id=#{product_id}"
43
+ RestClient.get rest_url, @header
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flipkart_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Deepak HB
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.7.2
27
+ description: Pull data from flipkart by using api
28
+ email: deepakhb2@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/flipkart_api.rb
34
+ homepage: https://github.com/deepakhb2/flipkart_api
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.9.3
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.2.2
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: This gem is to pull data from flipkart using flipkart api
58
+ test_files: []