Class: SerwerSMS::Resources::Templates

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Templates

Returns a new instance of Templates.



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

def initialize(client)
  @client = client
end

Instance Method Details

#add(name, text) ⇒ Hash

Add new template

Parameters:

  • name (String)
  • text (String)

Returns:

  • (Hash)

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



29
30
31
# File 'lib/serwersms/resources/templates.rb', line 29

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

#delete(id) ⇒ Hash

Delete a template

Parameters:

  • id (Integer)

Returns:

  • (Hash)

    @option return [Boolean] :success



50
51
52
# File 'lib/serwersms/resources/templates.rb', line 50

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

#edit(id, name, text) ⇒ Hash

Edit a template

Parameters:

  • id (Integer)
  • name (String)
  • text (String)

Returns:

  • (Hash)

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



41
42
43
# File 'lib/serwersms/resources/templates.rb', line 41

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

#index(params = {}) ⇒ Hash

List of templates

Parameters:

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

    @option params [String] :sort Values: name @option params [String] :order Values: asc|desc

Returns:

  • (Hash)

    @option return [Array] :items @option item [Integer] :id @option item [String] :name @option item [String] :text



18
19
20
# File 'lib/serwersms/resources/templates.rb', line 18

def index(params = {})
  @client.call('templates/index', params)
end