<%= t('rest_help.title') %>

<%= t('rest_help.intro.title') %>

<%= t('rest_help.intro.content') %>

<%= t('rest_help.intro.content_2') %>

<%= 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') %>

<%= t('rest_help.auth.title') %>

<%= 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') %>

<%= t('rest_help.retrieve.title') %>

<%= raw I18n.t 'rest_help.retrieve.content', curl_link: link_to(I18n.t('rest_help.curl_link_text'), 'http://en.wikipedia.org/wiki/CURL') %>


  $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
      <%= root_url %>contexts.xml
  >> <?xml version="1.0" encoding="UTF-8"?>
  <contexts>...</contexts>

<%= t('rest_help.retrieve.single_context') %>


  $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
      <%= root_url %>contexts/51.xml
  >> <?xml version="1.0" encoding="UTF-8"?>
  <context>...</context>

<%= t('rest_help.retrieve.todos_from_context') %>


  $ 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>

<%= t('rest_help.retrieve.projects') %>

<%= t('rest_help.retrieve.paths_title') %>

<%= raw t('rest_help.retrieve.limit', fields: 'ID, created_at, modified_at, completed_at', limit_parameter: 'limit_fields', set_to: 'index') %>


  $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
  <%= root_url %>tickler.xml?limit_fields=index

<%= raw t('rest_help.retrieve.active_todos', active_code: 'limit_to_active_todos') %>


  $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
  <%= root_url %>todos.xml?limit_to_active_todos=1

<%= t('rest_help.writing.title') %>

<%= raw t('rest_help.writing.description', put: 'PUT', post: 'POST', delete: 'DELETE') %>

<%= t('rest_help.writing.example_title') %>


$ 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
...

<%= raw t('rest_help.writing.example_project_response_title', response_code: 'HTTP/1.1 201 Created', header: 'Location') %>


$ 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
...

<%= raw t('rest_help.writing.example_todo_response_title', response_code: 'HTTP/1.1 201 Created', header: 'Location') %>


  $ 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>

<%= raw t('rest_help.writing.example_note_response_title', response_code: 'HTTP/1.1 200 OK') %>


  $ 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>

<%= raw t('rest_help.writing.example_delete_title', delete: 'DELETE') %>


  $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X DELETE \
      <%= root_url %>todos/452.xml -i
  >> HTTP/1.1 200 OK
  ...

<%= raw t('rest_help.writing.example_delete_response_title', response_code: 'HTTP/1.1 200 OK') %>

<%= t('rest_help.response.title') %>

<%= raw t('rest_help.response.description', response_200: '200 OK', response_201: '201 Created', example_call: 'GET /contexts/2/todos.xml') %>

<%= t('rest_help.response.xml_description') %>


$ 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"/>


<%= t('rest_help.activeresource.title') %>

<%= 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: 'gem install activeresource --source http://gems.rubyonrails.org --include-dependencies' %>


$ 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={...}, ...]

<%= raw I18n.t 'rest_help.activeresource.wrapper_description', signals_link: link_to(I18n.t('rest_help.activeresource.signals_link_text'), 'http://www.37signals.com') %>


$ 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>

<%= t('rest_help.notes.title') %>

<%= t('rest_help.notes.description') %>

<%= raw I18n.t 'rest_help.notes.curl_description', curl: link_to(I18n.t('rest_help.curl_link_text'), 'http://en.wikipedia.org/wiki/CURL') %>