Class: SerwerSMS::Resources::Groups

Inherits:
Object
  • Object
show all
Defined in:
lib/serwersms/resources/groups.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Groups

Returns a new instance of Groups.



4
5
6
# File 'lib/serwersms/resources/groups.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#add(name) ⇒ Hash

Add new group

Parameters:

  • name (String)

Returns:

  • (Hash)

    @option return [Boolean] :success @option return [Integer] :id



14
15
16
# File 'lib/serwersms/resources/groups.rb', line 14

def add(name)
  @client.call('groups/add', 'name' => name)
end

#check(phone) ⇒ Hash

View groups containing phone number

Parameters:

  • phone (String)

Returns:

  • (Hash)

    @option return [Array] :items @option item [Integer] :id @option item [Integer] :group_id @option item [String] :group_name



78
79
80
# File 'lib/serwersms/resources/groups.rb', line 78

def check(phone)
  @client.call('groups/check', 'phone' => phone)
end

#delete(id) ⇒ Hash

Delete a group

Parameters:

  • id (Integer)

Returns:

  • (Hash)

    @option return [Boolean] :success



66
67
68
# File 'lib/serwersms/resources/groups.rb', line 66

def delete(id)
  @client.call('groups/delete', 'id' => id)
end

#edit(id, name) ⇒ Hash

Edit a group

Parameters:

  • id (Integer)
  • name (String)

Returns:

  • (Hash)

    @option return [Boolean] :success @option return [Integer] :id



57
58
59
# File 'lib/serwersms/resources/groups.rb', line 57

def edit(id, name)
  @client.call('groups/edit', 'id' => id, 'name' => name)
end

#index(search = nil, params = {}) ⇒ Hash

List of groups

Parameters:

  • search (String) (defaults to: nil)

    Group name filter

  • params (Hash) (defaults to: {})

    @option params [Integer] :page The number of the displayed page @option params [Integer] :limit Limit items displayed on single page @option params [String] :sort Values: name @option params [String] :order Values: asc|desc

Returns:

  • (Hash)

    @option return [Hash] :paging @option paging [Integer] :page The number of current page @option paging [Integer] :count The number of all pages @option return [Array] :items @option item [Integer] :id @option item [String] :name @option item [Integer] :count Number of contacts in the group



34
35
36
37
# File 'lib/serwersms/resources/groups.rb', line 34

def index(search = nil, params = {})
  params['search'] = search
  @client.call('groups/index', params)
end

#view(id) ⇒ Hash

View single group

Parameters:

  • id (Integer)

Returns:

  • (Hash)

    @option return [Integer] :id @option return [String] :name @option return [Integer] :count Number of contacts in the group



46
47
48
# File 'lib/serwersms/resources/groups.rb', line 46

def view(id)
  @client.call('groups/view', 'id' => id)
end