samples

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const SupportedVersions = 0

SupportedVersions is the version number of the fixture template the CLI supports

Variables

View Source
var List = map[string]*SampleData{
	"adding-sales-tax":                 addingSalesTax,
	"checkout-subscription-and-add-on": checkoutSubscriptionAndAddOn,
	"placing-a-hold":                   placingAHold,
	"payment-form-modal":               paymentFormModal,
	"saving-card-without-payment":      savingCardWithoutPayment,
	"checkout-one-time-payments":       checkoutOneTimePayments,
	"checkout-single-subscription":     checkoutSingleSubscription,
	"web-elements-card-payment":        webElementsCardPayment,
	"saving-card-after-payment":        savingCardAfterPayment,
	"react-elements-card-payment":      reactElementsCardPayment,
}

List contains a mapping of Stripe Samples that we want to be available in the CLI to some of their metadata TODO: what do we want to name these for it to be easier for users to select?

Functions

func Names

func Names() []string

Names returns a list of all the sample's names

Types

type Fixture added in v0.6.2

type Fixture struct {
	Fs      afero.Fs
	APIKey  string
	BaseURL string
	// contains filtered or unexported fields
}

Fixture contains a mapping of an individual fixtures responses for querying

func NewFixture added in v0.6.2

func NewFixture(fs afero.Fs, apiKey, baseURL, file string) (*Fixture, error)

NewFixture creates a to later run steps for populating test data

func (*Fixture) Execute added in v0.6.2

func (fxt *Fixture) Execute() error

Execute takes the parsed fixture file and runs through all the requests defined to populate the user's account

func (*Fixture) UpdateEnv added in v0.6.2

func (fxt *Fixture) UpdateEnv() error

UpdateEnv uses the results of the fixtures command just executed and updates a local .env with the resulting data

type SampleData

type SampleData struct {
	Name        string
	URL         string
	Description string
}

SampleData stores the information needed for Stripe Samples to operate in the CLI

func (*SampleData) BoldName

func (sd *SampleData) BoldName() string

BoldName returns an ansi bold string for the name

func (*SampleData) GitRepo

func (sd *SampleData) GitRepo() string

GitRepo returns a string of the repo with the .git prefix

type Samples

type Samples struct {
	Config *config.Config
	Fs     afero.Fs
	Git    git.Interface
	// contains filtered or unexported fields
}

Samples stores the information for the selected sample in addition to the selected configuration option to copy over

func (*Samples) Cleanup added in v0.6.1

func (s *Samples) Cleanup(name string) error

Cleanup performs cleanup for the recently created sample

func (*Samples) ConfigureDotEnv

func (s *Samples) ConfigureDotEnv(sampleLocation string) error

ConfigureDotEnv takes the .env.example from the provided location and modifies it to automatically configure it for the users settings

func (*Samples) Copy

func (s *Samples) Copy(target string) error

Copy will copy all of the files from the selected configuration above oves. This has a few different behaviors, depending on the configuration. Ultimately, we want the user to do as minimal of folder traversing as possible. What we want to end up with is:

|- example-sample/ +-- client/ +-- server/ +-- readme.md +-- ... `-- .env.example

The behavior here is:

  • If there are no integrations available, copy the top-level files, the client folder, and the selected language inside of the server folder to the server top-level (example above)
  • If the user selects 1 integration, mirror the structure above for the selected integration (example above)
  • If they selected >1 integration, we want the same structure above but replicated once per selected in integration.

func (*Samples) GetFiles

func (s *Samples) GetFiles(path string) ([]string, error)

GetFiles returns a list of files for a given path

func (*Samples) GetFolders

func (s *Samples) GetFolders(path string) ([]string, error)

GetFolders returns a list of all folders for a given path

func (*Samples) Initialize

func (s *Samples) Initialize(app string) error

Initialize get the sample ready for the user to copy. It: 1. creates the sample cache folder if it doesn't exist 2. store the path of the locale cache folder for later use 3. if the selected app does not exist in the local cache folder, clone it 4. if the selected app does exist in the local cache folder, pull changes 5. see if there are different integrations available for the sample 6. see what languages the sample is available in

func (*Samples) MakeFolder

func (s *Samples) MakeFolder(name string) (string, error)

MakeFolder creates the folder that'll contain the Stripe app the user is creating

func (*Samples) PointToDotEnv

func (s *Samples) PointToDotEnv(target string) error

PointToDotEnv searches through the recently copied files for references to `../../..` and changes it to be one (or two) levels removed. Reason for this is that as part of configuring the sample, we'll remove 1-2 levels of the folder hierarchy so we need to adjust the references we point to.

func (*Samples) SelectOptions

func (s *Samples) SelectOptions() error

SelectOptions prompts the user to select the integration they want to use (if available) and the language they want the integration to be.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL