Class: HashBlue::Account

Inherits:
Client
  • Object
show all
Defined in:
lib/hash_blue/account.rb

Overview

This class models the Account entity, providing an easy way to CRUD operations using ActiveRecord as design model

Examples of use:

# Initialize client with a valid access token HashBlue::Client.user = <valid_access_token>

# Retrieve all messages messages = HashBlue::Message.find(:all)

# Retrieve a specific message message = HashBlue::Message.find(<valid_message_id>)

# Retrieve a contact messages messages = HashBlue::Message.find(=> <valid_contact_id>)

# Retrieve favourite messages messages = HashBlue::Message.favourites

# Mark a message as favourite message = HashBlue::Message.find(<valid_message_id>) message.favourite!

# Unmark a message as favourite message = HashBlue::Message.find(<valid_message_id>) message.unfavourite!

# Create a message HashBlue::Message.create!(<phone_number>, <content>)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

client, delete, get, post, put

Instance Attribute Details

#emailObject

Returns the value of attribute email.



50
51
52
# File 'lib/hash_blue/account.rb', line 50

def email
  @email
end

#msisdnObject

Returns the value of attribute msisdn.



48
49
50
# File 'lib/hash_blue/account.rb', line 48

def msisdn
  @msisdn
end

#phone_numberObject

Returns the value of attribute phone_number.



49
50
51
# File 'lib/hash_blue/account.rb', line 49

def phone_number
  @phone_number
end

Class Method Details

.findObject

Get user account



60
61
62
# File 'lib/hash_blue/account.rb', line 60

def find
  parse_response(get "/account")
end

Instance Method Details

#to_sObject



52
53
54
# File 'lib/hash_blue/account.rb', line 52

def to_s
  "#{self.class.name} => {:phone_number => #{phone_number}, :msisdn => #{msisdn}, :email => #{email}}"
end