class M2X::Client::Key
Wrapper for {m2x.att.com/developer/documentation/v2/keys M2X
Keys} API
Constants
- PATH
Public Class Methods
Method for {m2x.att.com/developer/documentation/v2/keys#Create-Key Create Key} endpoint. Note that, according to the parameters sent, you can create a Master API Key
or a Device/Stream API Key
.
@param {Client} client Client API @param params Query parameters passed as keyword arguments. View M2X
API Docs for listing of available parameters. @return {Key} The newly created Key
.
# File lib/m2x/key.rb, line 31 def create!(client, params={}) res = client.post(PATH, nil, params, "Content-Type" => "application/json") new(client, res.json) if res.success? end
Method for {m2x.att.com/developer/documentation/v2/keys#List-Keys List Keys} endpoint.
@param {Client} client Client API @param params Query parameters passed as keyword arguments. View M2X
API Docs for listing of available parameters. @return (Array) List of {Key} objects.
# File lib/m2x/key.rb, line 16 def list(client, params={}) res = client.get(PATH, params) res.json["keys"].map{ |atts| new(client, atts) } if res.success? end
Public Instance Methods
# File lib/m2x/key.rb, line 38 def path @path ||= "#{ PATH }/#{ URI.encode(@attributes.fetch("key")) }" end
Method for {m2x.att.com/developer/documentation/v2/keys#Regenerate-Key Regenerate Key} endpoint. Note that if you regenerate the key that you're using for authentication then you would need to change your scripts to start using the new key token for all subsequent requests.
@return {Key} The regenerated key.
# File lib/m2x/key.rb, line 50 def regenerate res = @client.post("#{path}/regenerate", nil, {}) if res.success? @path = nil @attributes = res.json end end