alipan-sdk 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
  SHA256:
3
- metadata.gz: 391e43dcbc839df82035ba6a730fe7d274054d5fa8147fc8742847668cca0b46
4
- data.tar.gz: 96afad1647af9260c3340f6bd9ecde58c593db444ad0cce301e0e1285dc0124f
3
+ metadata.gz: d3f53b591622f3f464672c3e9bb90f51cf0de5d3cd60442513700cb2b13df5ac
4
+ data.tar.gz: 635f457fddba0eddd3909dd3f53b872801dfaa041555b802082a9a2850857abd
5
5
  SHA512:
6
- metadata.gz: 95e7da78fb03144dc9c1b26843b0e0d8733391b1ee28a6dbb363964cc39257d1d07ffc5ecbe575cedc4eb46e695ea088791d5275f1d4be0c9fa7e00e0ebbbcb2
7
- data.tar.gz: '08f4d6470a21d3f7ec5f5e8e37ea45c52834a3baf8c7953715ee8d190114a5fb6d7244737c7f3be9d640f110c76795b78812e35adf6740a56a764234fb08f18f'
6
+ metadata.gz: bcf71c608206c88d31caf4782fe724538128f56acfdfcbe5a88aa13c2413a2d243c2962cef5f6f2af3eae6bbb30ee39e0b7868f80860cda4cd587df7633387bb
7
+ data.tar.gz: 87807a884d03c3bc416625f100f28c86813f701dbdd6cb495118e17d1450bb7dbc829662d0a1c58ab3185cafb535f787f277ed4cd13801ebd073df8d26994468
data/README.md CHANGED
@@ -1,39 +1,45 @@
1
1
  # Alipan SDK for Ruby
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ [![Gem Version](https://badge.fury.io/rb/alipan-sdk.svg)](https://badge.fury.io/rb/alipan-sdk)
4
4
 
5
- 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/alipan`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ## 关于
6
6
 
7
- ## Installation
7
+ 阿里云盘SDK 方便Ruby客户端程序调用
8
8
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
9
+ ## 快速开始
10
10
 
11
- Install the gem and add to the application's Gemfile by executing:
11
+ ### 鉴权配置
12
+
13
+ 登录官网[阿里云盘开发者门户](https://www.alipan.com/developer/f) 按照开发文档获取access_token
14
+
15
+ ### 安装Alipan SDK for Ruby
12
16
 
13
17
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+ gem install alipan-sdk
15
19
  ```
16
20
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
21
+ 并在你的程序中或者`irb`命令下包含:
18
22
 
19
23
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
24
+ require 'alipan'
21
25
  ```
22
26
 
23
- ## Usage
27
+ ### 创建Client
28
+ client = Alipan::Client.new({:access_token=>"xxx"})
24
29
 
25
- TODO: Write usage instructions here
30
+ `access_token`是您的鉴权信息
26
31
 
27
- ## Development
28
32
 
29
- 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.
33
+ **请妥善保管您的access_token 泄露之后可能影响您的数据安全**
30
34
 
31
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ ### 获取drive
36
+ drive = client.get_drive
32
37
 
33
- ## Contributing
38
+ ### 获取object
39
+ objects = drive.list_objects
34
40
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/alipan.
41
+ ## 更多
36
42
 
37
- ## License
43
+ 更多文档请查看:
38
44
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
45
+ [阿里云盘开发者门户](https://www.alipan.com/developer/f)
data/lib/alipan/http.rb CHANGED
@@ -64,6 +64,7 @@ module Alipan
64
64
  )
65
65
  response = request.execute do |resp, &blk|
66
66
  if resp.code >= 300
67
+ e = RuntimeError.new JSON.parse(resp.body)
67
68
  logger.error(e.to_s)
68
69
  raise e
69
70
  else
@@ -45,7 +45,25 @@ module Alipan
45
45
  body = JSON.parse(r.body)
46
46
 
47
47
  objects = body[:items.to_s].map do |item|
48
- Object.new(item, self)
48
+ Object.new(
49
+ {
50
+ :drive_id => item.fetch(:drive_id.to_s),
51
+ :file_id => item.fetch(:file_id.to_s),
52
+ :parent_file_id => item.fetch(:parent_file_id.to_s),
53
+ :name => item.fetch(:name.to_s),
54
+ :size => item.fetch(:size.to_s),
55
+ :file_extension => item.fetch(:file_extension.to_s),
56
+ :content_hash => item.fetch(:content_hash.to_s),
57
+ :category => item.fetch(:category.to_s),
58
+ :type => item.fetch(:type.to_s),
59
+ :thumbnail => item.fetch(:thumbnail.to_s),
60
+ :url => item.fetch(:url.to_s),
61
+ :created_at => item.fetch(:created_at.to_s),
62
+ :updated_at => item.fetch(:updated_at.to_s),
63
+ :play_cursor => item.fetch(:play_cursor.to_s),
64
+ :video_media_metadata => item.fetch(:video_media_metadata.to_s),
65
+ :video_preview_metadata => item.fetch(:video_preview_metadata.to_s)
66
+ }, self)
49
67
  end
50
68
 
51
69
  more = {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alipan
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alipan-sdk
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
  - freeshenls