ruby-universe 0.0.4

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: 6c83a90b91a461fcfb9b03f29058294d0da51ae7
4
+ data.tar.gz: 22fd017265c3974ea3484979954a5ec131bbf40c
5
+ SHA512:
6
+ metadata.gz: 8277afebcb8bb60dfbc1fe788083a7f8d07eb0174779fb8d0dcce21187520e2f2209311cb44c8cb2fad1fdb07f51878474f4131f00db575eeb9ca1f705f8fb23
7
+ data.tar.gz: e7b7419716ffc996a3449c44fd44dbcb0e8e8c37f4651daab1ea5cd2bf98188488c33d79648f74b9a0de3a84190bafe097a77b9729dfeb0c2ff8af37c0beffee
@@ -0,0 +1,55 @@
1
+ [![Gem Version](https://badge.fury.io/rb/ruby-universe.svg)](http://badge.fury.io/rb/ruby-universe)
2
+
3
+ This gem is for Universe.com V2 API only.
4
+
5
+ # Get Started
6
+
7
+ gem install ruby-universe
8
+
9
+ For Rails project:
10
+
11
+ gem 'rubybrite', :require => 'universe'
12
+
13
+ ## Quick examples
14
+
15
+ ``@uapi = UniverseAPI.new("access_token")``
16
+
17
+ ### For Event API call:
18
+ ``@event = @uapi.listings(id: 123456)``
19
+
20
+ Get event details: ``@event.get``
21
+
22
+ Get event attendees: ``@event.attendees.get``
23
+
24
+ For a specific attendee: ``@event.attendees(id: 1234567).get``
25
+
26
+ Use options: ``@event.attendees(status: "attending").get``
27
+
28
+ Get event teams: ``@event.teams.get``
29
+
30
+ Get event team attendees: ``@event.teams(id: 123456).attendees.get``
31
+
32
+ ### For User API call:
33
+
34
+ When using personal OAuth token:
35
+ ``@user = @uapi.users(id: "me")``
36
+
37
+ When using a third party OAuth token:
38
+ ``@user = @uapi.users(id: third_party_user_id)``
39
+
40
+ OAuth token needs to be updated before making an API call on behalf of a third party:
41
+ ``UniverseAPI::Configuration.access_token="third-party-user-oauth-token"``
42
+
43
+ Get user details: ``@user.get``
44
+
45
+ Get user owned events attendees: ``@user.owned_event_attendees.get``
46
+
47
+ ### For Order API call:
48
+
49
+ ``@order = @uapi.orders(id: 123456)``
50
+ ``@order.get``
51
+
52
+ This gem also provides ``.post`` and ``.put``
53
+
54
+ For more information about V2 API, please visit http://developers.universe.com/.
55
+
@@ -0,0 +1,28 @@
1
+ require "httparty"
2
+ require "json"
3
+ require "universe/configuration"
4
+ require "universe/response"
5
+ require "universe/request"
6
+
7
+ class UniverseAPI
8
+ attr_accessor :access_token
9
+
10
+ def initialize( auth_token )
11
+ @access_token = auth_token
12
+ end
13
+
14
+ def method_missing(method, *args)
15
+ params = args[0].is_a?(Hash) ? args[0] : {}
16
+ path = ""
17
+ if not params[:id]
18
+ path = "/#{method}/?access_token=#{@access_token}"
19
+ else
20
+ # raise MissingIdException.new("#{method.capitalize} id can not be empty.") unless params[:id]
21
+ path = "/#{method}/#{params.delete(:id)}?access_token=#{@access_token}"
22
+ end
23
+ Request.new(path, params)
24
+ end
25
+
26
+ class APIException < ::Exception; end
27
+ class MissingIdException < APIException; end
28
+ end
@@ -0,0 +1,9 @@
1
+ class UniverseAPI
2
+ class Configuration
3
+ class << self
4
+ def end_point
5
+ "https://universe.com/api/v2"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,41 @@
1
+ class UniverseAPI
2
+ class Request
3
+ include HTTParty
4
+ base_uri Configuration.end_point
5
+
6
+ attr_accessor :path, :query
7
+
8
+ def initialize(path = "", query = {})
9
+ @path = path
10
+ @query = query
11
+ end
12
+
13
+ def get
14
+ response = self.class.get(path, query: query).body
15
+ Response.new(response)
16
+ end
17
+
18
+ def post
19
+ response = self.class.post(path, query: query).body
20
+ Response.new(response)
21
+ end
22
+
23
+ def put
24
+ response = self.class.put(path, query: query).body
25
+ Response.new(response)
26
+ end
27
+
28
+ def delete
29
+ response = self.class.delete(path, query: query).body
30
+ Response.new(response)
31
+ end
32
+
33
+ def method_missing(method, *args)
34
+ params = args[0].is_a?(Hash) ? args[0] : {}
35
+ route, token = path.split("?")
36
+ id = params.delete(:id)
37
+ route += "/#{method}/#{id}?#{token}"
38
+ Request.new(route, params)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ class UniverseAPI
2
+ class Response
3
+ attr_accessor :body
4
+
5
+ def initialize(json)
6
+ @body = JSON.parse(json)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "ruby-universe"
3
+ s.authors = ["John-Alan Simmons", "Xin Fan (Fred)"]
4
+ s.version = "0.0.4"
5
+ s.licenses = ['MIT']
6
+ s.email = ["simmons.johnalan@gmail.com", "fredxinfan@gmail.com"]
7
+ s.summary = "A simple API wrapper for Universe V2."
8
+ s.homepage = "https://github.com/ConferenceCloud/ruby-universe"
9
+ s.files = [
10
+ "README.md",
11
+ "ruby-universe.gemspec",
12
+ "lib/universe.rb",
13
+ "lib/universe/configuration.rb",
14
+ "lib/universe/request.rb",
15
+ "lib/universe/response.rb"
16
+ ]
17
+
18
+ s.add_dependency("httparty",["~> 0.13"])
19
+ s.add_dependency("json",["~> 1.8"])
20
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-universe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - John-Alan Simmons
8
+ - Xin Fan (Fred)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-05-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.13'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.13'
28
+ - !ruby/object:Gem::Dependency
29
+ name: json
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.8'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.8'
42
+ description:
43
+ email:
44
+ - simmons.johnalan@gmail.com
45
+ - fredxinfan@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - README.md
51
+ - lib/universe.rb
52
+ - lib/universe/configuration.rb
53
+ - lib/universe/request.rb
54
+ - lib/universe/response.rb
55
+ - ruby-universe.gemspec
56
+ homepage: https://github.com/ConferenceCloud/ruby-universe
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.5
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: A simple API wrapper for Universe V2.
80
+ test_files: []
81
+ has_rdoc: