Class: Cyby::UserApi

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/cyby/user_api.rb

Constant Summary collapse

AUTH =
'X-Cybozu-Authorization'

Instance Method Summary collapse

Constructor Details

#initializeUserApi

Returns a new instance of UserApi.



7
8
9
10
11
# File 'lib/cyby/user_api.rb', line 7

def initialize
  config = YAML.load_file("#{ENV['HOME']}/.cyby.yml")
  self.class.base_uri "https://#{config['subdomain']}.cybozu.com/v1/csv"
  @auth = Base64.encode64("#{config['login']}:#{config['password']}").chomp
end

Instance Method Details

#get(path) ⇒ Object



13
14
15
16
# File 'lib/cyby/user_api.rb', line 13

def get(path)
  options = { headers: { AUTH => @auth } }
  self.class.get(path, options)
end

#groupObject



34
35
36
# File 'lib/cyby/user_api.rb', line 34

def group
  get("/group.csv")
end

#organizationObject



22
23
24
# File 'lib/cyby/user_api.rb', line 22

def organization
  get("/organization.csv")
end

#titleObject



26
27
28
# File 'lib/cyby/user_api.rb', line 26

def title
  get("/title.csv")
end

#userObject



18
19
20
# File 'lib/cyby/user_api.rb', line 18

def user
  get("/user.csv")
end

#user_groupsObject



38
39
40
# File 'lib/cyby/user_api.rb', line 38

def user_groups
  get("/userGroups.csv")
end

#user_organizationsObject



30
31
32
# File 'lib/cyby/user_api.rb', line 30

def user_organizations
  get("/userOrganizations.csv")
end

#user_servicesObject



42
43
44
# File 'lib/cyby/user_api.rb', line 42

def user_services
  get("/userServices.csv")
end