mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-25 11:38:49 +01:00
258 lines
7.7 KiB
Text
258 lines
7.7 KiB
Text
<h1><%= t('rest_help.title') %></h1>
|
|
|
|
<h2><%= t('rest_help.intro.title') %></h2>
|
|
|
|
<p><%= t('rest_help.intro.content') %></p>
|
|
<p><%= t('rest_help.intro.content_2') %></p>
|
|
|
|
<p><%= raw I18n.t 'rest_help.intro.content_3', restful_link: link_to(I18n.t('rest_help.intro.restful_link_text'), 'http://en.wikipedia.org/wiki/REST') %></p>
|
|
|
|
<h2><%= t('rest_help.auth.title') %></h2>
|
|
|
|
<p><%= raw I18n.t 'rest_help.auth.content', auth_link: link_to(I18n.t('rest_help.auth.basic_auth_link_text'), 'http://en.wikipedia.org/wiki/Basic_authentication') %></p>
|
|
|
|
<h2><%= t('rest_help.retrieve.title') %></h2>
|
|
|
|
<p><%= raw I18n.t 'rest_help.retrieve.content', curl_link: link_to(I18n.t('rest_help.curl_link_text'), 'http://en.wikipedia.org/wiki/CURL') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
<%= root_url %>contexts.xml
|
|
>> <?xml version="1.0" encoding="UTF-8"?>
|
|
<contexts>...</contexts>
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= t('rest_help.retrieve.single_context') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
<%= root_url %>contexts/51.xml
|
|
>> <?xml version="1.0" encoding="UTF-8"?>
|
|
<context>...</context>
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= t('rest_help.retrieve.todos_from_context') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
<%= root_url %>contexts/51/todos.xml
|
|
>> <?xml version="1.0" encoding="UTF-8"?>
|
|
<todos type="array">...</todos>
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= t('rest_help.retrieve.projects') %></p>
|
|
<p><%= t('rest_help.retrieve.paths_title') %></p>
|
|
|
|
<ul>
|
|
<li>/todos.xml</li>
|
|
<li>/todos/done.xml</li>
|
|
<li>/todos/<code><%= t('rest_help.id') %></code>.xml</li>
|
|
<li>/tickler.xml</li>
|
|
<li>/hidden.xml</li>
|
|
<li>/calendar.xml</li>
|
|
<li>/contexts.xml</li>
|
|
<li>/contexts/<code><%= t('rest_help.id') %></code>.xml</li>
|
|
<li>/contexts/<code><%= t('rest_help.id') %></code>/todos.xml</li>
|
|
<li>/projects.xml</li>
|
|
<li>/projects/<code><%= t('rest_help.id') %></code>.xml</li>
|
|
<li>/projects/<code><%= t('rest_help.id') %></code>/todos.xml</li>
|
|
</ul>
|
|
|
|
<p><%= raw t('rest_help.retrieve.limit',
|
|
fields: '<code>ID, created_at, modified_at, completed_at</code>',
|
|
limit_parameter: '<code>limit_fields</code>',
|
|
set_to: '<code>index</code>') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
<%= root_url %>tickler.xml?limit_fields=index
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw t('rest_help.retrieve.active_todos', active_code: '<code>limit_to_active_todos</code>') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
<%= root_url %>todos.xml?limit_to_active_todos=1
|
|
</code>
|
|
</pre>
|
|
|
|
<h2><%= t('rest_help.writing.title') %></h2>
|
|
|
|
<p><%= raw t('rest_help.writing.description',
|
|
put: '<code>PUT</code>',
|
|
post: '<code>POST</code>',
|
|
delete: '<code>DELETE</code>') %></p>
|
|
|
|
<p><%= t('rest_help.writing.example_title') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
-d "<project><name><%= t('rest_help.writing.example_project_name') %></name></project>" \
|
|
<%= root_url %>projects.xml -i
|
|
>> HTTP/1.1 201 Created
|
|
Location: <%= root_url %>projects/65.xml
|
|
...
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw t('rest_help.writing.example_project_response_title',
|
|
response_code: '<code>HTTP/1.1 201 Created</code>',
|
|
header: '<code>Location</code>') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
-d "<todo><description><%= t('rest_help.writing.example_todo_name') %></description><context_id>2</context_id><project_id>65</project_id></todo>" \
|
|
<%= root_url %>todos.xml -i
|
|
>> HTTP/1.1 201 Created
|
|
Location: <%= root_url %>todos/452.xml
|
|
...
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw t('rest_help.writing.example_todo_response_title',
|
|
response_code: '<code>HTTP/1.1 201 Created</code>',
|
|
header: '<code>Location</code>') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \
|
|
-d "<todo><notes><%= t('rest_help.writing.example_note_text') %></notes></todos>" \
|
|
<%= root_url %>todos/452.xml -i
|
|
>> HTTP/1.1 200 OK
|
|
...
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<todo>
|
|
...
|
|
<description><%= t('rest_help.writing.example_todo_name') %></description>
|
|
|
|
<notes><%= t('rest_help.writing.example_note_text') %></notes>
|
|
...
|
|
</todo>
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw t('rest_help.writing.example_note_response_title',
|
|
response_code: '<code>HTTP/1.1 200 OK</code>') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \
|
|
<%= root_url %>todos/452/toggle_check.xml -i
|
|
>> HTTP/1.1 200 OK
|
|
...
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<todo>
|
|
...
|
|
<completed-at type=\"datetime\">2007-12-05T06:43:25Z</completed-at>
|
|
|
|
<state>completed</state>
|
|
...
|
|
</todo>
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw t('rest_help.writing.example_delete_title',
|
|
delete: '<code>DELETE</code>') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X DELETE \
|
|
<%= root_url %>todos/452.xml -i
|
|
>> HTTP/1.1 200 OK
|
|
...
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw t('rest_help.writing.example_delete_response_title',
|
|
response_code: '<code>HTTP/1.1 200 OK</code>') %></p>
|
|
|
|
<h2><%= t('rest_help.response.title') %></h2>
|
|
|
|
<p><%= raw t('rest_help.response.description',
|
|
response_200: '<code>200 OK</code>',
|
|
response_201: '<code>201 Created</code>',
|
|
example_call: '<code>GET /contexts/2/todos.xml</code>') %></p>
|
|
|
|
<p><%= t('rest_help.response.xml_description') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
|
<%= root_url %>contexts/2/todos.xml
|
|
>> <?xml version="1.0" encoding="UTF-8"?>
|
|
<nil-classes type="array"/>
|
|
|
|
</code>
|
|
</pre>
|
|
|
|
<h2><%= t('rest_help.activeresource.title') %></h2>
|
|
|
|
<p><%= raw I18n.t 'rest_help.activeresource.description',
|
|
activeresource_link: link_to(I18n.t('rest_help.activeresource.activeresource_link_text'), 'http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release'),
|
|
ror_link: link_to(I18n.t('rest_help.activeresource.ror_link_text'), 'http://www.rubyonrails.org'),
|
|
gem_command: '<code>gem install activeresource --source http://gems.rubyonrails.org --include-dependencies</code>'
|
|
%></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ script/console
|
|
Loading development environment (Rails 1.2.4)
|
|
>> class Context < ActiveResource::Base; end
|
|
=> nil
|
|
>> Context.site = "<%= root_url %>"
|
|
=> "<%= root_url %>"
|
|
>> Context.site.user = "username"
|
|
=> "username"
|
|
|
|
>> Context.site.password = CGI.escape "p4ssw0rd"
|
|
=> "p4ssw0rd"
|
|
>> Context.find :first
|
|
=> #<Context:0x262396c @prefix_options={}, @attributes={...}>
|
|
>> >> Context.find :all
|
|
=> [#<Context:0x274cfc8 @prefix_options={}, @attributes={...}, ...]
|
|
</code>
|
|
</pre>
|
|
|
|
<p><%= raw I18n.t 'rest_help.activeresource.wrapper_description',
|
|
signals_link: link_to(I18n.t('rest_help.activeresource.signals_link_text'), 'http://www.37signals.com') %></p>
|
|
|
|
<pre>
|
|
<code>
|
|
$ SITE="http://username:p4ssw0rd@<%= request.host_with_port %>" irb \
|
|
-r tracks_api_wrapper.rb
|
|
|
|
irb(main):001:0> inbox = Tracks::Context.find :first
|
|
irb(main):002:0> inbox.name
|
|
=> "@inbox"
|
|
irb(main):003:0>
|
|
</code>
|
|
</pre>
|
|
|
|
<h2><%= t('rest_help.notes.title') %></h2>
|
|
|
|
<p><%= t('rest_help.notes.description') %></p>
|
|
|
|
<ul>
|
|
<li><%= raw I18n.t 'rest_help.notes.bullet1',
|
|
id: '<code>ID</code>',
|
|
url: '<span class="caps">URL</span>' %></li>
|
|
<li><%= raw I18n.t 'rest_help.notes.bullet2',
|
|
omit: '<code>...</code>' %></li>
|
|
</ul>
|
|
|
|
<p><%= raw I18n.t 'rest_help.notes.curl_description',
|
|
curl: link_to(I18n.t('rest_help.curl_link_text'), 'http://en.wikipedia.org/wiki/CURL') %></p>
|
|
</div>
|