Class: Pechkin::Member

Inherits:
Model
  • Object
show all
Defined in:
lib/pechkinrb/member.rb

Constant Summary collapse

FIELDS =
[
  :id,
  :list_id,
  :email,
  :state,
  :merge_1,
  :merge_2,
  :merge_3,
  :merge_4,
  :merge_5,
  :optin_time,
  :unsub_time,
  :lastedit_time
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, doc) ⇒ Member

Initialize new member instance

Parameters:

  • connection (Pachkin::Connection)

    Active connection

  • doc (Hash)

    API object data


28
29
30
31
32
33
# File 'lib/pechkinrb/member.rb', line 28

def initialize(connection, doc)
  super(connection, doc)
  FIELDS.each do |field|
    instance_variable_set :"@#{field}", doc[field.to_s]
  end
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw


3
4
5
# File 'lib/pechkinrb/member.rb', line 3

def raw
  @raw
end

Instance Method Details

#delete_memberObject

Invokes 'lists.delete_member' API method


37
38
39
# File 'lib/pechkinrb/member.rb', line 37

def delete_member
  connection.call_method('lists.delete_member', id_params)
end

#listObject

Invokes 'lists.get_lists' API method to retrieve member list

Parameters:

  • params (Pechkin::List)

    List instance, accosiated with member


51
52
53
# File 'lib/pechkinrb/member.rb', line 51

def list
  connection.get_list(list_id)
end

#unsubscribe_member(params) ⇒ Fixnum

Invokes 'lists.unsubscribe_member' API method

Parameters:

  • params (Hash)

    Params to be passed

Returns:

  • (Fixnum)

    Count of unsubscribed members


59
60
61
# File 'lib/pechkinrb/member.rb', line 59

def unsubscribe_member(params)
  connection.call_method('lists.unsubscribe_member', params.merge(id_params))['unsubscribed']
end

#update_member(params) ⇒ Object

Invokes 'lists.update_member' API method

Parameters:

  • params (Hash)

    Params to be passed


44
45
46
# File 'lib/pechkinrb/member.rb', line 44

def update_member(params)
  connection.call_method('lists.update_member', params.merge(id_params))
end