jaconda 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,7 +1,7 @@
1
1
  Jaconda API
2
2
  --------------
3
3
 
4
- The official ruby wrapper for working with the [Jaconda REST API](http://help.jaconda.im/faqs/api/jaconda-api-documentation)'s XML interface.
4
+ The official ruby wrapper for working with the [Jaconda REST API](http://help.jaconda.im/kb/api-v2/jaconda-api-documentation)'s XML interface.
5
5
 
6
6
  ## Installation
7
7
 
@@ -13,46 +13,106 @@ ActiveResource
13
13
 
14
14
  ## Usage
15
15
 
16
- The first thing you need to set the authentication.
16
+ ### Sending notifications
17
17
 
18
- Jaconda::API.authenticate("API_TOKEN")
18
+ Jaconda::Notification.authenticate(:subdomain => "JACONDA_SUBDOMAIN",
19
+ :room_id => "ROOM_ID",
20
+ :room_token => "ROOM_TOKEN")
19
21
 
20
- ### Finding rooms
22
+ Jaconda::Notification.notify(:text => "146 tests, 1399 assertions, 0 failures, 0 errors",
23
+ :sender_name => "Build Server")
21
24
 
22
- Jaconda::Room.find(:all) # find all rooms for the current account.
23
- Jaconda::Room.find(123) # find individual room by ID
25
+ ### Using API
24
26
 
25
- ### Creating a Room
27
+ Jaconda::API.authenticate(:subdomain => "JACONDA_SUBDOMAIN",
28
+ :token => "API_TOKEN")
26
29
 
27
- room = Jaconda::Room.new(:jid => 'awesome.project')
28
- room.title = "Awesome Project Room"
29
- room.save
30
+ Jaconda::API.authenticate(:subdomain => "JACONDA_SUBDOMAIN",
31
+ :email => "EMAIL",
32
+ :password => "PASSWORD")
33
+
34
+ #### Finding rooms
35
+
36
+ Jaconda::API::Room.find(:all)
37
+ Jaconda::API::Room.find("support")
38
+
39
+ #### Finding who's available in the room
40
+
41
+ room = Jaconda::API::Room.find("support")
42
+ room.available_users
43
+
44
+ #### Finding who has access to the room
30
45
 
31
- ### Updating a Room
46
+ room = Jaconda::API::Room.find("support")
47
+ room.presences
32
48
 
33
- room = Jaconda::Room.find(123)
34
- room.status_message = "Deadline: 3 apr"
49
+ #### Creating a Room
50
+
51
+ Jaconda::API::Room.create(:jid => "awesome.project",
52
+ :title => "Awesome Project Room")
53
+
54
+ #### Updating a Room
55
+
56
+ room = Jaconda::API::Room.find("support")
57
+ room.topic = "Deadline: 3 apr"
35
58
  room.save
36
59
 
37
- ### Finding messages
60
+ #### Finding messages
38
61
 
39
- room = Jaconda::Room.find(123)
62
+ room = Jaconda::API::Room.find("support")
40
63
  room.messages
41
-
42
- Jaconda::Message.find(:all, :params => { :room_id => 123 })
43
- Jaconda::Message.find(:all, :params => { :room_id => 123, :per_page => 100, :page => 2 })
64
+ room.messages(:page => 2)
65
+
66
+ Jaconda::API::Message.find(:all, :params => { :room_id => "support",
67
+ :per_page => 100,
68
+ :page => 2 })
69
+
70
+ #### Finding messages on date
71
+
72
+ room = Jaconda::API::Room.find("support")
73
+ room.transcript
74
+ room.transcript(:date => Date.yesterday)
75
+
76
+ Jaconda::API::Message.transcript(:room_id => "support",
77
+ :date => Date.today - 1.month)
78
+
79
+ #### Searching for messages
80
+
81
+ room = Jaconda::API::Room.find("support")
82
+ room.search(:text => "bug")
83
+ room.search(:text => "commit", :per_page => 5)
84
+
85
+ Jaconda::API::Message.search(:room_id => "support",
86
+ :text => "issue",
87
+ :page => 2)
88
+
89
+ #### Saying something
90
+
91
+ Jaconda::API::Message.create(:room_id => "support",
92
+ :text => "Hello from the API!")
93
+
94
+ Jaconda::API::Message.create(:room_id => "support",
95
+ :text => "is loving Jaconda!",
96
+ :kind => "me")
97
+
98
+ Jaconda::API::Message.create(:room_id => "support",
99
+ :text => "Hello from the API!",
100
+ :kind => "voice")
101
+
102
+ #### Finding members
44
103
 
45
- ### Creating a Message
104
+ Jaconda::API::Member.find(:all)
105
+ Jaconda::API::Member.find(123)
46
106
 
47
- Jaconda::Message.create(:room_id => 123, :text => "Hello from the API!")
107
+ #### Inviting new member
48
108
 
49
- ### Finding users
109
+ Jaconda::API::Member.create(:name => "Anton",
110
+ :email => "developer@gmail.com")
50
111
 
51
- room = Jaconda::Room.find(123)
52
- room.users
53
-
54
- Jaconda::User.find(:all, :params => { :room_id => 123 })
112
+ #### Finding uploads
55
113
 
56
- ### Creating a User
114
+ room = Jaconda::API::Room.find("support")
115
+ room.uploads
57
116
 
58
- Jaconda::User.create(:room_id => 123, :jid => "developer@gmail.com")
117
+ member = Jaconda::API::Member.find(123)
118
+ member.uploads
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gem.email = "ant.mironov@gmail.com"
10
10
  gem.homepage = "http://github.com/mironov/jaconda-api"
11
11
  gem.authors = ["Anton Mironov"]
12
- gem.add_dependency "activeresource"
12
+ gem.add_dependency "activeresource", "~> 2.3.5"
13
13
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
14
  end
15
15
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 2.0.0
data/jaconda.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jaconda}
8
- s.version = "1.0.2"
8
+ s.version = "2.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anton Mironov"]
12
- s.date = %q{2010-12-12}
12
+ s.date = %q{2011-02-27}
13
13
  s.email = %q{ant.mironov@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -23,6 +23,13 @@ Gem::Specification.new do |s|
23
23
  "VERSION",
24
24
  "jaconda.gemspec",
25
25
  "lib/jaconda.rb",
26
+ "lib/jaconda/base.rb",
27
+ "lib/jaconda/member.rb",
28
+ "lib/jaconda/message.rb",
29
+ "lib/jaconda/notification.rb",
30
+ "lib/jaconda/presence.rb",
31
+ "lib/jaconda/room.rb",
32
+ "lib/jaconda/upload.rb",
26
33
  "test/helper.rb",
27
34
  "test/test_jaconda.rb"
28
35
  ]
@@ -41,14 +48,14 @@ Gem::Specification.new do |s|
41
48
  s.specification_version = 3
42
49
 
43
50
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<activeresource>, [">= 0"])
51
+ s.add_runtime_dependency(%q<activeresource>, ["~> 2.3.5"])
45
52
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
46
53
  else
47
- s.add_dependency(%q<activeresource>, [">= 0"])
54
+ s.add_dependency(%q<activeresource>, ["~> 2.3.5"])
48
55
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
56
  end
50
57
  else
51
- s.add_dependency(%q<activeresource>, [">= 0"])
58
+ s.add_dependency(%q<activeresource>, ["~> 2.3.5"])
52
59
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
53
60
  end
54
61
  end
data/lib/jaconda.rb CHANGED
@@ -1,31 +1,9 @@
1
- require 'active_resource'
2
-
3
- module Jaconda
4
- class API < ActiveResource::Base
5
- self.site = "https://jaconda.im"
6
- self.prefix = "/api/"
7
-
8
- def self.authenticate(api_token)
9
- self.password = 'x'
10
- self.user = api_token
11
- end
12
- end
13
-
14
- class Room < API
15
- def users(options = {})
16
- User.find(:all, :params => options.update(:room_id => id))
17
- end
18
-
19
- def messages(options = {})
20
- Message.find(:all, :params => options.update(:room_id => id))
21
- end
22
- end
23
-
24
- class User < API
25
- self.prefix = "/api/rooms/:room_id/"
26
- end
27
-
28
- class Message < API
29
- self.prefix = "/api/rooms/:room_id/"
30
- end
31
- end
1
+ require "active_resource"
2
+
3
+ require "jaconda/base"
4
+ require "jaconda/notification"
5
+ require "jaconda/room"
6
+ require "jaconda/upload"
7
+ require "jaconda/member"
8
+ require "jaconda/presence"
9
+ require "jaconda/message"
@@ -0,0 +1,16 @@
1
+ module Jaconda
2
+ class API < ActiveResource::Base
3
+ self.prefix = "/api/v2/"
4
+
5
+ def self.authenticate(options)
6
+ self.site = "https://#{options[:subdomain]}.jaconda.im"
7
+ if options[:token]
8
+ self.user = options[:token]
9
+ self.password = "x"
10
+ else
11
+ self.user = options[:email]
12
+ self.password = options[:password]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module Jaconda
2
+ class API::Member < API
3
+ self.element_name = "user"
4
+
5
+ def self.collection_name
6
+ "members"
7
+ end
8
+
9
+ def presences
10
+ API::Presence.prefix = "/api/v2/members/:user_id/"
11
+ API::Presence.find(:all, :params => {:user_id => id})
12
+ end
13
+
14
+ def uploads
15
+ API::Upload.prefix = "/api/v2/members/:user_id/"
16
+ API::Upload.find(:all, :params => {:user_id => id})
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module Jaconda
2
+ class API::Message < API
3
+ self.prefix = "/api/v2/rooms/:room_id/"
4
+
5
+ def self.search(options = {})
6
+ get(:search, options)
7
+ end
8
+
9
+ def self.transcript(options = {})
10
+ date = options[:date] || Date.today
11
+ get("#{date.year}/#{date.month}/#{date.day}", options)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Jaconda
2
+ class Notification < ActiveResource::Base
3
+ self.prefix = "/api/v2/rooms/:room_id/"
4
+ self.element_name = ""
5
+
6
+ def self.authenticate(options)
7
+ self.site = "https://#{options[:subdomain]}.jaconda.im"
8
+ @room_id = options[:room_id]
9
+ self.user = options[:room_token]
10
+ self.password = "x"
11
+ end
12
+
13
+ def self.notify(params = {})
14
+ post(:notify, :message => params, :room_id => @room_id)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ module Jaconda
2
+ class API::Presence < API
3
+ end
4
+ end
@@ -0,0 +1,29 @@
1
+ module Jaconda
2
+ class API::Room < API
3
+ def id
4
+ jid
5
+ end
6
+
7
+ def presences
8
+ API::Presence.prefix = "/api/v2/rooms/:room_id/"
9
+ API::Presence.find(:all, :params => {:room_id => id})
10
+ end
11
+
12
+ def uploads
13
+ API::Upload.prefix = "/api/v2/rooms/:room_id/"
14
+ API::Upload.find(:all, :params => {:room_id => id})
15
+ end
16
+
17
+ def messages(options = {})
18
+ API::Message.find(:all, :params => options.update(:room_id => id))
19
+ end
20
+
21
+ def search(options = {})
22
+ API::Message.search(options.update(:room_id => id))
23
+ end
24
+
25
+ def transcript(options = {})
26
+ API::Message.transcript(options.update(:room_id => id))
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module Jaconda
2
+ class API::Upload < API
3
+ self.prefix = "/api/v2/rooms/:room_id/"
4
+ end
5
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jaconda
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
- - 1
8
- - 0
9
7
  - 2
10
- version: 1.0.2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anton Mironov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-12 00:00:00 +05:00
18
+ date: 2011-02-27 00:00:00 +05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,12 +24,14 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 9
30
30
  segments:
31
- - 0
32
- version: "0"
31
+ - 2
32
+ - 3
33
+ - 5
34
+ version: 2.3.5
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
@@ -63,6 +65,13 @@ files:
63
65
  - VERSION
64
66
  - jaconda.gemspec
65
67
  - lib/jaconda.rb
68
+ - lib/jaconda/base.rb
69
+ - lib/jaconda/member.rb
70
+ - lib/jaconda/message.rb
71
+ - lib/jaconda/notification.rb
72
+ - lib/jaconda/presence.rb
73
+ - lib/jaconda/room.rb
74
+ - lib/jaconda/upload.rb
66
75
  - test/helper.rb
67
76
  - test/test_jaconda.rb
68
77
  has_rdoc: true