params:
   email, String
   items, Array of Hashes
   incomplete, Integer
   message_id, String
   options, Hash
 returns:
   hash, response from server

 Record that a user has made a purchase, or has added items to their purchase total.
345885
def purchase(email, items, incomplete = nil, message_id = nil, options = {})
      data = options
      data[:email] = email
      data[:items] = items

      if incomplete != nil
        data[:incomplete] = incomplete.to_i
      end

      if message_id != nil
        data[:message_id] = message_id
      end
      api_post(:purchase, data)
    end
1068379
def request_params(additional_params)
      client_params.merge(additional_params).select { |_, v| !v.nil? }
    end
1144072
def buyer
      response = JSON.parse(@client.get("items/#{send(:id)}/buyers").body)
      Promisepay::User.new(@client, response['users'])
    end
365295
def get_emails(self, limit=100, offset=0, conditions={}):
        
        url = self.EMAILS_URL + "?limit=%s&offset=%s" % (limit, offset)

        for key, value in conditions.items():
            if key is 'ids':
                value = ",".join(value)

            url += '&%s=%s' % (key, value)

        connection = Connection(self.token)
        connection.set_url(self.production, url)

        return connection.get_request()
210336
def response_shim(body, status)
      items = JSON.parse(body, symbolize_names: true)

      { response: { items:      items,
                    offset:     0,
                    limit:      items.size,
                    totalItems: items.size,
                    modeItems:  false },
        status:   { result:     status == 200 ? 'OK' : 'ERROR',
                    message:    extract_api_message(status, items),
                    code:       status } }.to_json
    end
777479
def subscription_params
        optional_targets = (params[:subscription][:optional_targets] || {}).keys.select { |key| key.to_s.start_with?("subscribing_to_") }
        optional_targets.each do |optional_target_key|
          params[:subscription][:optional_targets][optional_target_key] = params[:subscription][:optional_targets][optional_target_key].to_boolean
        end
        params.require(:subscription).permit(:key, :subscribing, :subscribing_to_email, optional_targets: optional_targets)
      end
1290626
def get_email_templates(self, params=None):
        
        if not params:
            params = {}
        return self._iterate_through_pages(self.get_email_templates_per_page, resource=EMAIL_TEMPLATES,
                                           **{'params': params})
52618
def build_checkout_params(self, **kwargs):
        
        params = kwargs or {}
        if self.sender:
            params['senderName'] = self.sender.get('name')
            params['senderAreaCode'] = self.sender.get('area_code')
            params['senderPhone'] = self.sender.get('phone')
            params['senderEmail'] = is_valid_email(self.sender.get('email'))
            params['senderCPF'] = is_valid_cpf(self.sender.get('cpf'))
            params['senderCNPJ'] = is_valid_cnpj(self.sender.get('cnpj'))
            params['senderBornDate'] = self.sender.get('born_date')
            params['senderHash'] = self.sender.get('hash')

        if self.config.USE_SHIPPING:
            if self.shipping:
                params['shippingType'] = self.shipping.get('type')
                params['shippingAddressStreet'] = self.shipping.get('street')
                params['shippingAddressNumber'] = self.shipping.get('number')
                params['shippingAddressComplement'] = self.shipping.get(
                    'complement')
                params['shippingAddressDistrict'] = self.shipping.get(
                    'district')
                params['shippingAddressPostalCode'] = self.shipping.get(
                    'postal_code')
                params['shippingAddressCity'] = self.shipping.get('city')
                params['shippingAddressState'] = self.shipping.get('state')
                params['shippingAddressCountry'] = self.shipping.get('country',
                                                                     'BRA')
                if self.shipping.get('cost'):
                    params['shippingCost'] = self.shipping.get('cost')
        else:
            params['shippingAddressRequired'] = 'false'

        if self.extra_amount:
            params['extraAmount'] = self.extra_amount

        params['reference'] = self.reference
        params['receiverEmail'] = self.data['email']

        if self.redirect_url:
            params['redirectURL'] = self.redirect_url

        if self.notification_url:
            params['notificationURL'] = self.notification_url

        if self.abandon_url:
            params['abandonURL'] = self.abandon_url

        for i, item in enumerate(self.items, 1):
            params['itemId%s' % i] = item.get('id')
            params['itemDescription%s' % i] = item.get('description')
            params['itemAmount%s' % i] = item.get('amount')
            params['itemQuantity%s' % i] = item.get('quantity')
            params['itemWeight%s' % i] = item.get('weight')
            params['itemShippingCost%s' % i] = item.get('shipping_cost')

        if self.payment:

            params['paymentMethod'] = self.payment.get('method')
            params['paymentMode'] = self.payment.get('mode')

        if self.credit_card:
            params['billingAddressCountry'] = 'BRA'

            credit_card_keys_map = [
                ('creditCardToken', 'credit_card_token'),
                ('installmentQuantity', 'installment_quantity'),
                ('installmentValue', 'installment_value'),
                ('noInterestInstallmentQuantity',
                 'no_interest_installment_quantity'),
                ('creditCardHolderName', 'card_holder_name'),
                ('creditCardHolderCPF', 'card_holder_cpf'),
                ('creditCardHolderBirthDate', 'card_holder_birth_date'),
                ('creditCardHolderAreaCode', 'card_holder_area_code'),
                ('creditCardHolderPhone', 'card_holder_phone'),
                ('billingAddressStreet', 'billing_address_street'),
                ('billingAddressNumber', 'billing_address_number'),
                ('billingAddressComplement', 'billing_address_complement'),
                ('billingAddressDistrict', 'billing_address_district'),
                ('billingAddressPostalCode', 'billing_address_postal_code'),
                ('billingAddressCity', 'billing_address_city'),
                ('billingAddressState', 'billing_address_state'),
            ]

            for key_to_set, key_to_get in credit_card_keys_map:
                params[key_to_set] = self.credit_card.get(key_to_get)

        if self.pre_approval:

            params['preApprovalCharge'] = self.pre_approval.get('charge')
            params['preApprovalName'] = self.pre_approval.get('name')
            params['preApprovalDetails'] = self.pre_approval.get('details')
            params['preApprovalAmountPerPayment'] = self.pre_approval.get(
                'amount_per_payment')
            params['preApprovalMaxAmountPerPayment'] = self.pre_approval.get(
                'max_amount_per_payment')
            params['preApprovalPeriod'] = self.pre_approval.get('period')
            params['preApprovalMaxPaymentsPerPeriod'] = self.pre_approval.get(
                'max_payments_per_period')
            params['preApprovalMaxAmountPerPeriod'] = self.pre_approval.get(
                'max_amount_per_period')
            params['preApprovalInitialDate'] = self.pre_approval.get(
                'initial_date')
            params['preApprovalFinalDate'] = self.pre_approval.get(
                'final_date')
            params['preApprovalMaxTotalAmount'] = self.pre_approval.get(
                'max_total_amount')

        self.data.update(params)
        self.clean_none_params()
1269490
def track_purchase(self, user, items, total, purchase_id= None, campaign_id=None, 
					   template_id=None, created_at=None,
					   data_fields=None):
		

		call="/api/commerce/trackPurchase"

		payload ={}
	
		if isinstance(user, dict):
			payload["user"]= user
		else:
			raise TypeError('user key is not in Dictionary format')

		if isinstance(items, list):
			payload["items"]= items
		else:
			raise TypeError('items are not in Array format')

		if isinstance(total, float):
			payload["total"]= total
		else:
			raise TypeError('total is not in correct format')

		if purchase_id is not None:
			payload["id"]= str(purchase_id) 

		if campaign_id is not None:
			payload["campaignId"]= campaign_id

		if template_id is not None:
			payload["templateId"]= template_id		

		if created_at is not None:
			payload["createdAt"]= created_at

		if data_fields is not None:
			payload["data_fields"]= data_fields

		return self.api_call(call=call, method="POST", json=payload)
1338498
def request_parameters
      Hash[(Tumblr::Client::POST_OPTIONS | [:id, :type]).map {|key|
        [key.to_s, send(key)] if respond_to?(key) && send(key)
      }.compact]
    end
1039150
def user_params
        if params[:user][:password].blank? && action_name == 'update'
          params[:user].delete(:password)
          params[:user].delete(:password_confirmation)
        end
        params.require(:user).permit(
          :username, :gruppen, :sn, :givenname, :displayname, 
          :telephone, :email, :password, :password_confirmation,
          :title, :position, :department, :company
         )
      end
899205
def admin_line_item_status_options
      arr = ['pending', 'ready to ship', 'shipped', 'backordered', 'canceled']
      options = []
      arr.each do |status|
        options << {
          :value => status,
          :text  => status
        }
      end
      render :json => options
    end
1363225
def read_get_item_response_messages(client, get_item_response_messages)
      get_item_response_messages = [get_item_response_messages] if !get_item_response_messages.is_a?(Array)
      items = get_item_response_messages.map do |girm|
        read_items(client, girm[:items])
      end.flatten
    end
263851
def user
      response = JSON.parse(@client.get("wallet_accounts/#{send(:id)}/users").body)
      response.key?('users') ? Promisepay::User.new(@client, response['users']) : nil
    end
244712
def request_payment(options = {})
      response = JSON.parse(@client.patch("items/#{send(:id)}/request_payment", options).body)
      @attributes = response['items']
      true
    end
393409
def check(self, item_id):
        
        response = self._request("/submission/sample/{sample_id}".format(sample_id=item_id), headers=self.headers)

        if response.status_code == 404:
            # unknown id
            return False

        try:
            finished = False
            for submission in response.json()['data']:
                finished = finished or submission['submission_finished']
            if finished:
                return True

        except (ValueError, KeyError) as e:
            raise sandboxapi.SandboxError(e)

        return False
1060822
def params_array(object)
      case object
      when Array then object
      when Hash then object.to_a
      when RequestProxy
        tmp = object.path.split('?')
        params = tmp[1] ? params_decode(tmp[1]) : []
        if object.post? && object.headers['Content-Type'].to_s.start_with?('application/x-www-form-urlencoded')
          params.concat params_decode(object.body)
        end
        params
      else
        raise "error: cannot convert #{object.class} object to params array"
      end
    end