Class: Admincredible::Resources::Extension

Inherits:
Admincredible::Resource show all
Defined in:
lib/admincredible/resources/Extension.rb

Instance Attribute Summary

Attributes inherited from Admincredible::Resource

#client

Instance Method Summary collapse

Methods inherited from Admincredible::Resource

#config, #connection, #initialize

Constructor Details

This class inherits a constructor from Admincredible::Resource

Instance Method Details

#allObject Also known as: index



4
5
6
# File 'lib/admincredible/resources/Extension.rb', line 4

def all
  client.jget('extensions', 'index')['data']['extensions']
end

#update(extension_ids = [], repeat_until_response = true) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/admincredible/resources/Extension.rb', line 9

def update(extension_ids=[], repeat_until_response=true)
  unless config.oauth?
    client.rebuild_connection
    connection.builder.request :retry, 18 
  end
  
  response = nil
  begin
    response = client.jget('extensions', 'update', :extension_ids => extension_ids)
  rescue Faraday::Error::TimeoutError => e
    if repeat_until_response && config.oauth?
      seconds_left = config.step_after_seconds

      seconds_left.times do |i|
        sleep 1
      end

      return update(extension_ids)
    else
      response = false
    end
  end
  
  client.rebuild_connection unless config.oauth?
  response
end