Class: Mass::OutreachType

Inherits:
BlackStack::Base
  • Object
show all
Defined in:
lib/base-line/outreach_type.rb

Overview

Outreach module. List of methods you have to overload if you develop a profile type that supports outreach operations.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.object_nameObject



6
7
8
# File 'lib/base-line/outreach_type.rb', line 6

def self.object_name
    'outreach_type'
end

Instance Method Details

#normalized_outreach_url(url:) ⇒ Object

Return the same URL in a normalized form:

  • remove all GET parameters.

  • remove all trailing slashes.

If the profile ‘access` is not `:rpa`, raise an exception. If the `url` is not valid, raise an exception. Return the normalized URL.

Overload this method in the child class.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/base-line/outreach_type.rb', line 34

def normalized_outreach_url(url:)
    # If the profile `access` is not `:rpa`, raise an exception.
    raise "The method `normalized_outreach_url` is not allowed for #{self.access.to_s} access." if self.access != :rpa
    # If the `url` is not valid, raise an exception.
    raise "The URL is not valid." if !self.valid_outreach_url?(url: url)
    # Return the same URL in a normalized form:
    # - remove all GET parameters.
    # - remove all trailing slashes.
    url = url.gsub(/\?.*$/, '').strip
    url = ret.gsub(/\/+$/, '')
    # Return the normalized URL.
    url
end

#valid_outreach_mta?(mta:) ⇒ Boolean

If the profile ‘access` is not `:mta`, raise an exception. Parameter `params` must be a hash. Return `true` if the `params` are valid. Return `false` if the `params` are not valid.

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
74
# File 'lib/base-line/outreach_type.rb', line 66

def valid_outreach_mta?(mta:)
    # If the profile `access` is not `:api`, raise an exception.
    raise "The method `valid_outreach_mta?` is not allowed for #{self.access.to_s} access." if self.access != :mta
    # Parameter `params` must be a hash.
    raise "The parameter `mta` must be a hash." if !mta.is_a?(Hash)
    # Return `true` if the `params` are valid.
    # Return `false` if the `params` are not valid. 
    true
end

#valid_outreach_params?(params:) ⇒ Boolean

If the profile ‘access` is not `:api`, raise an exception. Parameter `params` must be a hash. Return `true` if the `params` are valid. Return `false` if the `params` are not valid.

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
60
# File 'lib/base-line/outreach_type.rb', line 52

def valid_outreach_params?(params:)
    # If the profile `access` is not `:api`, raise an exception.
    raise "The method `valid_outreach_params?` is not allowed for #{self.access.to_s} access." if self.access != :api
    # Parameter `params` must be a hash.
    raise "The parameter `params` must be a hash." if !params.is_a?(Hash)
    # Return `true` if the `params` are valid.
    # Return `false` if the `params` are not valid.
    true
end

#valid_outreach_url?(url:) ⇒ Boolean

If the profile ‘access` is not `:rpa`, raise an exception. Return `true` if the `url` is valid. Return `false` if the `url` is not valid.

Overload this method in the child class.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
# File 'lib/base-line/outreach_type.rb', line 16

def valid_outreach_url?(url:)
    # If the profile `access` is not `:rpa`, raise an exception.
    raise "The method `valid_outreach_url?` is not allowed for #{self.access.to_s} access." if self.access != :rpa
    # Return `true` if the `url` is valid.
    # Return `false` if the `url` is not valid. 
    true
end