Class: EsaPiyo::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/esa_piyo.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token: nil, current_team: nil) ⇒ Client

Returns a new instance of Client.



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

def initialize(access_token: nil, current_team: nil)
  @client = Esa::Client.new(access_token: access_token, current_team: current_team)
end

Instance Method Details

#email(screen_name: nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/esa_piyo.rb', line 37

def email(screen_name: nil)

  params = {
    page: 1,
    per_page: 100,
  }

  begin
    res = @client.members(params)
    body = res.body
    members = body["members"]

    members.each do |member| 
      if member["screen_name"] == screen_name then
        return member["email"]
      end
    end

    params[:page] = body["next_page"]
  end until params[:page].nil?

  return 
end

#screen_name(email: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/esa_piyo.rb', line 13

def screen_name(email: nil)

  params = {
    page: 1,
    per_page: 100,
  }

  begin
    res = @client.members(params)
    body = res.body
    members = body["members"]

    members.each do |member| 
      if member["email"] == email then
        return member["screen_name"]
      end
    end

    params[:page] = body["next_page"]
  end until params[:page].nil?

  return 
end