Class: Plivo::Resources::BrandInterface

Inherits:
Base::ResourceInterface show all
Defined in:
lib/plivo/resources/brand.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Method Summary collapse

Methods included from Utils

GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?

Constructor Details

#initialize(client, resource_list_json = nil) ⇒ BrandInterface

Returns a new instance of BrandInterface.



20
21
22
23
24
25
# File 'lib/plivo/resources/brand.rb', line 20

def initialize(client, resource_list_json = nil)
  @_name = '10dlc/Brand'
  @_resource_type = Brand
  @_identifier_string = 'brand_id'
  super
end

Instance Method Details

#create(options = nil) ⇒ Object

Create a new brand



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/plivo/resources/brand.rb', line 66

def create(options=nil)
  valid_param?(:options, options, Hash, true)
  if not options[:brand_alias]
    raise_invalid_request("brand_alias must be provided")
  end
  if not options[:brand_type]
    raise_invalid_request("brand_type must be provided")
  end
  if not options[:profile_uuid]
    raise_invalid_request("profile_uuid must be provided")
  end
  perform_create(options)
end

#delete(brand_id) ⇒ Object

Delete Brand

Parameters:

  • brand_id (String)


92
93
94
95
# File 'lib/plivo/resources/brand.rb', line 92

def delete(brand_id)
  valid_param?(:brand_id, brand_id, [String, Symbol], true)
  perform_delete(brand_id)
end

#get(brand_id) ⇒ Brand

Get an Brand

Parameters:

  • brand_id (String)

Returns:



31
32
33
34
# File 'lib/plivo/resources/brand.rb', line 31

def get(brand_id)
  valid_param?(:brand_id, brand_id, [String, Symbol], true)
  perform_get(brand_id)
end

#get_usecases(brand_id) ⇒ Object

Get BrandUsecase

Parameters:

  • brand_id (String)


83
84
85
86
87
# File 'lib/plivo/resources/brand.rb', line 83

def get_usecases(brand_id)
  valid_param?(:brand_id, brand_id, [String, Symbol], true)
  identifier = brand_id + '/usecases'
  perform_action_with_identifier(identifier, 'GET', nil)
end

#list(options = nil) ⇒ Hash

List all Brand

Parameters:

  • options (Hash) (defaults to: nil)

Options Hash (options):

  • :type (String)
  • :status (Status)
  • :limit (Status)
  • :offset (Status)

Returns:

  • (Hash)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/plivo/resources/brand.rb', line 44

def list(options=nil)
  return perform_list_without_object if options.nil?
  
  params = {}
  %i[status type limit offset].each do |param|
    if options.key?(param) && valid_param?(param, options[param],
                                             [String, Integer], true)
      params[param] = options[param]
    end
  end
  if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
    raise_invalid_request('The maximum number of results that can be '\
    "fetched is 20. limit can't be more than 20 or less than 1")
  end
  if options.key?(:offset) && options[:offset] < 0
    raise_invalid_request("Offset can't be negative")
  end
  perform_list_without_object(params)
end