Class: KynetxAmApi::DirectApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tokens_and_secrets = {}) ⇒ DirectApi

Create a new session to the KynetxApi Manager.

request_token request_secret

:request_token
:request_secret
:oauth_verifier
:access_token
:access_secret


22
23
24
# File 'lib/kynetx_am_api/direct_api.rb', line 22

def initialize(tokens_and_secrets = {})
  @oauth = KynetxAmApi::Oauth.new(tokens_and_secrets)
end

Instance Attribute Details

#oauthObject

Returns the value of attribute oauth.



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

def oauth
  @oauth
end

Instance Method Details

#get_app_details(application_id) ⇒ Object



106
107
108
# File 'lib/kynetx_am_api/direct_api.rb', line 106

def get_app_details(application_id)
  return get_response("app/#{application_id}/details", :json)
end

#get_app_info(application_id) ⇒ Object



102
103
104
# File 'lib/kynetx_am_api/direct_api.rb', line 102

def get_app_info(application_id)
  return get_response("app/#{application_id}/info", :json)
end

#get_app_source(application_id, version, format = :krl) ⇒ Object



97
98
99
100
# File 'lib/kynetx_am_api/direct_api.rb', line 97

def get_app_source(application_id, version, format = :krl)
  data =  get_response("app/#{application_id}/source/#{version}/#{format}", format)
  return data
end

#get_appcreateObject



49
50
51
# File 'lib/kynetx_am_api/direct_api.rb', line 49

def get_appcreate
  return get_response("appcreate", :json)
end

#get_applistObject



45
46
47
# File 'lib/kynetx_am_api/direct_api.rb', line 45

def get_applist
  return get_response("applist", :json)
end

#get_authorize_urlObject

Provides the url to direct user to if the application has not been authorized.



34
35
36
# File 'lib/kynetx_am_api/direct_api.rb', line 34

def get_authorize_url
  return get_request_token.authorize_url
end

#get_request_tokenObject



27
28
29
# File 'lib/kynetx_am_api/direct_api.rb', line 27

def get_request_token
  @oauth.get_request_token
end

#get_user_infoObject



150
151
152
153
154
155
156
157
158
159
# File 'lib/kynetx_am_api/direct_api.rb', line 150

def 
  user = @oauth.user
  if user.username.to_s.empty?
     = get_response("userinfo", :json)
    user.username = ["username"]
    user.userid = ["userid"]
    user.name = ["name"]
  end
  return user
end

#pingObject



146
147
148
# File 'lib/kynetx_am_api/direct_api.rb', line 146

def ping
  return get_response("ping")
end

#post_app_delete(application_id) ⇒ Object



53
54
55
# File 'lib/kynetx_am_api/direct_api.rb', line 53

def post_app_delete(application_id)
  return post_response("app/#{application_id}/delete", {})
end

#post_app_generate(application_id, type, opts = {}) ⇒ Object

type is one of ff = firefox, ie = internet explorer, cr = google chrome



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/kynetx_am_api/direct_api.rb', line 80

def post_app_generate(application_id, type, opts={})
        # 
        # default_options = {
        #   "name" => "",
        #   "author" => "",
        #   "description" => "",
        #   "guid" => "",
        #   "datasets" => "",
        #   "env" => "prod",
        #   "image_url" => "http://appresource.s3.amazonaws.com/apiappimages/missing_icard.jpg",
        #   "runtime" => ""
        # }
        # options = default_options.merge(opts)
  return post_response("app/#{application_id}/generate/#{type}", opts,:json)
end

#post_app_invitecancel(application_id, invite_id) ⇒ Object



65
66
67
# File 'lib/kynetx_am_api/direct_api.rb', line 65

def post_app_invitecancel(application_id, invite_id)
  return post_response("app/#{application_id}/invitecancel",{"inviteid" => invite_id})
end

#post_app_inviteuser(application_id, application_name, email, message) ⇒ Object



61
62
63
# File 'lib/kynetx_am_api/direct_api.rb', line 61

def post_app_inviteuser(application_id, application_name, email, message)
  return post_response("app/#{application_id}/inviteuser", {"email" => email, "message" => message, "appname" => application_name.to_s})
end

#post_app_ownershiptransfercancel(application_id, transfer_id) ⇒ Object



73
74
75
# File 'lib/kynetx_am_api/direct_api.rb', line 73

def post_app_ownershiptransfercancel(application_id,transfer_id)
  return post_response("app/#{application_id}/ownershiptransfercancel", {"ownershiptransferrequestid" => transfer_id})
end

#post_app_setproductversion(application_id, version) ⇒ Object



122
123
124
# File 'lib/kynetx_am_api/direct_api.rb', line 122

def post_app_setproductversion(application_id, version)
  return post_response("app/#{application_id}/setproductionversion", {"version" => version})
end

#post_app_setversionnote(application_id, version, note) ⇒ Object



126
127
128
# File 'lib/kynetx_am_api/direct_api.rb', line 126

def post_app_setversionnote(application_id, version, note)
  return post_response("app/#{application_id}/setversionnote", {"version" => version, "note" => note}, :json)
end

#post_app_source(application_id, source, type = "krl") ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/kynetx_am_api/direct_api.rb', line 111

def post_app_source(application_id, source, type = "krl")
  data = ""
  if type == "krl"
    data = {:krl => source.to_s}
  else
    data = {:json => source.to_json}
  end
  return post_response("app/#{application_id}/source", data)
end

#post_app_transferownershiprequest(application_id, application_name, user_id, message) ⇒ Object



69
70
71
# File 'lib/kynetx_am_api/direct_api.rb', line 69

def post_app_transferownershiprequest(application_id,application_name,user_id,message)
  return post_response("app/#{application_id}/ownershiptransferrequest", {"userid" => user_id, "message" => message, "appname" => application_name})
end

#post_app_updateappimage(application_id, filename, content_type, image_data) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/kynetx_am_api/direct_api.rb', line 130

def post_app_updateappimage(application_id, filename, content_type, image_data)
  # TODO: Make this go through the APIß
  response = ""      
  url = URI.parse('https://accounts.kynetx.com/api/0.1/updateAppInfo')      
  StringIO.open(image_data) do |i|
    req = Net::HTTP::Post::Multipart.new url.path,
      "image" => UploadIO.new(i, content_type, filename),
      "appid" => application_id
    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
    response = http.start { |h| h.request(req) }        
  end
  
  return response
end

#post_remove_user(application_id, user_id) ⇒ Object



57
58
59
# File 'lib/kynetx_am_api/direct_api.rb', line 57

def post_remove_user(application_id, user_id)
  return post_response("app/#{application_id}/removeuser", {"userid" => user_id})
end