nabeelamjad / poke-api

Poke API - A Ruby API gem for Pokémon GO.
MIT License
82 stars 22 forks source link

Dropping inventory items #5

Closed coalwater closed 8 years ago

coalwater commented 8 years ago

I'm trying to do an api call that drops items from the inventory, I've used get_inventory and then filtered the items that I want to drop, then I created a call like this

client.recycle_inventory_item(201, 10)
client.call

but then I get this error

Poke::API::Errors::UnknownProtoFault: An unknown proto fault has occured => [uninitialized constant RpcSub::RecycleInventoryItemRequest @ /[gem_path]/gems/poke-api-0.0.2/lib/poke-api/request_builder.rb:87:in `fetch_proto_request_class']

Is this because the RpcSub needs to map all requests, or am I doing something wrong?

nabeelamjad commented 8 years ago

It seems like neither RecycleInventoryItemRequest nor response is in rpc_sub.rb. I suspect the Proto files need to be updated, I'll need to have a look at this some point upcoming weekend (they all need updating to the new structure).

However, If you really want to get this working I've published a branch with this call working for you: https://github.com/nabeelamjad/poke-api/tree/RecycleInventory (you can run gem build poke-api.gemspec && gem install poke-api-0.0.2.gem to override your gem once you checkout/download that git branch, alternatively point Bundler at the branch instead).

The way you would invoke this is client.recycle_inventory_item(item_id: 201, count: 10) followed with client.call.

coalwater commented 8 years ago

Ok thank you very much, will test and update you. if you need help with your api I could give you some of my time, the problem is that I don't really understand how this protos part works, maybe if you could guide me to something to give me the basics to start.

nabeelamjad commented 8 years ago

Have a look at this link: https://github.com/AeonLucid/POGOProtos/search?utf8=%E2%9C%93&q=recycle. I've gotten the proto files from there and simply added them to the existing structure (not too difficult, have a look at my commit). To generate proto files all you need to do is run the protoc command targeting the .proto files/directory. https://developers.google.com/protocol-buffers/docs/reference/ruby-generated goes into more detail about it, from there on you can simply use them by requiring the files and invoking the classes.

You will need to have protoc installed, instructions here: https://github.com/google/protobuf/blob/master/src/README.md.

Icehawk78 commented 8 years ago

Is there a reason you don't/can't just compile the entirety of the POGOProtos and drop them in here?

Would the existing structure support doing that, or would that be a very large change, given that the proto files seem to be somewhat regularly being updated?

nabeelamjad commented 8 years ago

Compiling the protos is quite straight forward, I would need to make sure the existing structure still works with the new protos (it'll be a case of making sure all the class names match, etc)

nabeelamjad commented 8 years ago

@Icehawk78 @coalwater - New protobufs are now up and running, let me know if there are any issues.

I've tagged it as 0.0.3, if something does not work then revert to 0.0.2 and let me know. I've had to use b2c48b17b560dc3d259d50a8afa1ef4199170bc4 @ POGOProtos while also adding a missing import on GetIncensePokemonResponse.proto. I will use the very latest protobufs once that repository has been fixed (there's quite some stuff broken now apparently). We're only a couple commits behind however, so everything should be good.