Class: Snov::GetUserLists

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/snov/get_user_lists.rb

Defined Under Namespace

Classes: UserList

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: Snov.client) ⇒ GetUserLists

Returns a new instance of GetUserLists.



9
10
11
# File 'lib/snov/get_user_lists.rb', line 9

def initialize(client: Snov.client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/snov/get_user_lists.rb', line 7

def client
  @client
end

Instance Method Details

#allObject



17
18
19
# File 'lib/snov/get_user_lists.rb', line 17

def all
  @all ||= raw_result.map { |result| UserList.new(result) }
end

#each(&block) ⇒ Object



13
14
15
# File 'lib/snov/get_user_lists.rb', line 13

def each(&block)
  all.each(&block)
end

#raw_resultObject



21
22
23
24
25
# File 'lib/snov/get_user_lists.rb', line 21

def raw_result
  @raw_result ||= client.get("/v1/get-user-lists").map do |val|
    val.deep_transform_keys! { |key| key.underscore }
  end
end