Class: BoxnetApi::Client

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

Constant Summary collapse

@@API_KEY =
nil
@@URL =
"https://www.box.net/api/1.0/rest"

Class Method Summary collapse

Class Method Details

.API_KEY=(value) ⇒ Object



10
11
12
# File 'lib/boxnet.rb', line 10

def self.API_KEY=(value)
  @@API_KEY = value
end

.get_account_tree(auth_token, folder_id, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/boxnet.rb', line 27

def self.(auth_token, folder_id, options={})
  params = []
  params << "onelevel" if options[:onelevel]
  params << "nozip"

  if params.empty?
    raw_result = get(@@URL + "?api_key=#{@@API_KEY}&action=get_account_tree&auth_token=#{auth_token}&folder_id=#{folder_id}")
  else
    params_string = params.join(",")
    raw_result = get(@@URL + "?api_key=#{@@API_KEY}&action=get_account_tree&auth_token=#{auth_token}&folder_id=#{folder_id}&params[]=#{params_string}")
  end

  Result.new(raw_result)
end

.get_auth_token(ticket) ⇒ Object



23
24
25
# File 'lib/boxnet.rb', line 23

def self.get_auth_token(ticket)
  get(@@URL + "?api_key=#{@@API_KEY}&ticket=#{ticket}&action=get_auth_token")
end

.get_auth_url_for_ticket(ticket) ⇒ Object



19
20
21
# File 'lib/boxnet.rb', line 19

def self.get_auth_url_for_ticket(ticket)
  "https://www.box.net/api/1.0/auth/#{ticket}"
end

.get_ticketObject



14
15
16
17
# File 'lib/boxnet.rb', line 14

def self.get_ticket
  data = get(@@URL + "?api_key=#{@@API_KEY}&action=get_ticket")
  Ticket.new(data)
end