geekpark_api 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: 18eb95d39542d332d0d70b66d768e5e8e713e275
4
- data.tar.gz: f07488538c51a6072fe709a9af0991225d95ee61
3
+ metadata.gz: 3222532bead0d1fd36dbc774838e6eb9964a0eae
4
+ data.tar.gz: 6361430cf464d2bf9c68e130f1a8f9c3f74a388f
5
5
  SHA512:
6
- metadata.gz: 46c6a0b81068ddd048c69f37e8d70f2269b65a9a213f8a3fe1cdf3af26b75dbd66beed5101ea863923777bcc5ffe8cb51862fa4a67033e95c8902b63b5e5f661
7
- data.tar.gz: 53de2aa83d4320979665db860db2fdf3f0cc408f866f7ec71496b50a7eaefd22672216ede8d4bbd87dde3ee19246102ce58e28ad149c731824f3c663d5325280
6
+ metadata.gz: 9859366ff2d2edc474ff2b335d7f90ff05774ece3404a8e36804eb844185e543a25834d40f830497c4ceea5113f999843bfc887eec95ddeb8c3caf44008e6ca6
7
+ data.tar.gz: cfeb3169fa5e993c75a71c404be707f9521f564618666ac930f06f6f4071322efacf57236b0e7626c8159c5cd9e9f18ff7e649d64039aedb0b7823f0ec98a75a
data/README.md CHANGED
@@ -20,9 +20,39 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install geekpark_api
22
22
 
23
+ ## Config
24
+
25
+ create `config/initializes/geekpark_api.rb` and put your settings here, you can override default settings.
26
+
27
+ ```ruby
28
+ # :app_id, :app_secret, :signature, :user_api_base_uri, :event_api_base_uri
29
+ GeekparkApi.configure do |config|
30
+ config.user_api_base_uri = 'http://localhost:3000/api/v1/user'
31
+ end
32
+ ```
33
+
23
34
  ## Usage
24
35
 
25
- TODO: Write usage instructions here
36
+ ```ruby
37
+ GeekparkApi::User.update(TOKEN, {username: 'ligan1231'})
38
+
39
+ # {:status=>200,
40
+ # :body=>
41
+ # {"uuid"=>"67271786-8fff-49d0-a180-51b1eb7defb7",
42
+ # "username"=>"ligan1231",
43
+ # "realname"=>"",
44
+ # "email"=>"gavin.li1986@gmail.com",
45
+ # "company"=>"",
46
+ # "position"=>"",
47
+ # "mobile"=>"",
48
+ # "avatar"=>
49
+ # {"url"=>"http://7mnpep.com2.z0.glb.clouddn.com/uploads/user/avatar/000/210/689/e0037d0ceac78ccfb7f33b99020b5165.jpeg",
50
+ # "small"=>{"url"=>"http://7mnpep.com2.z0.glb.clouddn.com/uploads/user/avatar/000/210/689/small_e0037d0ceac78ccfb7f33b99020b5165.jpeg"},
51
+ # "thumb"=>{"url"=>"http://7mnpep.com2.z0.glb.clouddn.com/uploads/user/avatar/000/210/689/thumb_e0037d0ceac78ccfb7f33b99020b5165.jpeg"},
52
+ # "medium"=>{"url"=>"http://7mnpep.com2.z0.glb.clouddn.com/uploads/user/avatar/000/210/689/medium_e0037d0ceac78ccfb7f33b99020b5165.jpeg"}},
53
+ # "bio"=>""}}
54
+ #
55
+ ```
26
56
 
27
57
  ## Development
28
58
 
@@ -1,8 +1,10 @@
1
1
  module GeekparkApi
2
2
  class Activities
3
3
  class << self
4
- def find
4
+ def find id
5
+ res = Faraday.get "#{GeekparkApi.config.event_api_base_uri}/#{id}"
5
6
 
7
+ {status: res.status, body: JSON.parse(res.body)}
6
8
  end
7
9
  end
8
10
  end
@@ -1,8 +1,21 @@
1
+ require 'singleton'
1
2
  module GeekparkApi
2
3
  class Configuration
3
- attr_accessor :app_id
4
- attr_accessor :app_secret
5
- attr_accessor :user_api_base_url
6
- attr_accessor :event_api_base_url
4
+ include Singleton
5
+
6
+ attr_accessor :app_id, :app_secret, :signature, :user_api_base_uri, :event_api_base_uri
7
+
8
+ def self.defaults
9
+ @defaults ||= {
10
+ user_api_base_uri: 'http://www.geekpark.net/api/v1/user',
11
+ event_api_base_uri: 'http://events.geekpark.net/api/v1/',
12
+ signature: ENV['event_signature']
13
+ }
14
+ end
15
+
16
+ def initialize
17
+ self.class.defaults.each_pair { |k, v| send("#{k}=", v) }
18
+ end
19
+
7
20
  end
8
21
  end
@@ -0,0 +1,14 @@
1
+ module GeekparkApi
2
+ class User
3
+
4
+ def self.update token, params = {}
5
+ res = Faraday.patch GeekparkApi.config.user_api_base_uri do |req|
6
+ req.headers['Authorization'] = "Bearer #{token}"
7
+ req.body = params
8
+ end
9
+
10
+ {status: res.status, body: JSON.parse(res.body)}
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module GeekparkApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/geekpark_api.rb CHANGED
@@ -1,22 +1,23 @@
1
1
  require "faraday"
2
2
  require "json"
3
3
  require "geekpark_api/version"
4
- require "geekpark_api/sign"
5
4
  require "geekpark_api/configuration"
5
+ require "geekpark_api/sign"
6
6
  require "geekpark_api/orders"
7
- require "geekpark_api/users"
7
+ require "geekpark_api/user"
8
8
  require "geekpark_api/activities"
9
9
 
10
10
  module GeekparkApi
11
- extend self
12
- #config
11
+ class << self
12
+ #config
13
13
 
14
- def config
15
- @config ||= Configuration.new
16
- end
14
+ def config
15
+ Configuration.instance
16
+ end
17
17
 
18
- def configure
19
- yield(config)
18
+ def configure
19
+ yield(config)
20
+ end
20
21
  end
21
22
 
22
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geekpark_api
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
  - Gavin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,7 @@ files:
87
87
  - lib/geekpark_api/configuration.rb
88
88
  - lib/geekpark_api/orders.rb
89
89
  - lib/geekpark_api/sign.rb
90
- - lib/geekpark_api/users.rb
90
+ - lib/geekpark_api/user.rb
91
91
  - lib/geekpark_api/version.rb
92
92
  homepage: https://github.com/GeekPark/geekpark_api
93
93
  licenses: []
@@ -1,5 +0,0 @@
1
- module GeekparkApi
2
- class Users
3
-
4
- end
5
- end