xtremelabs / xl-passbook-ruby

Apache License 2.0
16 stars 10 forks source link

Very interesting gem #4

Closed sfielder closed 12 years ago

sfielder commented 12 years ago

How would you apply custom json to the pkpass that is not cointained in the templates json file?

Thanks!

xtreme-andrei-dinin commented 12 years ago

Hi, So the idea is that you have your template and then you override values. if you used the rails g passbook:pkpass command to generate some code, you should have a model created that actually modifies the json. def update_pass pkpass update_json pkpass.json end

In update_json method, some of the values (serial_number and authentication_token) are updated.

(In general, an instance of Passbook::Pkpass has json method that exposes the json)

Hope that helps. Let me know if you need more help!

Cheers, -Andrei D

On Tue, Oct 30, 2012 at 5:40 PM, sfielder notifications@github.com wrote:

How would you apply custom json to the pkpass that is not cointained in the templates json file?

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/xtremelabs/xl-passbook-ruby/issues/4.

sfielder commented 12 years ago

Thank you Andrei - makes total sense.

So all I have to do is:

1) add additional attributes to the model to support the json structure 2) instantiate and save my eventpass model 3) request the path added to routes file and send along param[:serial_number]

...and voila!

sound about right?

thanks again for your help!

Scott

xtreme-andrei-dinin commented 12 years ago

yeah, you can do it that way, as long as you replace the first line in "def self.update_or_create params" method right now its something like this eventpass_pass = find_by_card_id params[:card_id] and in your case, you want eventpass_pass = find_by_serial_number params[:serial_number]

Do you create passes upfront and then have them "picked up" whenever someone requests pass with that particular serial_number? Just interested in how you are using this so that I can improve the gem.

Cheers, -Andrei

On Tue, Oct 30, 2012 at 9:24 PM, sfielder notifications@github.com wrote:

Thank you Andrei - makes total sense.

So all I have to do is:

1) add additional attributes to the model to support the json structure 2) instantiate and save my eventpass model 3) request the path added to routes file and send along param[:serial_number]

...and voila!

sound about right?

thanks again for your help!

Scott

— Reply to this email directly or view it on GitHubhttps://github.com/xtremelabs/xl-passbook-ruby/issues/4#issuecomment-9929369.

sfielder commented 12 years ago

That is one of the use cases, but the way you have it setup is giving me some thoughts on others.

Was also wondering how to enable the registration feature, is that operational in the gem? If so, what is the process to get that working to manage devices? Do I need to update routes or other?

Really appreciate all your help!

S

xtreme-andrei-dinin commented 12 years ago

The passbook registration is in the gem and it is enabled by default. The routes are already setup in the gem too. As long as you have the following line (in your model) with correct service url, you should be good. pass_json['webServiceURL'] = "http://192.168.91.151:3000"

Cheers, -Andrei

On Wed, Oct 31, 2012 at 3:05 PM, sfielder notifications@github.com wrote:

That is one of the use cases, but the way you have it setup is giving me some thoughts on others.

Was also wondering how to enable the registration feature, is that operational in the gem? If so, what is the process to get that working to manage devices? Do I need to update routes or other?

Really appreciate all your help!

S

— Reply to this email directly or view it on GitHubhttps://github.com/xtremelabs/xl-passbook-ruby/issues/4#issuecomment-9957804.

sfielder commented 12 years ago

Awesome thx -

Was going to ask you one last thing about the images included in the template. Is it possible to pass URL strings vs the actual files in the templates folder?

Thanks again!

xtreme-andrei-dinin commented 12 years ago

No, you have to pass in content. I thought of doing that, but I think everyone's got their own strategy for this (timeouts and stuff) here's how I do it:

require 'open-uri'
  file_content = ""
  open(file_url, 'r', :read_timeout=>0.5) do |read_file|
    file_content<<read_file.read
  end
xtreme-andrei-dinin commented 12 years ago

closing. File a new issue if you have more questions.