kynetx_am_api 0.1.26 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,8 @@ module KynetxAmApi
6
6
  attr_reader :application_id
7
7
  attr_reader :api
8
8
 
9
- def initialize(user, application_id, version=nil)
9
+ # constructor takes a KynextAmApi::User object and an application id (ruleset_id)
10
+ def initialize(user, application_id)
10
11
  @api = user.api
11
12
  @application_id = application_id
12
13
  @user = user
@@ -154,16 +155,75 @@ module KynetxAmApi
154
155
  return @api.post_app_generate(@application_id, "info_card", options)
155
156
  end
156
157
 
157
- def extension(type, name, author, description)
158
+ def extension(type, name, author, description, format="json")
158
159
  options = {
159
160
  "extname" => name,
160
161
  "extdesc" => description,
161
- "extauthor" => author.to_s.empty? ? @user.name : author
162
+ "extauthor" => author.to_s.empty? ? @user.name : author,
163
+ "format" => format
162
164
  }
163
165
  options["appguid"] = @guid if type.to_s == "ie"
164
166
  return @api.post_app_generate(@application_id, type.to_s, options)
165
167
 
166
168
  end
169
+
170
+ # Returns an endpoint
171
+ #
172
+ # type is a String or Symbol of one of the following:
173
+ # :chrome
174
+ # :ie
175
+ # :firefox
176
+ # :info_card
177
+ # :bookmarklet
178
+ # :sitetags
179
+ #
180
+ # opts is a Hash of options that has the following keys:
181
+ # (see Kynetx App Management API documentation on "generate" for more information)
182
+ #
183
+ # :extname (endpoint name - defaults to app name.)
184
+ # :extauthor (endpoint author - defaults to user generating the endpoint.)
185
+ # :extdesc (endpoint description - defaults to empty.)
186
+ # :force_build ('Y' or 'N' force a regeneration of the endpoint - defaults to 'N'.)
187
+ # :contents ( 'compiled' or 'src' specifies whether you want the endpoint or the source code of the endpoint - defaults to 'compiled'.)
188
+ # :format ('url' or 'json' specifies how the endpoint is returned - default is 'json' which returns a Base64 encoded data string.)
189
+ # :datasets (used for infocards - defaults to empty)
190
+ # :env ('dev' or 'prod' specifies whether to run the development or production version of the app - defaults to 'prod'.)
191
+ # :image_url (a fully qualified url to the image that will be used for the infocard. It must be a 240x160 jpg - defaults to a cropped version of the app image in appBuilder.)
192
+ # :runtime (specific runtime to be used. This only works with bookmarklets - defaults to init.kobj.net/js/shared/kobj-static.js )
193
+ #
194
+ # Returns a hash formatted as follows:
195
+ # {:data => "endpoint as specified in the :format option",
196
+ # :file_name => "filename.*",
197
+ # :content_type => 'content type',
198
+ # :errors => []
199
+ # }
200
+ def endpoint(type, opts={})
201
+ options = {
202
+ :extname => @name,
203
+ :extdesc => "",
204
+ :extauthor => @user.name,
205
+ :force_build => 'N',
206
+ :contents => "compiled",
207
+ :format => 'json',
208
+ :env => 'prod'
209
+ }
210
+
211
+ # Set type specific options
212
+ case type.to_s
213
+ when 'bookmarklet'
214
+ options[:runtime] = "init.kobj.net/js/shared/kobj-static.js"
215
+ when 'info_card'
216
+ options[:image_url] = image_url('icard')
217
+ options[:datasets] = ""
218
+ when 'ie'
219
+ options[:appguid] = @guid
220
+ end
221
+
222
+ options.merge!(opts)
223
+ puts "ENDPOINT PARAMS: (#{type}): #{options.inspect}" if $DEBUG
224
+ return @api.post_app_generate(@application_id, type.to_s, options)
225
+
226
+ end
167
227
 
168
228
  private
169
229
 
@@ -217,6 +277,7 @@ module KynetxAmApi
217
277
  reload
218
278
  return true
219
279
  else
280
+ puts "ERROR SAVING KRL: #{response.inspect}" if $DEBUG
220
281
  raise response["error"]
221
282
  end
222
283
  end
@@ -62,7 +62,7 @@ module KynetxAmApi
62
62
  # - :offset => Start in list (not implemented)
63
63
  # - :size => Number of application to list (not implemented)
64
64
  #
65
- # Returns a has with two keys
65
+ # Returns a Hash with two keys
66
66
  # - "apps" => Array Off Hashes with :appid , :role, :name, :created
67
67
  # - "valid" => true
68
68
  #
@@ -73,16 +73,14 @@ module KynetxAmApi
73
73
 
74
74
  #
75
75
  # - :application_id => application_id
76
- # - :version => Version of application to obtain
77
76
  #
78
77
  def find_application(options = {})
79
- options[:version] ||= "development"
80
78
  raise "Expecting :application_id" unless options[:application_id]
81
79
 
82
80
  if @current_application && @current_application.application_id != options[:application_id]
83
- @current_application = KynetxAmApi::Application.new(self, options[:application_id], options[:version])
81
+ @current_application = KynetxAmApi::Application.new(self, options[:application_id])
84
82
  else
85
- @current_application ||= KynetxAmApi::Application.new(self, options[:application_id], options[:version])
83
+ @current_application ||= KynetxAmApi::Application.new(self, options[:application_id])
86
84
  end
87
85
  return @current_application
88
86
  end
@@ -122,4 +120,4 @@ module KynetxAmApi
122
120
 
123
121
 
124
122
  end
125
- end
123
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 26
9
- version: 0.1.26
8
+ - 27
9
+ version: 0.1.27
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Farmer, Cid Dennis
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-21 00:00:00 -06:00
17
+ date: 2010-06-19 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency