Top Level Namespace

Includes:
SparkApi::Models

Defined Under Namespace

Modules: SparkApi

Instance Method Summary collapse

Instance Method Details

#cObject



45
46
47
# File 'lib/spark_api/cli/setup.rb', line 45

def c
  SparkApi.client
end

#delete(path, options = {}) ⇒ Object



63
64
65
# File 'lib/spark_api/cli/setup.rb', line 63

def delete(path, options={})
  c.delete(path, options)
end

#get(path, options = {}) ⇒ Object

Straight up HTTP functions y’all!!!



51
52
53
# File 'lib/spark_api/cli/setup.rb', line 51

def get(path, options={})
  c.get(path, options)
end

#load_oauth2_session(session_alias = "default") ⇒ Object



74
75
76
77
78
# File 'lib/spark_api/cli/setup.rb', line 74

def load_oauth2_session session_alias = "default"
  c.oauth2_provider.session = ""
rescue => e
  puts "Unable to find a saved oauth2 session: #{e.message}"
end

#persist_sessions!(my_alias = nil) ⇒ Object

Enables saving and loading serialized oauth2 sessions for the system user.



27
28
29
30
31
# File 'lib/spark_api/cli/oauth2.rb', line 27

def persist_sessions! my_alias = nil
  warn "Warning: persistent session mode saves access tokens in clear text on the filesystem."
  SparkApi.client.oauth2_provider.session_alias = my_alias unless my_alias.nil?
  SparkApi.client.oauth2_provider.persistent_sessions = true
end

#post(path, body = nil, options = {}) ⇒ Object



55
56
57
# File 'lib/spark_api/cli/setup.rb', line 55

def post(path, body = nil, options={})
  c.post(path, body, options)
end

#put(path, body = nil, options = {}) ⇒ Object



59
60
61
# File 'lib/spark_api/cli/setup.rb', line 59

def put(path, body = nil, options={})
  c.put(path, body, options)
end

#save_oauth2_session!(session_alias = "default") ⇒ Object

Handy session persistence



68
69
70
71
72
# File 'lib/spark_api/cli/setup.rb', line 68

def save_oauth2_session! session_alias = "default"
  
rescue => e
  puts "Unable to save the oauth2 session: #{e.message}"
end