youzanyun 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -0
- data/lib/youzanyun.rb +3 -3
- data/lib/youzanyun/api/items.rb +1 -1
- data/lib/youzanyun/client.rb +6 -6
- data/lib/youzanyun/version.rb +1 -1
- data/youzanyun.gemspec +1 -3
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4be63242a40ff32bdc342d50544e9de4e0042f7
|
4
|
+
data.tar.gz: 70c8276e145af15e5f5d7ca7560f250ad9526554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee84fcc2df4e721f36f24a7d2afb2456435762f93c07abc650d759a7aa3a8564cf052376ced9cd23b74dbf45bd7d15c663d18913c92008056ce55e1cb751a292
|
7
|
+
data.tar.gz: 07347015e7b4d5f1697afa1b98f5170fe021deccdf4bf01949fe6c045966f43f405c186a9b7b83fa93aad085fe82fd83d36a8ac5512b781334b4a26ec52679e9
|
data/README.md
ADDED
@@ -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.
|
data/lib/youzanyun.rb
CHANGED
@@ -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="
|
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
|
61
|
+
expires_in.to_i / 1000 - key_expired.to_i
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/youzanyun/api/items.rb
CHANGED
data/lib/youzanyun/client.rb
CHANGED
@@ -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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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 =
|
59
|
+
str = client_id + body + client_secret
|
60
60
|
Digest::MD5.hexdigest(str) == event_sign
|
61
61
|
end
|
62
62
|
|
data/lib/youzanyun/version.rb
CHANGED
data/youzanyun.gemspec
CHANGED
@@ -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.
|
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.
|
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-
|
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: :
|
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
|