Git Product home page Git Product logo

rick-and-morty-client's Introduction

Rick and Morty Client (Wrapper for Rick and Morty API)

	// Example FindByID Character
	characterService := services.NewCharacterService()
	character, _ := characterService.FindByID(1)
	fmt.Println("FindByID Character:")
	fmt.Println(reflect.TypeOf(character))
	fmt.Println(character)
	fmt.Println(character.ID)
	fmt.Println(character.Name)
	fmt.Println(character.Status)

	// Example FindAll Characters
	fmt.Println("FindAll Characters:")
	characterPages, _ := characterService.FindAll()
	fmt.Println(reflect.TypeOf(characterPages))
	fmt.Println("Page 1:", characterPages[0])
	fmt.Println("Pages:", len(characterPages))
	fmt.Println("Select character 1 from page 1:", characterPages[0].Characters[0])

	// Example Filter Characters
	// Available keys
	// name: filter by the given name.
	// status: filter by the given status (alive, dead or unknown).
	// species: filter by the given species.
	// type: filter by the given type.
	// gender: filter by the given gender (female, male, genderless or unknown).

	queryParams := map[string]string{
		"name":   "rick",
		"status": "alive",
	}

	fmt.Println("Filter Characters:")
	filteredCharacterPages, _ := characterService.Filter(queryParams)
	fmt.Println(reflect.TypeOf(filteredCharacterPages))
	fmt.Println("Page 1:", filteredCharacterPages[0])
	fmt.Println("Pages:", len(filteredCharacterPages))
	fmt.Println("Select character 1 from page 1:", filteredCharacterPages[0].Characters[0])

	// Example FindByID Location
	locationService := services.NewLocationService()
	location, _ := locationService.FindByID(1)
	fmt.Println("FindByID Location:")
	fmt.Println(reflect.TypeOf(location))
	fmt.Println(location)
	fmt.Println(location.ID)
	fmt.Println(location.Name)

	// Example FindAll Locations
	fmt.Println("FindAll Locations:")
	locationPages, _ := locationService.FindAll()
	fmt.Println(reflect.TypeOf(locationPages))
	fmt.Println("Page 1:", locationPages[0])
	fmt.Println("Pages:", len(locationPages))
	fmt.Println("Select location 1 from page 1:", locationPages[0].Locations[0])

	// Example Filter Locations
	// Available keys
	// name: filter by the given name.
	// type: filter by the given type.
	// dimension: filter by the given dimension.

	queryParamsLocation := map[string]string{
		"name": "earth",
		"type": "planet",
	}

	fmt.Println("Filter Location:")
	filteredLocationPages, _ := locationService.Filter(queryParamsLocation)
	fmt.Println(reflect.TypeOf(filteredLocationPages))
	fmt.Println("Page 1:", filteredLocationPages[0])
	fmt.Println("Pages:", len(filteredLocationPages))
	fmt.Println("Select location 1 from page 1:", filteredLocationPages[0].Locations[0])

Tests

rick-and-morty-client$ go test -v ./...

rick-and-morty-client's People

Contributors

edwbaeza avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.