class Client

Client Class (クライント クラス)

@!attribute [r] id

@return [String] client id (クライアントID)

@!attribute [r] application_id

@return [String] application id (アプリID)

@!attribute [r] code

@return [String] authentication key (認証キー)

@!attribute [r] token

@return [String] device token (デバイス・トークン)

@!attribute [r] os

@return [String] os name (OS名)

@!attribute [r] environment

@return [String] environment (環境設定)

@!attribute [r] status

@return [String] status (状態)

@!attribute [r] created

@return [String] created datetime (作成日時)

Attributes

application_id[R]
code[R]
created[R]
environment[R]
id[R]
os[R]
status[R]
token[R]

Public Class Methods

new(token, os=nil) click to toggle source

initializer (イニシャライザ) @param [String] token device token (デバイス・トークン) @param [String] os os name (OS名)

# File lib/growthpush/client.rb, line 37
def initialize(token, os=nil)
  @token = token
  @os = os
end

Public Instance Methods

save(growth_push) click to toggle source

save client (クライアントを登録する) @param [GrowthPush] growth_push GrowthPush object (GrowthPushオブジェクト) @raise [GrowthPushException] exception (例外) @return [Client] client (クライアント)

# File lib/growthpush/client.rb, line 48
def save(growth_push)

  begin
    http_response = HttpClient.instance.post('clients',
                                                 {
                                                     'applicationId' => growth_push.application_id,
                                                     'secret' => growth_push.secret,
                                                     'token' => self.token,
                                                     'os' => self.os,
                                                     'environment' => growth_push.environment
                                                 }
    )
  rescue GrowthPushException => ex
    raise GrowthPushException.new('Failed to save client: ' << ex.message, ex.code)
  end

  self.attributes = http_response.body

  return self
end

Private Instance Methods

attributes=(attributes) click to toggle source

set attributes (属性をセットする) @param [Hash] attributes attributes (属性)

# File lib/growthpush/client.rb, line 73
def attributes=(attributes)
  @id = attributes['id']
  @application_id = attributes['applicationId']
  @code = attributes['code']
  @token = attributes['token']
  @os = attributes['os']
  @environment = attributes['environment']
  @status = attributes['status']
  @created = attributes['created']
end