-
Notifications
You must be signed in to change notification settings - Fork 2
Metadata query params #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7f587c2
3fb156a
5073430
ef8337f
fcccd4c
67adf5f
2172df6
c11b163
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. | |
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.9.0] - 2021-08-17 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts on having this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bspellacy not sure I follow. What's the release flow you have in mind? I'm planning on releasing all the SDKs then the changes to patch (docs) |
||
|
||
### Added | ||
|
||
- Add support for querying Orders by `metadata` | ||
- Added `transaction_value_eth_gwei` as an alternative way to compute transaction level emissions for ethereum | ||
|
||
## [1.8.0] - 2021-07-20 | ||
|
||
### Added | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
patch_ruby (1.8.0) | ||
patch_ruby (1.9.0) | ||
json (~> 2.1, >= 2.1.0) | ||
typhoeus (~> 1.0, >= 1.0.1) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'rspec' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require "pathname" | ||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", | ||
Pathname.new(__FILE__).realpath) | ||
|
||
bundle_binstub = File.expand_path("../bundle", __FILE__) | ||
|
||
if File.file?(bundle_binstub) | ||
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ | ||
load(bundle_binstub) | ||
else | ||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. | ||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") | ||
end | ||
end | ||
|
||
require "rubygems" | ||
require "bundler/setup" | ||
|
||
load Gem.bin_path("rspec-core", "rspec") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ class CreateEthereumEstimateRequest | |
|
||
attr_accessor :gas_used | ||
|
||
attr_accessor :transaction_value_eth_gwei | ||
|
||
attr_accessor :project_id | ||
|
||
attr_accessor :create_order | ||
|
@@ -27,6 +29,7 @@ def self.attribute_map | |
{ | ||
:'timestamp' => :'timestamp', | ||
:'gas_used' => :'gas_used', | ||
:'transaction_value_eth_gwei' => :'transaction_value_eth_gwei', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kleinjm can you add this one to the changelog? |
||
:'project_id' => :'project_id', | ||
:'create_order' => :'create_order' | ||
} | ||
|
@@ -37,6 +40,7 @@ def self.openapi_types | |
{ | ||
:'timestamp' => :'String', | ||
:'gas_used' => :'Integer', | ||
:'transaction_value_eth_gwei' => :'Integer', | ||
:'project_id' => :'String', | ||
:'create_order' => :'Boolean' | ||
} | ||
|
@@ -50,6 +54,8 @@ def self.openapi_nullable | |
|
||
nullable_properties.add("gas_used") | ||
|
||
nullable_properties.add("transaction_value_eth_gwei") | ||
|
||
nullable_properties.add("project_id") | ||
|
||
nullable_properties.add("create_order") | ||
|
@@ -91,6 +97,10 @@ def initialize(attributes = {}) | |
self.gas_used = attributes[:'gas_used'] | ||
end | ||
|
||
if attributes.key?(:'transaction_value_eth_gwei') | ||
self.transaction_value_eth_gwei = attributes[:'transaction_value_eth_gwei'] | ||
end | ||
|
||
if attributes.key?(:'project_id') | ||
self.project_id = attributes[:'project_id'] | ||
end | ||
|
@@ -120,6 +130,7 @@ def ==(o) | |
self.class == o.class && | ||
timestamp == o.timestamp && | ||
gas_used == o.gas_used && | ||
transaction_value_eth_gwei == o.transaction_value_eth_gwei && | ||
project_id == o.project_id && | ||
create_order == o.create_order | ||
end | ||
|
@@ -133,7 +144,7 @@ def eql?(o) | |
# Calculates hash code according to all attributes. | ||
# @return [Integer] Hash code | ||
def hash | ||
[timestamp, gas_used, project_id, create_order].hash | ||
[timestamp, gas_used, transaction_value_eth_gwei, project_id, create_order].hash | ||
end | ||
|
||
# Builds the object from hash | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ | |
=end | ||
|
||
module Patch | ||
VERSION = '1.8.0' | ||
VERSION = '1.9.0' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
RSpec.describe 'Estimates Integration' do | ||
before do | ||
Patch.configure do |config| | ||
config.access_token = ENV['SANDBOX_API_KEY'] | ||
end | ||
end | ||
|
||
it 'supports create, retrieve and list' do | ||
create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100) | ||
estimate_id = create_estimate_response.data.id | ||
|
@@ -33,7 +27,7 @@ | |
) | ||
|
||
expect(flight_estimate.data.type).to eq 'flight' | ||
expect(flight_estimate.data.mass_g).to eq 1_031_697 | ||
expect(flight_estimate.data.mass_g).to eq 1_000_622 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirmed this change is correct with Brendan There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, we will probably want to remove this type of tests from the SDK itself. |
||
end | ||
|
||
it 'supports creating vehicle estimates' do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
RSpec.describe 'Orders Integration' do | ||
before do | ||
Patch.configure do |config| | ||
config.access_token = ENV['SANDBOX_API_KEY'] | ||
end | ||
end | ||
|
||
it 'supports create, place, cancel, retrieve and list' do | ||
create_order_response = Patch::Order.create_order(mass_g: 100) | ||
order_id = create_order_response.data.id | ||
|
@@ -71,15 +65,24 @@ | |
expect(order.registry_url).not_to be_empty | ||
end | ||
|
||
it 'supports create with metadata' do | ||
it 'supports creation with and querying by metadata' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel this is the most stable strategy for now. Creating an order with metadata and then querying for it in the same spec reduces the chance of the order being on a following page |
||
metadata = { user: 'john doe' } | ||
|
||
create_order_response = Patch::Order.create_order(mass_g: 100, metadata: metadata) | ||
create_order_response = | ||
Patch::Order.create_order(mass_g: 100, metadata: metadata) | ||
|
||
expect(create_order_response.success).to eq true | ||
expect(create_order_response.data.id).not_to be_nil | ||
expect(create_order_response.data.mass_g).to eq(100) | ||
expect(create_order_response.data.metadata).to eq(metadata) | ||
|
||
retrieve_orders_response = Patch::Order.retrieve_orders( | ||
page: 1, metadata: { user: 'john' } | ||
) | ||
expect(retrieve_orders_response.success).to eq true | ||
expect(retrieve_orders_response.data.count).to be >= 1 | ||
expect(retrieve_orders_response.data.map(&:metadata)) | ||
.to all(have_key(:user)) | ||
end | ||
|
||
it 'supports place and cancel for orders created via an estimate' do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
RSpec.describe 'Preferences Integration' do | ||
before do | ||
Patch.configure do |config| | ||
config.access_token = ENV['SANDBOX_API_KEY'] | ||
end | ||
end | ||
Comment on lines
-2
to
-6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to the helper |
||
|
||
it 'supports create, delete, retrieve and list' do | ||
retrieve_projects_response = Patch::Project.retrieve_projects | ||
expect(retrieve_projects_response.data.length).not_to be_zero | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
RSpec.describe 'Projects Integration' do | ||
Patch.configure do |config| | ||
config.access_token = ENV['SANDBOX_API_KEY'] | ||
end | ||
|
||
it 'supports retrieve and list' do | ||
page_limit = 1 | ||
next_page = 1 | ||
|
@@ -43,20 +39,12 @@ | |
end | ||
|
||
describe 'returned fields' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. combining specs here for performance and stability |
||
before do | ||
@project = Patch::Project.retrieve_projects(page: 1).data.first | ||
end | ||
|
||
it 'returns photos' do | ||
expect(@project.photos).to be_an_instance_of(Array) | ||
end | ||
|
||
it 'returns average_price_per_tonne_cents_usd' do | ||
expect(@project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer) | ||
end | ||
it 'returns the expected fields' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
project = Patch::Project.retrieve_projects(page: 1).data.first | ||
|
||
it 'returns remaining_mass_g' do | ||
expect(@project.remaining_mass_g).to be_an_instance_of(Integer) | ||
expect(project.photos).to be_an_instance_of(Array) | ||
expect(project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer) | ||
expect(project.remaining_mass_g).to be_an_instance_of(Integer) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,15 @@ | |
config.include FactoryBot::Syntax::Methods | ||
config.before(:suite) do | ||
FactoryBot.find_definitions | ||
Patch.configure do |config| | ||
if ENV.fetch('LOCAL_SDK_TEST', false) | ||
config.access_token = ENV.fetch('LOCAL_PATCH_API_KEY') | ||
Comment on lines
+45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set these 2 env vars to run tests against your local patch instance |
||
config.scheme = 'http' | ||
config.host = 'api.patch.test:3000' | ||
else | ||
config.access_token = ENV.fetch('SANDBOX_API_KEY') | ||
end | ||
end | ||
end | ||
|
||
# rspec-expectations config goes here. You can use an alternate | ||
|
@@ -66,6 +75,12 @@ | |
mocks.verify_partial_doubles = true | ||
end | ||
|
||
# Run specs in random order to surface order dependencies. If you find an | ||
# order dependency and want to debug it, you can fix the order by providing | ||
# the seed, which is printed after each run. | ||
# --seed 1234 | ||
config.order = :random | ||
|
||
# The settings below are suggested to provide a good initial experience | ||
# with RSpec, but feel free to customize to your heart's content. | ||
=begin | ||
|
@@ -107,12 +122,6 @@ | |
# particularly slow. | ||
config.profile_examples = 10 | ||
|
||
# Run specs in random order to surface order dependencies. If you find an | ||
# order dependency and want to debug it, you can fix the order by providing | ||
# the seed, which is printed after each run. | ||
# --seed 1234 | ||
config.order = :random | ||
|
||
# Seed global randomization in this process using the `--seed` CLI option. | ||
# Setting this allows you to use `--seed` to deterministically reproduce | ||
# test failures related to randomization by passing the same `--seed` value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will slow down CI but reduce the amount of "collisions" we may see due to the same tests running on the same endpoints in parallel. Considering we don't run CI on these projects very frequently, I feel the stability is worth the extra 2 minutes until we change up the test suite to not hit the real API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense!