dangdang 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 19ef00da2dcce62b16082a3b384c245f1944a5f4
4
+ data.tar.gz: fa9ccbd9c6da136c4ace79acb089cda36a4d46e8
5
+ SHA512:
6
+ metadata.gz: 6dce35a72b85258a95b8d1524c37d77a81c5f62937c81f937842edd66ba18dd38d319df7ee70c5f802d59e39d52dc3672cccc83c1e4a2c376f844a820823d897
7
+ data.tar.gz: 170af02d838974281a30e0d5d49676f7e6ed80ccef3437e90a72f02bebb1ded89534f50546c06aebef453022f58e4bd6dfbe04b1902574abb8f9ae51c13b79cf
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'http://ruby.taobao.org'
2
+
3
+ gem 'digest'
4
+ gem 'eat'
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ gem 'pry-rescue'
9
+ end
10
+
11
+ group :test do
12
+ gem 'rubocop', require: false
13
+ gem 'simplecov', require: false
14
+ gem 'webmock'
15
+ end
16
+
17
+ # Specify your gem's dependencies in dangdang.gemspec
18
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Yanying Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,42 @@
1
+ # Dangdang
2
+ =========
3
+ [Dangdang Open Platform(当当开放平台)](http://open.dangdang.com) API in Ruby
4
+
5
+ # Order
6
+ ## Initialize
7
+ ```ruby
8
+ a = Dangdang::Order.new(
9
+ app_key: "1111111111",
10
+ app_secret: "AAAAAAAA11111111BBBBBBBB22222222",
11
+ session_key: "AAAAAAAA11111111AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDYYYYYYYYZZZZZZZZ"
12
+ )
13
+ ```
14
+
15
+ ## Orders List:
16
+ ["dangdang_orders_list_get" method params reference](http://open.dangdang.com/index.php?c=documentCenterG4&f=show&page_id=132)
17
+
18
+
19
+ Example:
20
+ ```ruby
21
+ # You can only fetch orders paid from Dangdang Open Platform in current time when using 'osd oed' submitted params.
22
+ a.dangdang_orders_list_get(
23
+ osd: "2014-11-25 00:00:00",
24
+ oed: "2014-11-26 16:30:00"
25
+ )
26
+
27
+ a.dangdang_orders_list_get(os: "100")
28
+
29
+ a.dangdang_order_list_get(o: "11111111111")
30
+ ```
31
+
32
+
33
+ ## Order Details:
34
+ ["dangdang_order_details_get" method params reference](http://open.dangdang.com/index.php?c=documentCenterG4&f=show&page_id=133)
35
+
36
+ Example:
37
+ ```ruby
38
+ a.dangdang_order_details_get(o: "11111111111")
39
+ ```
40
+
41
+
42
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dangdang/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'dangdang'
8
+ spec.version = Dangdang::VERSION
9
+ spec.authors = ['YanyingWang']
10
+ spec.email = ['yanyingwangwang@gmail.com']
11
+ spec.summary = 'dangdang'
12
+ spec.description = 'Ruby SDK for open.dangdang.com'
13
+ spec.homepage = 'https://github.com/yanyingwang/dangdang'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+
24
+ spec.add_dependency 'digest', '~> 0.0.1'
25
+ spec.add_dependency 'eat', '0.1.8'
26
+ end
@@ -0,0 +1,59 @@
1
+ require "dangdang/version"
2
+ require 'digest'
3
+ require 'cgi'
4
+ require 'eat'
5
+ require 'active_support/core_ext/hash'
6
+
7
+ module Dangdang
8
+ class Order
9
+ def initialize(option = {})
10
+ @option = option
11
+ @api_uri_front = "http://api.open.dangdang.com/openapi/rest?"
12
+ end
13
+ def sys_params
14
+ { :app_key => @option[:app_key],
15
+ :format => "xml",
16
+ :method => @method,
17
+ :session => @option[:session_key],
18
+ :sign_method => "md5",
19
+ :timestamp => Time.now.strftime("%Y-%m-%d %T"),
20
+ :v => "1.0" }
21
+ end
22
+
23
+ def sys_params_to_string
24
+ sys_params.to_a.flatten.join("")
25
+ end
26
+ def secret_string
27
+ @option[:app_secret] + sys_params_to_string + @option[:app_secret]
28
+ end
29
+ def sign_key
30
+ Digest::MD5.hexdigest(secret_string).upcase
31
+ end
32
+
33
+
34
+ def dangdang_orders_list_get(params_app = {})
35
+ @method = __callee__.to_s.split("_").join(".")
36
+ [:lastModifyTime_start, :lastModifyTime_end, :osd, :oed, :sgsd, :sged].each do |v|
37
+ params_app[v] = CGI.escape(params_app[v]) if params_app[v]
38
+ end
39
+ @params_app = params_app
40
+ Hash.from_xml(eat(get_api_uri))
41
+ end
42
+ def dangdang_order_details_get(params_app = {})
43
+ @method = __callee__.to_s.split("_").join(".")
44
+ @params_app = params_app
45
+ Hash.from_xml(eat(get_api_uri))
46
+ end
47
+
48
+ def get_api_uri
49
+ @api_uri_front + "sign=#{sign_key}&" + url_params
50
+ end
51
+ def url_params
52
+ params = sys_params
53
+ params.merge!(@params_app)
54
+ params[:timestamp] = CGI.escape(params[:timestamp])
55
+ params.to_a.map { |p| p.join("=")}.join("&")
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Dangdang
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dangdang
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - YanyingWang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: digest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: eat
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.8
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.8
69
+ description: Ruby SDK for open.dangdang.com
70
+ email:
71
+ - yanyingwangwang@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - dangdang.gemspec
83
+ - lib/dangdang.rb
84
+ - lib/dangdang/version.rb
85
+ homepage: https://github.com/yanyingwang/dangdang
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.6
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: dangdang
109
+ test_files: []