youzanyun 0.1.0 → 0.1.1

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: 4c51390a4fd61285da7d5e0c5ff5759f0d2572e6
4
- data.tar.gz: 2d0adfeb7b8b0de72af88951945de0f4695f5333
3
+ metadata.gz: c4be63242a40ff32bdc342d50544e9de4e0042f7
4
+ data.tar.gz: 70c8276e145af15e5f5d7ca7560f250ad9526554
5
5
  SHA512:
6
- metadata.gz: da3c07fbf74d62b2a7b94c51612a2682a94dd660b4fb75278378ef4db719e5dbd32c8faba3cea429417a3044f5f0960435b5653be1d986e518dc855a0b7d102e
7
- data.tar.gz: 68e3fdca25ea60f42a2be87b4ed8f795e0cd790a0cf248b519086189b2f9999c5a0a0e8be43de04508ea02ab639fc60f7cbcbed0c7b451d3f4f6d8b192f8bc07
6
+ metadata.gz: ee84fcc2df4e721f36f24a7d2afb2456435762f93c07abc650d759a7aa3a8564cf052376ced9cd23b74dbf45bd7d15c663d18913c92008056ce55e1cb751a292
7
+ data.tar.gz: 07347015e7b4d5f1697afa1b98f5170fe021deccdf4bf01949fe6c045966f43f405c186a9b7b83fa93aad085fe82fd83d36a8ac5512b781334b4a26ec52679e9
@@ -0,0 +1,52 @@
1
+ # Youzanyun
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/youzanyun`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'youzanyun'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install youzanyun
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ require "bundler/setup"
27
+ require "youzanyun"
28
+ require "redis"
29
+ require "redis-namespace"
30
+ redis = Redis.new(host: 'localhost', port: 6379, db: 2)
31
+ youzanyun_redis = Redis::Namespace.new("youzanyun", :redis => redis)
32
+ Youzanyun.configure do |config|
33
+ config.redis = youzanyun_redis
34
+ config.rest_client_options = {:timeout => 100, :read_timeout => 1000, :open_timeout => 100, :verify_ssl => true,:headers => { :content_type => 'application/json' }}
35
+ end
36
+
37
+ $client_youzanyun ||= Youzanyun::Client.new(
38
+ "client_id",
39
+ "client_secret",
40
+ "grant_id"
41
+ )
42
+ $client_youzanyun.get_access_token
43
+ ```
44
+ ## Development
45
+
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
+
48
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/youzanyun.
@@ -34,9 +34,9 @@ module Youzanyun
34
34
  load_json(resource(post_api_url).post(JSON.generate(post_body), params: url_params))
35
35
  end
36
36
 
37
- def http_delete_without_token(url, delete_body={}, url_params={}, endpoint="plain")
37
+ def http_delete_without_token(url, delete_body = {}, url_params = {}, endpoint="api")
38
38
  delete_api_url = endpoint_url(endpoint, url)
39
- load_json(resource(delete_api_url).delete(params: url_params,raw_response: true))
39
+ load_json(resource(delete_api_url).delete(params: url_params, raw_response: true))
40
40
  end
41
41
 
42
42
  def resource(url)
@@ -58,7 +58,7 @@ module Youzanyun
58
58
  end
59
59
 
60
60
  def calculate_expire(expires_in)
61
- expires_in.to_i - key_expired.to_i * 1000
61
+ expires_in.to_i / 1000 - key_expired.to_i
62
62
  end
63
63
  end
64
64
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Youzanyun
4
4
  module Api
5
- module Item
5
+ module Items
6
6
  # 获取单个商品
7
7
  def items_inventory_get(options)
8
8
  http_get(url(".inventory.get"), options)
@@ -15,11 +15,11 @@ module Youzanyun
15
15
  attr_accessor :access_token, :token_type, :redis_key
16
16
 
17
17
  def initialize(client_id, client_secret, grant_id, options={})
18
- @client_id = client_id
19
- @client_secret = client_secret
20
- @expired_at = Time.now.to_i
21
- @grant_id = grant_id
22
- @redis_key = security_redis_key(options[:redis_key] || "youzanyun_#{client_id}")
18
+ self.client_id = client_id
19
+ self.client_secret = client_secret
20
+ self.expired_at = Time.now.to_i
21
+ self.grant_id = grant_id
22
+ self.redis_key = security_redis_key(options[:redis_key] || "youzanyun_#{client_id}")
23
23
  super()
24
24
  end
25
25
 
@@ -56,7 +56,7 @@ module Youzanyun
56
56
  end
57
57
 
58
58
  def verify?(event_sign:, body:)
59
- str = @client_id + body + @client_secret
59
+ str = client_id + body + client_secret
60
60
  Digest::MD5.hexdigest(str) == event_sign
61
61
  end
62
62
 
@@ -1,3 +1,3 @@
1
1
  module Youzanyun
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -24,7 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
26
26
  spec.add_runtime_dependency "rest-client", '>= 1.7'
27
- spec.add_development_dependency "redis-namespace"
28
- spec.add_development_dependency 'pry-rails'
29
-
27
+ spec.add_dependency "redis-namespace"
30
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youzanyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - guoyoujin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -73,21 +73,7 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: pry-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
76
+ type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
@@ -105,6 +91,7 @@ files:
105
91
  - ".rspec"
106
92
  - ".travis.yml"
107
93
  - Gemfile
94
+ - README.md
108
95
  - Rakefile
109
96
  - bin/console
110
97
  - bin/setup