textamerica 0.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.
- data/README +13 -0
- data/Rakefile +75 -0
- data/lib/textamerica.rb +242 -0
- data/test/test_helper.rb +4 -0
- data/test/textamerica/textamerica_test.rb +18 -0
- metadata +42 -0
data/README
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
== Welcome to TextAmerica
|
2
|
+
|
3
|
+
TextAmerica is a ruby library for interacting with TextAmerica.com
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
require 'textAmerica'
|
7
|
+
@tamerica = TextAmerica::Client.new <APIKEY>, <USERNAME>, <PASSWORD>
|
8
|
+
|
9
|
+
== About
|
10
|
+
|
11
|
+
Author:: Mark Lussier (mailto:mlussier@gmail.com)
|
12
|
+
Copyright:: Copyright (c) 2005 Mark Lussier
|
13
|
+
License:: BSD
|
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/contrib/rubyforgepublisher'
|
7
|
+
|
8
|
+
PKG_VERSION = "0.1"
|
9
|
+
|
10
|
+
PKG_FILES = FileList[
|
11
|
+
"lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "doc/**/*"
|
12
|
+
]
|
13
|
+
|
14
|
+
desc "Default Task"
|
15
|
+
task :default => [ :test ]
|
16
|
+
|
17
|
+
# Run the unit tests
|
18
|
+
desc "Run all unit tests"
|
19
|
+
Rake::TestTask.new("test") { |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.pattern = 'test/*/*_test.rb'
|
22
|
+
t.verbose = true
|
23
|
+
}
|
24
|
+
|
25
|
+
# Genereate the RDoc documentation
|
26
|
+
desc "Create documentation"
|
27
|
+
Rake::RDocTask.new("doc") { |rdoc|
|
28
|
+
rdoc.rdoc_dir = 'doc'
|
29
|
+
rdoc.rdoc_files.include('README')
|
30
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
|
+
}
|
32
|
+
|
33
|
+
# Genereate the package
|
34
|
+
spec = Gem::Specification.new do |s|
|
35
|
+
|
36
|
+
#### Basic information.
|
37
|
+
|
38
|
+
s.name = 'textamerica'
|
39
|
+
s.version = PKG_VERSION
|
40
|
+
s.summary = <<-EOF
|
41
|
+
A Ruby API for interacting with TextAmerica.com
|
42
|
+
EOF
|
43
|
+
s.description = <<-EOF
|
44
|
+
A Ruby API for interacting with TextAmerica.com
|
45
|
+
EOF
|
46
|
+
|
47
|
+
#### Which files are to be included in this gem? Everything! (Except CVS directories.)
|
48
|
+
|
49
|
+
s.files = PKG_FILES
|
50
|
+
|
51
|
+
#### Load-time details: library and application (you will need one or both).
|
52
|
+
|
53
|
+
s.require_path = 'lib'
|
54
|
+
s.autorequire = 'textamerica'
|
55
|
+
|
56
|
+
#### Documentation and testing.
|
57
|
+
|
58
|
+
s.has_rdoc = true
|
59
|
+
|
60
|
+
#### Author and project details.
|
61
|
+
|
62
|
+
s.author = "Mark Lussier"
|
63
|
+
s.email = "mlussier@gmail.com"
|
64
|
+
s.homepage = "http://rubyforge.org/projects/textamerica/"
|
65
|
+
end
|
66
|
+
|
67
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
68
|
+
pkg.need_zip = true
|
69
|
+
pkg.need_tar = true
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Publish to RubyForge"
|
73
|
+
task :rubyforge do
|
74
|
+
Rake::RubyForgePublisher.new('textamerica', 'intabulas').upload
|
75
|
+
end
|
data/lib/textamerica.rb
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
##
|
4
|
+
# Ruby API for TextAmerica (See http://www.textamerica.com/api.aspx)
|
5
|
+
# Copyright 2005 Mark Lussier
|
6
|
+
#
|
7
|
+
# HISTORY:
|
8
|
+
#
|
9
|
+
# 0.1 [2005-04-13]: Initial release
|
10
|
+
#
|
11
|
+
##
|
12
|
+
|
13
|
+
|
14
|
+
require 'xmlrpc/client'
|
15
|
+
require 'base64'
|
16
|
+
|
17
|
+
|
18
|
+
module TextAmerica
|
19
|
+
|
20
|
+
class Client
|
21
|
+
|
22
|
+
#
|
23
|
+
def initialize( apikey, username, password)
|
24
|
+
#@client = XMLRPC::Client.new('xml.api.textamerica.com', '/', 80)
|
25
|
+
@client = XMLRPC::Client.new('localhost', "/",3333)
|
26
|
+
@apikey = apikey
|
27
|
+
@username = username
|
28
|
+
@password = password
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
##
|
33
|
+
# ta.Moblog Methods
|
34
|
+
##
|
35
|
+
|
36
|
+
# Returns a list of the owners moblogs
|
37
|
+
#
|
38
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.GetMyMoblogs
|
39
|
+
def getMyMoblogs
|
40
|
+
return @client.call( 'ta.Moblog.GetMyMoblogs', @apikey, @username, @password )
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns a list of community moblog
|
44
|
+
#
|
45
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.GetCommunityMoblogs
|
46
|
+
def getCommunityMoblogs( which )
|
47
|
+
return @client.call( 'ta.Moblog.GetCommunityMoblogs', @apikey, @username, @password, which)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Changes the specific properties of your moblog such as title, text, domain, secret word. Returns a MoblogID
|
51
|
+
#
|
52
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.Update
|
53
|
+
def update( moblogid, domain, secretword, title, text, approvaltype, allowcomments )
|
54
|
+
return @client.call( 'ta.Moblog.Update', @apikey, @username, @password, moblogid,
|
55
|
+
domain, secretword, title, text, approvaltype, allowcomments)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Updates the title of a moblog. Returns the MoblogID.
|
59
|
+
#
|
60
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.ChangeTitle
|
61
|
+
def changeTitle( moblogid, title)
|
62
|
+
return @client.call( 'ta.Moblog.ChangeTitle', @apikey, @username, @password, moblogid, title)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Updates the description of a moblog. Returns the MoblogID
|
66
|
+
#
|
67
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.ChangeText
|
68
|
+
def changeText( moblogid, text)
|
69
|
+
return @client.call( 'ta.Moblog.ChangeText', @apikey, @username, @password, moblogid, text)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Changes an existing moblog domain. Returns the MoblogID
|
73
|
+
#
|
74
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.ChangeDomain
|
75
|
+
def changeDomain( moblogid, domain)
|
76
|
+
return @client.call( 'ta.Moblog.ChangeDomain', @apikey, @username, @password, moblogid, domain)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Changes the secret word of a moblog. Returns the MoblogID
|
80
|
+
#
|
81
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Moblog.ChangeSecretWord
|
82
|
+
def changeSecretWord( moblogid, secretword)
|
83
|
+
return @client.call( 'ta.Moblog.ChangeSecretWord', @apikey, @username, @password, moblogid, secretword)
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# ta.Bookmarks Methods
|
88
|
+
##
|
89
|
+
|
90
|
+
# Updates or creates a new bookmark list. Returns the bookmark list id.
|
91
|
+
#
|
92
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Bookmarks.Update
|
93
|
+
def bookmarksUpdate( listid, title)
|
94
|
+
return @client.call( 'ta.Bookmarks.Update', @apikey, @username, @password, listid, title)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Assigns a bookmark list to a specified moblog.
|
98
|
+
#
|
99
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Bookmarks.Assign
|
100
|
+
def bookmarksAssign( moblogid, listid)
|
101
|
+
return @client.call( 'ta.Bookmarks.Assign', @apikey, @username, @password, moblogid, listid)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Removes a bookmark list from a specified moblog
|
105
|
+
#
|
106
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Bookmarks.UnAssign
|
107
|
+
def bookmarksUnAssign( moblogid, listid)
|
108
|
+
return @client.call( 'ta.Bookmarks.UnAssign', @apikey, @username, @password, moblogid, listid)
|
109
|
+
end
|
110
|
+
|
111
|
+
# http://www.textamerica.com/apicalls.aspx?call=Bookmarks.Delete
|
112
|
+
#
|
113
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Bookmarks.Delete
|
114
|
+
def bookmarksDelete( listid)
|
115
|
+
return @client.call( 'ta.Bookmarks.Delete', @apikey, @username, @password, listid)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Updates or creates a new URL on a specified list.
|
119
|
+
#
|
120
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Bookmarks.UpdateURL
|
121
|
+
def bookmatksUpdateUrl(listid, title, url, target)
|
122
|
+
return @client.call( 'ta.Bookmarks.UpdateUrl', @apikey, @username, @password, listid, title, url, target)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Removes a URL from a specified bookmark list.
|
126
|
+
#
|
127
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Bookmarks.RemoveURL
|
128
|
+
def bookmatksRemoveUrl(listid, url)
|
129
|
+
return @client.call( 'ta.Bookmarks.RemoveUrl', @apikey, @username, @password, listid, url)
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
##
|
134
|
+
# ta.Favorites Methods
|
135
|
+
##
|
136
|
+
|
137
|
+
# Returns a list of the owners moblogs.
|
138
|
+
#
|
139
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Favorites.Update
|
140
|
+
def favoritesUpdate( listid, listtitle)
|
141
|
+
return @client.call( 'ta.Favorites.Update', @apikey, @username, @password, listid, listtitle)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Assigns a Favorites List to be displayed on a moblog.
|
145
|
+
#
|
146
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Favorites.Assign
|
147
|
+
def favoritesAssign( moblogid, listid)
|
148
|
+
return @client.call( 'ta.Favorites.Assign', @apikey, @username, @password, moblogid, listid)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Remove a moblog to a Favorites List.
|
152
|
+
#
|
153
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Favorites.Delete
|
154
|
+
def favoritesDelete( listid, listtitle)
|
155
|
+
return @client.call( 'ta.Favorites.Delete', @apikey, @username, @password, listid, listtitle)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Add a moblog to a Favorites List
|
159
|
+
#
|
160
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Favorites.AddMoblog
|
161
|
+
def favoritesAddMoblog( listid, moblogurl)
|
162
|
+
return @client.call( 'ta.Favorites.AddMoblog', @apikey, @username, @password, listid, moblogurl)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Remove a moblog to a Favorites List.
|
166
|
+
#
|
167
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Favorites.RemoveMoblog
|
168
|
+
def favoritesRemoveMoblog( listid, moblogurl)
|
169
|
+
return @client.call( 'ta.Favorites.RemoveMoblog', @apikey, @username, @password, listid, moblogurl)
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# ta.Template Methods
|
174
|
+
##
|
175
|
+
|
176
|
+
# Updates the section HTML for a specified moblog
|
177
|
+
#
|
178
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Template.UpdateSection
|
179
|
+
def templateUpdateSection(moblogid, sectionid, htmlcode)
|
180
|
+
return @client.call( 'ta.Template.UpdateSection', @apikey, @username, @password, moblogid, sectionid, htmlcode)
|
181
|
+
end
|
182
|
+
|
183
|
+
# Sets a template for a specified moblog from the textamerica template library
|
184
|
+
#
|
185
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Template.SetTemplate
|
186
|
+
def templateSetTemplate(moblogid, graphicid, layoutid)
|
187
|
+
return @client.call( 'ta.Template.SetTemplate', @apikey, @username, @password, moblogid, graphicid, layoutid)
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
##
|
192
|
+
# ta.Keywords Methods
|
193
|
+
##
|
194
|
+
|
195
|
+
# Adds keywords to a specified entry / image
|
196
|
+
#
|
197
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Keywords.Add
|
198
|
+
def keywordsAdd(entryid, keywords)
|
199
|
+
return @client.call( 'ta.Keywords.Add', @apikey, @username, @password, entryid, keywords)
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
# ta.Entry Methods
|
204
|
+
##
|
205
|
+
|
206
|
+
# Updates or creates a new image entry. Returns the EntryID.
|
207
|
+
#
|
208
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Entry.Update
|
209
|
+
def entryUpdate( moblogid, entryid, title, text, categoryid, imagedata, filetype)
|
210
|
+
return @client.call( 'ta.Entry.Update', @apikey, @username, @password, moblogid, entryid, title, text, categoryid, imagedata, filetype)
|
211
|
+
end
|
212
|
+
|
213
|
+
# Updates or creates a new image entry. Returns the EntryID.
|
214
|
+
#
|
215
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Entry.Update
|
216
|
+
def entryUpdateEx( moblogid, entryid, title, text, categoryid, file, filetype)
|
217
|
+
if File.exists?( file)
|
218
|
+
imagedata = File.open(file, "rb") {|f| f.read}
|
219
|
+
return @client.call( 'ta.Entry.Update', @apikey, @username, @password, moblogid, entryid, title, text,
|
220
|
+
categoryid, XMLRPC::Base64.encode(imagedata), filetype)
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
# Deletes a specified entry from a moblog. Returns "OK".
|
226
|
+
#
|
227
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Entry.Delete
|
228
|
+
def entryDelete( moblogid, entryid)
|
229
|
+
return @client.call( 'ta.Entry.Delete', @apikey, @username, @password, moblogid, entryid)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Deletes a specified entry from a moblog. Returns "OK".
|
233
|
+
#
|
234
|
+
# See http://www.textamerica.com/apicalls.aspx?call=Entry.Delete
|
235
|
+
def entryDelete?( moblogid, entryid)
|
236
|
+
result = @client.call( 'ta.Entry.Delete', @apikey, @username, @password, moblogid, entryid)
|
237
|
+
return result == 'OK'
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class TextAmericaTest < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@tamerica = TextAmerica::Client.new( 'TA113805', '<USERNAME>', '<PASSWORD>')
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def test_getMyMoblogs
|
10
|
+
assert_nothing_raised { moblogs = @tamerica.getMyMoblogs }
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_getCommunityMoblogs
|
14
|
+
assert_nothing_raised { moblogs = @tamerica.getCommunityMoblogs 5 }
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.10
|
3
|
+
specification_version: 1
|
4
|
+
name: textamerica
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.1"
|
7
|
+
date: 2005-04-14
|
8
|
+
summary: A Ruby API for interacting with TextAmerica.com
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: mlussier@gmail.com
|
12
|
+
homepage: http://rubyforge.org/projects/textamerica/
|
13
|
+
rubyforge_project:
|
14
|
+
description: A Ruby API for interacting with TextAmerica.com
|
15
|
+
autorequire: textamerica
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
authors:
|
28
|
+
- Mark Lussier
|
29
|
+
files:
|
30
|
+
- lib/textamerica.rb
|
31
|
+
- test/test_helper.rb
|
32
|
+
- test/textamerica
|
33
|
+
- test/textamerica/textamerica_test.rb
|
34
|
+
- Rakefile
|
35
|
+
- README
|
36
|
+
test_files: []
|
37
|
+
rdoc_options: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
requirements: []
|
42
|
+
dependencies: []
|