return API key when creating a channel via API
This commit is contained in:
parent
6d48aaa8fc
commit
6e5883bb80
@ -206,8 +206,8 @@ class ChannelsController < ApplicationController
|
||||
channel.add_write_api_key
|
||||
@channel_id = channel.id
|
||||
respond_to do |format|
|
||||
format.json { render :json => channel.to_json(Channel.public_options) }
|
||||
format.xml { render :xml => channel.to_xml(Channel.public_options) }
|
||||
format.json { render :json => channel.to_json(Channel.private_options) }
|
||||
format.xml { render :xml => channel.to_xml(Channel.private_options) }
|
||||
format.any { redirect_to channel_path(@channel_id, :anchor => "channelsettings") }
|
||||
end
|
||||
end
|
||||
|
@ -172,6 +172,19 @@ class Channel < ActiveRecord::Base
|
||||
}
|
||||
end
|
||||
|
||||
# used when creating a channel
|
||||
def self.private_options
|
||||
{
|
||||
:root => false,
|
||||
:only => [:id, :name, :description, :latitude, :longitude, :last_entry_id, :elevation, :created_at, :ranking],
|
||||
:methods => :username,
|
||||
:include => {
|
||||
:tags => {:only => [:id, :name]},
|
||||
:api_keys => {:only => [:api_key, :write_flag]}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
# login name of the user who created the channel
|
||||
def username; self.user.try(:login); end
|
||||
|
||||
|
@ -58,7 +58,11 @@ POST <span class="str"><%= @ssl_api_domain %>channels<span class="format format-
|
||||
"last_entry_id": null,
|
||||
"ranking": 15,
|
||||
"username": "hans",
|
||||
"tags": []
|
||||
"tags": [],
|
||||
"api_keys": [{
|
||||
"api_key": "XXXXXXXXXXXXXXXX",
|
||||
"write_flag": true
|
||||
}]
|
||||
}
|
||||
</pre>
|
||||
|
||||
@ -81,6 +85,12 @@ POST <span class="str"><%= @ssl_api_domain %>channels<span class="format format-
|
||||
<ranking type="integer">15</ranking>
|
||||
<username>hans</username>
|
||||
<tags type="array" />
|
||||
<api-keys type="array">
|
||||
<api-key>
|
||||
<api-key>XXXXXXXXXXXXXXXX</api-key>
|
||||
<write-flag type="boolean">true</write-flag>
|
||||
</api-key>
|
||||
</api-keys>
|
||||
</channel>
|
||||
</pre>
|
||||
|
||||
|
@ -4,7 +4,8 @@
|
||||
</div>
|
||||
|
||||
<br>
|
||||
To update a Channel feed, send an HTTP GET or POST to <code><%= @ssl_api_domain %>update<span class="format format-json">.json</span><span class="format format-xml">.xml</span></code> .
|
||||
To update a Channel feed, send an HTTP GET or POST to<br>
|
||||
<code><%= @ssl_api_domain %>update<span class="format format-json">.json</span><span class="format format-xml">.xml</span></code> .
|
||||
|
||||
<br><br>
|
||||
Valid parameters:
|
||||
|
Loading…
Reference in New Issue
Block a user