// Create adds an arbitrary charge or credit to the customer's upcoming invoice.
//
// see https://stripe.com/docs/api#invoiceitem_object
965408
func (self *InvoiceItemClient) Create(params *InvoiceItemParams) (*InvoiceItem, error) {
	item := InvoiceItem{}
	values := url.Values{
		"amount":   {strconv.FormatInt(params.Amount, 10)},
		"currency": {params.Currency},
		"customer": {params.Customer},
	}

	// add optional parameters
	if len(params.Desc) != 0 {
		values.Add("description", params.Desc)
	}
	if len(params.Invoice) != 0 {
		values.Add("invoice", params.Invoice)
	}

	err := query("POST", "/v1/invoiceitems", values, &item)
	return &item, err
}
402775
func (c Client) New(params *stripe.UsageRecordParams) (*stripe.UsageRecord, error) {
	path := stripe.FormatURLPath("/v1/subscription_items/%s/usage_records", stripe.StringValue(params.SubscriptionItem))
	record := &stripe.UsageRecord{}
	err := c.B.Call(http.MethodPost, path, c.Key, params, record)
	return record, err
}
164386
func NewContractCreation(nonce int64, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
	return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
}
170941
func (c *FakeServiceAccounts) Create(serviceAccount *corev1.ServiceAccount) (result *corev1.ServiceAccount, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(serviceaccountsResource, c.ns, serviceAccount), &corev1.ServiceAccount{})

	if obj == nil {
		return nil, err
	}
	return obj.(*corev1.ServiceAccount), err
}
906301
func New(params *stripe.ChargeParams) (*stripe.Charge, error) {
	return getC().New(params)
}
447168
func New(params *stripe.CardParams) (*stripe.Card, error) {
	return getC().New(params)
}
1052991
func (c Client) New(params *stripe.CardParams) (*stripe.Card, error) {
	if params == nil {
		return nil, errors.New("params should not be nil")
	}

	var path string
	if params.Account != nil {
		path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts",
			stripe.StringValue(params.Account))
	} else if params.Customer != nil {
		path = stripe.FormatURLPath("/v1/customers/%s/sources",
			stripe.StringValue(params.Customer))
	} else if params.Recipient != nil {
		path = stripe.FormatURLPath("/v1/recipients/%s/cards",
			stripe.StringValue(params.Recipient))
	} else {
		return nil, errors.New("Invalid card params: either account, customer or recipient need to be set")
	}

	body := &form.Values{}

	// Note that we call this special append method instead of the standard one
	// from the form package. We should not use form's because doing so will
	// include some parameters that are undesirable here.
	params.AppendToAsCardSourceOrExternalAccount(body, nil)

	// Because card creation uses the custom append above, we have to make an
	// explicit call using a form and CallRaw instead of the standard Call
	// (which takes a set of parameters).
	card := &stripe.Card{}
	err := c.B.CallRaw(http.MethodPost, path, c.Key, body, &params.Params, card)
	return card, err
}
818679
func New(params *stripe.FileParams) (*stripe.File, error) {
	return getC().New(params)
}
679611
func (c *FakeTemplates) Create(templateResource *template.Template) (result *template.Template, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(templatesResource, c.ns, templateResource), &template.Template{})

	if obj == nil {
		return nil, err
	}
	return obj.(*template.Template), err
}
431475
func (s *Sanitizer) Create(ctx context.Context, i Item) (*Lease, error) {
	if !isKeySafe(i.Key) {
		return nil, trace.BadParameter(errorMessage)
	}
	return s.backend.Create(ctx, i)
}
508253
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
	return nil, errdefs.ErrNotImplemented
}
871174
func New(params *stripe.TopupParams) (*stripe.Topup, error) {
	return getC().New(params)
}
958646
func (m *Memory) Create(ctx context.Context, i backend.Item) (*backend.Lease, error) {
	if len(i.Key) == 0 {
		return nil, trace.BadParameter("missing parameter key")
	}
	m.Lock()
	defer m.Unlock()
	m.removeExpired()
	if m.tree.Get(&btreeItem{Item: i}) != nil {
		return nil, trace.AlreadyExists("key %q already exists", string(i.Key))
	}
	m.processEvent(backend.Event{
		Type: backend.OpPut,
		Item: i,
	})
	return m.newLease(i), nil
}
315781
func New(params *stripe.SubscriptionParams) (*stripe.Subscription, error) {
	return getC().New(params)
}
455085
func (b *DynamoDBBackend) Create(ctx context.Context, item backend.Item) (*backend.Lease, error) {
	err := b.create(ctx, item, modeCreate)
	if trace.IsCompareFailed(err) {
		err = trace.AlreadyExists(err.Error())
	}
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return b.newLease(item), nil
}
241007
func (r *GormWorkItemRepository) Create(ctx context.Context, spaceID uuid.UUID, typeID uuid.UUID, fields map[string]interface{}, creatorID uuid.UUID) (*WorkItem, *Revision, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitem", "create"}, time.Now())

	wiType, err := r.witr.Load(ctx, typeID)
	if err != nil {
		return nil, nil, errors.NewBadParameterError("typeID", typeID)
	}

	allowedWIT, err := r.CheckTypeAndSpaceShareTemplate(ctx, wiType, spaceID)
	if err != nil {
		return nil, nil, err

	}
	if !allowedWIT {
		return nil, nil, err
	}

	// The order of workitems are spaced by a factor of 1000.
	pos, err := r.LoadHighestOrder(ctx, spaceID)
	if err != nil {
		return nil, nil, errors.NewInternalError(ctx, err)
	}
	pos = pos + orderValue
	number, err := r.winr.NextVal(ctx, spaceID)
	if err != nil {
		return nil, nil, errors.NewInternalError(ctx, err)
	}
	wi := WorkItemStorage{
		Type:           typeID,
		Fields:         Fields{},
		ExecutionOrder: pos,
		SpaceID:        spaceID,
		Number:         *number,
	}
	fields[SystemCreator] = creatorID.String()
	for fieldName, fieldDef := range wiType.Fields {
		if fieldDef.ReadOnly {
			continue
		}
		fieldValue := fields[fieldName]
		var err error
		wi.Fields[fieldName], err = fieldDef.ConvertToModel(fieldName, fieldValue)
		if err != nil {
			return nil, nil, errors.NewBadParameterError(fieldName, fieldValue) // TODO(kwk): Change errors pkg to consume the original error as well
		}
		if fieldDef.Type.GetKind() == KindList && fieldValue == nil {
			delete(wi.Fields, fieldName)
		}
		if fieldName == SystemDescription && wi.Fields[fieldName] != nil {
			description := rendering.NewMarkupContentFromMap(wi.Fields[fieldName].(map[string]interface{}))
			if !rendering.IsMarkupSupported(description.Markup) {
				return nil, nil, errors.NewBadParameterError(fieldName, fieldValue)
			}
		}
	}
	if err := r.db.Create(&wi).Error; err != nil {
		return nil, nil, errs.Wrapf(err, "failed to create work item")
	}

	witem, err := ConvertWorkItemStorageToModel(wiType, &wi)
	if err != nil {
		return nil, nil, err
	}
	// store a revision of the created work item
	rev, err := r.wirr.Create(context.Background(), creatorID, RevisionTypeCreate, wi)
	if err != nil {
		return nil, nil, errs.Wrapf(err, "error while creating work item")
	}
	log.Debug(ctx, map[string]interface{}{"pkg": "workitem", "wi_id": wi.ID, "number": wi.Number}, "Work item created successfully!")
	return witem, &rev, nil
}
218841
func (c Client) New(params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
	invoiceItem := &stripe.InvoiceItem{}
	err := c.B.Call(http.MethodPost, "/v1/invoiceitems", c.Key, params, invoiceItem)
	return invoiceItem, err
}