Sha256: 4d3fb18781a4fde6aaffe058df402bf865f0088d9779442c1c23f3d227b305d2

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Telegraph
  module Account
    def self.create(params)
      return nil unless CreateAccountSchema.(params).success?
      response = Telegraph::Core.request('createAccount', params)
      Types::Account.new(Hashie.symbolize_keys response['result'])
    end

    def self.edit(params)
      return nil unless EditAccountInfoSchema.(params).success?
      response = Telegraph::Core.request('editAccountInfo', params)
      Types::Account.new(Hashie.symbolize_keys response['result'])
    end

    def self.info(params)
      return nil unless GetAccountInfoSchema.(params).success?
      params[:fields] = params[:fields].to_s
      response = Telegraph::Core.request('getAccountInfo', params)
      Types::Account.new(Hashie.symbolize_keys response['result'])
    end

    def self.revoke_token(params)
      return nil unless RevokeAccessTokenSchema.(params).success?
      response = Telegraph::Core.request('revokeAccessToken', params)
      return response['error'] if response['error']
      Types::Account.new(Hashie.symbolize_keys response['result'])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telegraph_api-0.1.1 lib/telegraph/api/account.rb
telegraph_api-0.1.0 lib/telegraph/api/account.rb